The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 11:00 UTC
fix(server): the first file search after a big folder lands no longer freezes the server (#37451)
Julius Marminge committed
Nov 15, 2026 at 19:16 UTC
0813f4978e7449ca2b01598e3caea4b250e3cacb
4 files changed
+120
-68
apps/server/src/workspace/WorkspaceSearchIndex.test.ts
+10
-6
@@ -170,7 +170,7 @@ it.effect("fetches past a first page of Git-ignored results", () =>
170
ok: true as const,
171
value: { isScanning: false },
172
}),
173
- watch: () => ({ ok: true as const, value: () => undefined }),
173
+ watchAsync: async () => ({ ok: true as const, value: () => undefined }),
174
fileSearchAsync: fileSearch,
175
} as unknown as FileFinder;
176
vi.spyOn(FileFinder, "create").mockReturnValueOnce({ ok: true, value: finder });
@@ -197,7 +197,7 @@ it.effect.skipIf(HostProcess.Platform.defaultValue() === "win32")(
197
ok: true as const,
198
value: { isScanning: false },
199
}),
200
- watch: () => ({ ok: true as const, value: () => undefined }),
200
+ watchAsync: async () => ({ ok: true as const, value: () => undefined }),
201
fileSearchAsync: vi.fn(async () => ({
202
ok: true as const,
203
value: { items, scores: [], totalMatched: 1, totalFiles: 1 },
@@ -264,7 +264,7 @@ it.effect("continues whole-word searches after a filtered grep page", () =>
264
ok: true as const,
265
value: { isScanning: false },
266
}),
267
- watch: () => ({ ok: true as const, value: () => undefined }),
267
+ watchAsync: async () => ({ ok: true as const, value: () => undefined }),
268
grepAsync: grep,
269
} as unknown as FileFinder;
270
vi.spyOn(FileFinder, "create").mockReturnValueOnce({ ok: true, value: finder });
@@ -333,7 +333,7 @@ it.live("answers content searches with git grep while a slow content index build
333
ok: true as const,
334
value: { isScanning: false, isWarmupComplete },
335
}),
336
- watch: () => ({ ok: true as const, value: () => undefined }),
336
+ watchAsync: async () => ({ ok: true as const, value: () => undefined }),
337
grepAsync: grep,
338
} as unknown as FileFinder;
339
const noPcreFinder = {
@@ -512,10 +512,14 @@ function fakeSymlinkFinder(
512
ok: true as const,
513
value: { isScanning: false },
514
}),
515
- watch: (callback: (events: ReadonlyArray<WatchEvent>) => void) => {
515
+ // fff's watch waits on the picker lock on the JS thread.
516
+ watch: () => {
517
+ throw new Error("watch must not run on the JS thread");
518
+ },
519
+ watchAsync: async (callback: (events: ReadonlyArray<WatchEvent>) => void) => {
520
if (watchFailures > 0) {
521
watchFailures -= 1;
518
- throw new Error("File system watcher is not ready");
522
+ return { ok: false as const, error: "File system watcher is not ready" };
523
}
524
watchers.push(callback);
525
return { ok: true as const, value: () => undefined };
apps/server/src/workspace/WorkspaceSearchIndex.ts
+21
-23
@@ -1030,38 +1030,36 @@ export const make = Effect.fn("WorkspaceSearchIndex.make")(function* (
1030
if (!editsOnly) invalidateSymlinkScan();
1031
};
1032
// fff refuses subscriptions until its watcher is up, which can trail the initial scan, so
1033
- // each read retries until one is in place.
1033
+ // each read retries until one is in place. Subscribing waits on fff's picker lock, which its
1034
+ // watcher holds while it indexes a new folder, so it runs off the JS thread.
1035
let unwatch: WatchUnsubscribe | undefined;
1036
yield* Effect.addFinalizer(() => Effect.sync(() => unwatch?.()));
1036
- const ensureWatching = () => {
1037
+ const ensureWatching = Effect.fn("WorkspaceSearchIndex.ensureWatching")(function* () {
1038
if (unwatch) return true;
1038
- try {
1039
- const result = finder.watch(onWatchBatch);
1040
- if (result.ok) unwatch = result.value;
1041
- } catch {
1042
- // Not ready yet; the next read tries again.
1043
- }
1039
+ const result = yield* Effect.promise(() =>
1040
+ finder.watchAsync(onWatchBatch).catch(() => undefined),
1041
+ );
1042
+ if (result?.ok) unwatch = result.value;
1043
return unwatch !== undefined;
1045
- };
1044
+ });
1045
const indexScope = yield* Effect.scope;
1046
const startSymlinkScan = Effect.fn("WorkspaceSearchIndex.startSymlinkScan")(function* () {
1047
symlinkScanStale = false;
1049
- // Subscribing before the scan starts means no change during it goes unseen.
1050
- const watched = ensureWatching();
1048
const done = yield* Deferred.make<SymlinkScan>();
1049
pendingSymlinkScan = done;
1053
- yield* scanSymlinkEntries().pipe(
1054
- Effect.tap((result) =>
1055
- Effect.gen(function* () {
1056
- lastSymlinkScan = result;
1057
- knownLinkPaths = result.linkPaths;
1058
- // Without a watcher, or before fff has seen every folder, the result is kept only briefly.
1059
- lastSymlinkScanExpiresAt =
1060
- watched && result.indexComplete
1061
- ? undefined
1062
- : (yield* Clock.currentTimeMillis) + UNWATCHED_SYMLINK_SCAN_TTL_MS;
1063
- }),
1064
- ),
1050
+ yield* Effect.gen(function* () {
1051
+ // Subscribing before the scan starts means no change during it goes unseen.
1052
+ const watched = yield* ensureWatching();
1053
+ const result = yield* scanSymlinkEntries();
1054
+ lastSymlinkScan = result;
1055
+ knownLinkPaths = result.linkPaths;
1056
+ // Without a watcher, or before fff has seen every folder, the result is kept only briefly.
1057
+ lastSymlinkScanExpiresAt =
1058
+ watched && result.indexComplete
1059
+ ? undefined
1060
+ : (yield* Clock.currentTimeMillis) + UNWATCHED_SYMLINK_SCAN_TTL_MS;
1061
+ return result;
1062
+ }).pipe(
1063
Effect.onExit((exit) =>
1064
Effect.sync(() => {
1065
pendingSymlinkScan = undefined;
patches/@ff-labs__fff-node@0.11.0.patch
+86
-36
@@ -30,7 +30,7 @@ index 0f90eedca20655ccd30b8f28e433b2094341fbdf..c2ef86927d6e3ab0e8584330fa0ac3fd
30
/** Total number of items (files + dirs) that matched */
31
totalMatched: number;
32
diff --git a/dist/finder.d.ts b/dist/finder.d.ts
33
-index 452102d720cc19b0560cfc9e2f1a320687047c92..490dba5277c8d751b53ed239c0ce77f3e11f9c43 100644
33
+index 452102d720cc19b0560cfc9e2f1a320687047c92..704b52c3d076c50c3bf15e96a574385c9862670c 100644
34
--- a/dist/finder.d.ts
35
+++ b/dist/finder.d.ts
36
@@ -242,6 +242,18 @@ export declare class FileFinder implements FileFinderApi {
@@ -63,8 +63,17 @@ index 452102d720cc19b0560cfc9e2f1a320687047c92..490dba5277c8d751b53ed239c0ce77f3
63
/**
64
* Wait for the initial file scan to complete.
65
* Non-blocking: polls `isScanning` and yields to the event loop between checks.
66
+@@ -360,6 +376,8 @@ export declare class FileFinder implements FileFinderApi {
67
+ */
68
+ watch(callback: WatchBatchCallback, options?: WatchOptions): Result<WatchUnsubscribe>;
69
+ watch(pattern: string, callback: WatchBatchCallback, options?: WatchOptions): Result<WatchUnsubscribe>;
70
++ /** `watch(callback)` without blocking the JS thread. Patched in T3 Code. */
71
++ watchAsync(callback: WatchBatchCallback, options?: WatchOptions): Promise<Result<WatchUnsubscribe>>;
72
+ /**
73
+ * Get health check information.
74
+ *
75
diff --git a/dist/index.js b/dist/index.js
67
-index 7c1d722eabc8d8eb98998eb48c5fe9d70b749d10..5d9fbf45095bd2b2ff1c321c03b85414498bde57 100644
76
+index 7c1d722eabc8d8eb98998eb48c5fe9d70b749d10..69bfa2cc9023103f52cc469bbec917eab68fa806 100644
77
--- a/dist/index.js
78
+++ b/dist/index.js
79
@@ -1,7 +1,7 @@
@@ -116,14 +125,14 @@ index 7c1d722eabc8d8eb98998eb48c5fe9d70b749d10..5d9fbf45095bd2b2ff1c321c03b85414
125
const { rawPtr, struct: structData } = callRaw(funcName, paramsType, paramsValue);
126
+ return envelopeFromRaw(rawPtr, structData);
127
+}
119
-+async function readResultEnvelopeOnNativeThread(funcName, handle) {
128
++async function readResultEnvelopeOnNativeThread(funcName, paramsType, paramsValue) {
129
+ loadLibrary();
130
+ const rawPtr = await load({
131
+ library: LIBRARY_KEY,
132
+ funcName,
133
+ retType: DataType.External,
125
-+ paramsType: [DataType.External],
126
-+ paramsValue: [handle],
134
++ paramsType,
135
++ paramsValue,
136
+ freeResultMemory: false,
137
+ runInNewThread: true
138
+ });
@@ -137,7 +146,7 @@ index 7c1d722eabc8d8eb98998eb48c5fe9d70b749d10..5d9fbf45095bd2b2ff1c321c03b85414
146
if (structData.success === 0) {
147
const errorStr = readCString(structData.error);
148
freeResult(rawPtr);
140
-@@ -311,7 +342,9 @@ function readResultEnvelope(funcName, paramsType, paramsValue) {
149
+@@ -311,13 +342,17 @@ function readResultEnvelope(funcName, paramsType, paramsValue) {
150
return { rawPtr, struct: structData };
151
}
152
function callVoidResult(funcName, paramsType, paramsValue) {
@@ -148,7 +157,16 @@ index 7c1d722eabc8d8eb98998eb48c5fe9d70b749d10..5d9fbf45095bd2b2ff1c321c03b85414
157
if ("ok" in res) return res;
158
freeResult(res.rawPtr);
159
return { ok: true, value: void 0 };
151
-@@ -417,18 +450,20 @@ function ffiCreate(basePath, frecencyDbPath, historyDbPath, _useUnsafeNoLock, en
160
+ }
161
+ function callIntResult(funcName, paramsType, paramsValue) {
162
+- const res = readResultEnvelope(funcName, paramsType, paramsValue);
163
++ return intResultFromEnvelope(readResultEnvelope(funcName, paramsType, paramsValue));
164
++}
165
++function intResultFromEnvelope(res) {
166
+ if ("ok" in res) return res;
167
+ const value = Number(res.struct.int_value);
168
+ freeResult(res.rawPtr);
169
+@@ -417,18 +452,20 @@ function ffiCreate(basePath, frecencyDbPath, historyDbPath, _useUnsafeNoLock, en
170
}
171
function ffiDestroy(handle) {
172
loadLibrary();
@@ -174,7 +192,7 @@ index 7c1d722eabc8d8eb98998eb48c5fe9d70b749d10..5d9fbf45095bd2b2ff1c321c03b85414
192
size: DataType.U64,
193
modified: DataType.U64,
194
access_frecency_score: DataType.I64,
177
-@@ -445,8 +480,9 @@ var FFF_SCORE_STRUCT = {
195
+@@ -445,8 +482,9 @@ var FFF_SCORE_STRUCT = {
196
distance_penalty: DataType.I32,
197
current_file_penalty: DataType.I32,
198
combo_match_boost: DataType.I32,
@@ -185,7 +203,7 @@ index 7c1d722eabc8d8eb98998eb48c5fe9d70b749d10..5d9fbf45095bd2b2ff1c321c03b85414
203
};
204
var FFF_SEARCH_RESULT_STRUCT = {
205
items: DataType.External,
188
-@@ -462,8 +498,8 @@ var FFF_SEARCH_RESULT_STRUCT = {
206
+@@ -462,8 +500,8 @@ var FFF_SEARCH_RESULT_STRUCT = {
207
location_end_col: DataType.I32
208
};
209
var FFF_DIR_ITEM_STRUCT = {
@@ -196,7 +214,7 @@ index 7c1d722eabc8d8eb98998eb48c5fe9d70b749d10..5d9fbf45095bd2b2ff1c321c03b85414
214
max_access_frecency: DataType.I32
215
};
216
var FFF_DIR_SEARCH_RESULT_STRUCT = {
199
-@@ -475,9 +511,9 @@ var FFF_DIR_SEARCH_RESULT_STRUCT = {
217
+@@ -475,9 +513,9 @@ var FFF_DIR_SEARCH_RESULT_STRUCT = {
218
};
219
var FFF_MIXED_ITEM_STRUCT = {
220
item_type: DataType.U8,
@@ -209,7 +227,7 @@ index 7c1d722eabc8d8eb98998eb48c5fe9d70b749d10..5d9fbf45095bd2b2ff1c321c03b85414
227
size: DataType.U64,
228
modified: DataType.U64,
229
access_frecency_score: DataType.I64,
212
-@@ -500,10 +536,10 @@ var FFF_MIXED_SEARCH_RESULT_STRUCT = {
230
+@@ -500,10 +538,10 @@ var FFF_MIXED_SEARCH_RESULT_STRUCT = {
231
location_end_col: DataType.I32
232
};
233
var FFF_GREP_MATCH_STRUCT = {
@@ -224,7 +242,7 @@ index 7c1d722eabc8d8eb98998eb48c5fe9d70b749d10..5d9fbf45095bd2b2ff1c321c03b85414
242
match_ranges: DataType.External,
243
context_before: DataType.External,
244
context_after: DataType.External,
227
-@@ -598,18 +634,13 @@ function readMixedItemFromRaw(raw) {
245
+@@ -598,18 +636,13 @@ function readMixedItemFromRaw(raw) {
246
}
247
function callAccessor(funcName, resultPtr, index, structDef) {
248
loadLibrary();
@@ -245,7 +263,7 @@ index 7c1d722eabc8d8eb98998eb48c5fe9d70b749d10..5d9fbf45095bd2b2ff1c321c03b85414
263
}
264
function ptrOffset(base, bytes) {
265
return load({
248
-@@ -766,6 +797,7 @@ function parseSearchResult(rawPtr) {
266
+@@ -766,6 +799,7 @@ function parseSearchResult(rawPtr) {
267
}
268
const items = [];
269
const scores = [];
@@ -253,7 +271,7 @@ index 7c1d722eabc8d8eb98998eb48c5fe9d70b749d10..5d9fbf45095bd2b2ff1c321c03b85414
271
for (let i = 0; i < count; i++) {
272
const rawItem = callAccessor(
273
"fff_search_result_get_item",
256
-@@ -774,13 +806,15 @@ function parseSearchResult(rawPtr) {
274
+@@ -774,13 +808,15 @@ function parseSearchResult(rawPtr) {
275
FFF_FILE_ITEM_STRUCT
276
);
277
items.push(readFileItemFromRaw(rawItem));
@@ -276,7 +294,7 @@ index 7c1d722eabc8d8eb98998eb48c5fe9d70b749d10..5d9fbf45095bd2b2ff1c321c03b85414
294
}
295
load({
296
library: LIBRARY_KEY,
279
-@@ -824,6 +858,7 @@ function parseDirSearchResult(rawPtr) {
297
+@@ -824,6 +860,7 @@ function parseDirSearchResult(rawPtr) {
298
const count = sr.count;
299
const items = [];
300
const scores = [];
@@ -284,7 +302,7 @@ index 7c1d722eabc8d8eb98998eb48c5fe9d70b749d10..5d9fbf45095bd2b2ff1c321c03b85414
302
for (let i = 0; i < count; i++) {
303
const rawItem = callAccessor(
304
"fff_dir_search_result_get_item",
287
-@@ -832,13 +867,15 @@ function parseDirSearchResult(rawPtr) {
305
+@@ -832,13 +869,15 @@ function parseDirSearchResult(rawPtr) {
306
FFF_DIR_ITEM_STRUCT
307
);
308
items.push(readDirItemFromRaw(rawItem));
@@ -307,7 +325,7 @@ index 7c1d722eabc8d8eb98998eb48c5fe9d70b749d10..5d9fbf45095bd2b2ff1c321c03b85414
325
}
326
load({
327
library: LIBRARY_KEY,
310
-@@ -897,6 +934,7 @@ function parseMixedSearchResult(rawPtr) {
328
+@@ -897,6 +936,7 @@ function parseMixedSearchResult(rawPtr) {
329
}
330
const items = [];
331
const scores = [];
@@ -315,7 +333,7 @@ index 7c1d722eabc8d8eb98998eb48c5fe9d70b749d10..5d9fbf45095bd2b2ff1c321c03b85414
333
for (let i = 0; i < count; i++) {
334
const rawItem = callAccessor(
335
"fff_mixed_search_result_get_item",
318
-@@ -905,13 +943,15 @@ function parseMixedSearchResult(rawPtr) {
336
+@@ -905,13 +945,15 @@ function parseMixedSearchResult(rawPtr) {
337
FFF_MIXED_ITEM_STRUCT
338
);
339
items.push(readMixedItemFromRaw(rawItem));
@@ -338,7 +356,7 @@ index 7c1d722eabc8d8eb98998eb48c5fe9d70b749d10..5d9fbf45095bd2b2ff1c321c03b85414
356
}
357
load({
358
library: LIBRARY_KEY,
341
-@@ -932,7 +972,7 @@ function parseMixedSearchResult(rawPtr) {
359
+@@ -932,7 +974,7 @@ function parseMixedSearchResult(rawPtr) {
360
}
361
return { ok: true, value: result };
362
}
@@ -347,7 +365,7 @@ index 7c1d722eabc8d8eb98998eb48c5fe9d70b749d10..5d9fbf45095bd2b2ff1c321c03b85414
365
loadLibrary();
366
const rawPtr = load({
367
library: LIBRARY_KEY,
350
-@@ -966,9 +1006,10 @@ function ffiSearch(handle, query, currentFile, maxThreads, pageIndex, pageSize,
368
+@@ -966,9 +1008,10 @@ function ffiSearch(handle, query, currentFile, maxThreads, pageIndex, pageSize,
369
comboBoostMultiplier,
370
minComboCount
371
],
@@ -360,7 +378,7 @@ index 7c1d722eabc8d8eb98998eb48c5fe9d70b749d10..5d9fbf45095bd2b2ff1c321c03b85414
378
}
379
function ffiGlob(handle, pattern, currentFile, maxThreads, pageIndex, pageSize) {
380
loadLibrary();
363
-@@ -995,7 +1036,7 @@ function ffiGlob(handle, pattern, currentFile, maxThreads, pageIndex, pageSize)
381
+@@ -995,7 +1038,7 @@ function ffiGlob(handle, pattern, currentFile, maxThreads, pageIndex, pageSize)
382
});
383
return parseSearchResult(rawPtr);
384
}
@@ -369,7 +387,7 @@ index 7c1d722eabc8d8eb98998eb48c5fe9d70b749d10..5d9fbf45095bd2b2ff1c321c03b85414
387
loadLibrary();
388
const rawPtr = load({
389
library: LIBRARY_KEY,
372
-@@ -1016,11 +1057,12 @@ function ffiSearchDirectories(handle, query, currentFile, maxThreads, pageIndex,
390
+@@ -1016,11 +1059,12 @@ function ffiSearchDirectories(handle, query, currentFile, maxThreads, pageIndex,
391
// page_size
392
],
393
paramsValue: [handle, query, currentFile ?? "", maxThreads, pageIndex, pageSize],
@@ -385,7 +403,7 @@ index 7c1d722eabc8d8eb98998eb48c5fe9d70b749d10..5d9fbf45095bd2b2ff1c321c03b85414
403
loadLibrary();
404
const rawPtr = load({
405
library: LIBRARY_KEY,
388
-@@ -1054,11 +1096,12 @@ function ffiSearchMixed(handle, query, currentFile, maxThreads, pageIndex, pageS
406
+@@ -1054,11 +1098,12 @@ function ffiSearchMixed(handle, query, currentFile, maxThreads, pageIndex, pageS
407
comboBoostMultiplier,
408
minComboCount
409
],
@@ -401,7 +419,7 @@ index 7c1d722eabc8d8eb98998eb48c5fe9d70b749d10..5d9fbf45095bd2b2ff1c321c03b85414
419
loadLibrary();
420
const rawPtr = load({
421
library: LIBRARY_KEY,
404
-@@ -1107,9 +1150,10 @@ function ffiLiveGrep(handle, query, mode, maxFileSize, maxMatchesPerFile, smartC
422
+@@ -1107,9 +1152,10 @@ function ffiLiveGrep(handle, query, mode, maxFileSize, maxMatchesPerFile, smartC
423
afterContext,
424
classifyDefinitions
425
],
@@ -414,7 +432,7 @@ index 7c1d722eabc8d8eb98998eb48c5fe9d70b749d10..5d9fbf45095bd2b2ff1c321c03b85414
432
}
433
function ffiMultiGrep(handle, patternsJoined, constraints, maxFileSize, maxMatchesPerFile, smartCase, fileOffset, pageLimit, timeBudgetMs, enforceTimeBudget, beforeContext, afterContext, classifyDefinitions) {
434
loadLibrary();
417
-@@ -1188,7 +1232,11 @@ var FFF_SCAN_PROGRESS_STRUCT = {
435
+@@ -1188,7 +1234,11 @@ var FFF_SCAN_PROGRESS_STRUCT = {
436
};
437
function ffiGetScanProgress(handle) {
438
loadLibrary();
@@ -427,7 +445,7 @@ index 7c1d722eabc8d8eb98998eb48c5fe9d70b749d10..5d9fbf45095bd2b2ff1c321c03b85414
445
if ("ok" in res) return res;
446
const handlePtr = res.struct.handle;
447
freeResult(res.rawPtr);
430
-@@ -1429,6 +1477,10 @@ var FileFinder = class _FileFinder {
448
+@@ -1429,6 +1479,10 @@ var FileFinder = class _FileFinder {
449
handle;
450
/** Native ids of this instance's active watch subscriptions. */
451
watchers = /* @__PURE__ */ new Set();
@@ -438,7 +456,7 @@ index 7c1d722eabc8d8eb98998eb48c5fe9d70b749d10..5d9fbf45095bd2b2ff1c321c03b85414
456
constructor(handle) {
457
this.handle = handle;
458
}
441
-@@ -1485,12 +1537,115 @@ var FileFinder = class _FileFinder {
459
+@@ -1485,11 +1539,147 @@ var FileFinder = class _FileFinder {
460
destroy() {
461
if (this.handle !== null) {
462
const handle = this.handle;
@@ -460,8 +478,8 @@ index 7c1d722eabc8d8eb98998eb48c5fe9d70b749d10..5d9fbf45095bd2b2ff1c321c03b85414
478
+ } else {
479
+ release();
480
+ }
463
- }
464
- }
481
++ }
482
++ }
483
+ /**
484
+ * Patched in T3 Code: runs a handle-only call on a libuv pool thread so waiting on fff's
485
+ * picker lock never blocks the JS thread. Concurrent callers share one call, so one finder
@@ -472,15 +490,16 @@ index 7c1d722eabc8d8eb98998eb48c5fe9d70b749d10..5d9fbf45095bd2b2ff1c321c03b85414
490
+ if (!guard.ok) return Promise.resolve(guard);
491
+ const pending = this.nativeThreadCalls.get(funcName);
492
+ if (pending) return pending;
475
-+ const call = readResultEnvelopeOnNativeThread(funcName, guard.value).then(fromEnvelope, (cause) => err(String(cause))).finally(() => {
493
++ const call = readResultEnvelopeOnNativeThread(funcName, [DataType.External], [guard.value]).then(fromEnvelope, (cause) => err(String(cause))).finally(() => {
494
+ this.nativeThreadCalls.delete(funcName);
495
+ });
496
+ this.nativeThreadCalls.set(funcName, call);
497
+ return call;
498
+ }
499
+ /**
482
-+ * Patched in T3 Code: runs a search on a libuv pool thread. Searches on one finder run one at
483
-+ * a time, so while fff's watcher holds the picker lock a finder holds at most one pool thread.
500
++ * Patched in T3 Code: runs a search or subscription on a libuv pool thread. They run one at a
501
++ * time per finder, so while fff's watcher holds the picker lock a finder holds at most one pool
502
++ * thread.
503
+ */
504
+ searchOnNativeThread(search) {
505
+ const guard = this.ensureAlive();
@@ -535,6 +554,38 @@ index 7c1d722eabc8d8eb98998eb48c5fe9d70b749d10..5d9fbf45095bd2b2ff1c321c03b85414
554
+ true
555
+ ));
556
+ }
557
++ /**
558
++ * Patched in T3 Code: `watch` without blocking the JS thread. Subscribing takes the picker lock,
559
++ * which fff's watcher holds while it indexes a new directory.
560
++ */
561
++ watchAsync(callback, options) {
562
++ if (typeof callback !== "function") {
563
++ return Promise.resolve(err("watch callback must be a function"));
564
+ }
565
++ const ignore = options?.ignore ?? [];
566
++ return this.searchOnNativeThread(async (handle) => {
567
++ const registered = ensureWatchCallbackRegistered(handle);
568
++ if (!registered.ok) return registered;
569
++ const created = intResultFromEnvelope(await readResultEnvelopeOnNativeThread(
570
++ "fff_watch_args",
571
++ [DataType.External, DataType.String, DataType.StringArray, DataType.U32],
572
++ [handle, "", ignore, ignore.length]
573
++ ));
574
++ if (!created.ok) return created;
575
++ // fff_destroy drops the native subscription of a finder destroyed meanwhile.
576
++ if (this.handle !== handle) return this.ensureAlive();
577
++ const watchId = created.value;
578
++ watchHandlers.set(watchId, callback);
579
++ this.watchers.add(watchId);
580
++ return {
581
++ ok: true,
582
++ value: () => {
583
++ if (!this.watchers.delete(watchId)) return;
584
++ if (this.handle !== null) ffiUnwatch(this.handle, watchId);
585
++ }
586
++ };
587
++ });
588
++ }
589
+ /** Patched in T3 Code: `grep` without blocking the JS thread. */
590
+ grepAsync(query, options) {
591
+ return this.searchOnNativeThread((handle) => ffiLiveGrep(
@@ -553,11 +604,10 @@ index 7c1d722eabc8d8eb98998eb48c5fe9d70b749d10..5d9fbf45095bd2b2ff1c321c03b85414
604
+ options?.classifyDefinitions ?? false,
605
+ true
606
+ ));
556
-+ }
607
+ }
608
/**
609
* Check if this instance has been destroyed.
559
- */
560
-@@ -1757,6 +1912,18 @@ var FileFinder = class _FileFinder {
610
+@@ -1757,6 +1947,18 @@ var FileFinder = class _FileFinder {
611
if (!guard.ok) return guard;
612
return ffiScanFiles(guard.value);
613
}
@@ -576,7 +626,7 @@ index 7c1d722eabc8d8eb98998eb48c5fe9d70b749d10..5d9fbf45095bd2b2ff1c321c03b85414
626
/**
627
* Check if a scan is currently in progress.
628
*/
579
-@@ -1838,7 +2005,8 @@ var FileFinder = class _FileFinder {
629
+@@ -1838,7 +2040,8 @@ var FileFinder = class _FileFinder {
630
if (!guard.ok) return guard;
631
const deadline = Date.now() + timeoutMs;
632
while (true) {
pnpm-lock.yaml
+3
-3
@@ -369,7 +369,7 @@ patchedDependencies:
369
'@effect/platform-node-shared@4.1.2': 06952843c6f431ca83c78762fd18d23cda76883801049ee311feced2438ecf14
370
'@effect/vitest@4.1.2': 299510b71c36537a832a67e9d160a5f112a5f326a29e95c41cb45fc8234e47c7
371
'@expo/ui@58.0.27': 9f2547678939f4ec78fe45163b6455aad63d3c80353d7e0cc783f6a61a7ccc2f
372
- '@ff-labs/fff-node@0.11.0': 3be7107340e5f388114da259637828cd47f2b32eb8ae572440715c4e38cffe6e
372
+ '@ff-labs/fff-node@0.11.0': 93f62a76399b435a76588b2bef237db0a1e85880c1ac0d0759c416e9cc579252
373
'@legendapp/list@3.7.2': 3c68607b8bb7a531873bcbe0b197d163ef1fdb4d4cf52a4ddf9d2b3804671658
374
'@muse-code/sdk@1.4.6': 7b495b607fc5d76b444c7c4d58821e839726a30e6f3c53564f0d59f2d5b42101
375
'@pierre/diffs@1.7.0-beta.4': dd078a7448ce6727aaaa8b8b6702fe0ff02e85f18efa7c441a768530cabbe0cc
@@ -862,7 +862,7 @@ importers:
862
version: 4.1.2(patch_hash=06952843c6f431ca83c78762fd18d23cda76883801049ee311feced2438ecf14)(bufferutil@4.1.0)(effect@4.1.3)(utf-8-validate@6.0.6)
863
'@ff-labs/fff-node':
864
specifier: 0.11.0
865
- version: 0.11.0(patch_hash=3be7107340e5f388114da259637828cd47f2b32eb8ae572440715c4e38cffe6e)
865
+ version: 0.11.0(patch_hash=93f62a76399b435a76588b2bef237db0a1e85880c1ac0d0759c416e9cc579252)
866
'@muse-code/sdk':
867
specifier: 1.4.6
868
version: 1.4.6(patch_hash=7b495b607fc5d76b444c7c4d58821e839726a30e6f3c53564f0d59f2d5b42101)(@types/node@24.12.4)
@@ -15177,7 +15177,7 @@ snapshots:
15177
'@ff-labs/fff-bin-win32-x64@0.11.0':
15178
optional: true
15179
15180
- '@ff-labs/fff-node@0.11.0(patch_hash=3be7107340e5f388114da259637828cd47f2b32eb8ae572440715c4e38cffe6e)':
15180
+ '@ff-labs/fff-node@0.11.0(patch_hash=93f62a76399b435a76588b2bef237db0a1e85880c1ac0d0759c416e9cc579252)':
15181
dependencies:
15182
ffi-rs: 1.3.2
15183
optionalDependencies: