@devries-cameron20 / t3code Mirror · read-only / commits / b6f066b146
Fork 0

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 22, 10:45 UTC

fix(server): editing a file no longer forces a full search-index rescan (#24713)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Victor Vogel committed Oct 30, 2026 at 16:08 UTC b6f066b146210ed87a645a67b20da486bdf8f600
2 files changed +41 -1
apps/server/src/workspace/WorkspaceFileSystem.test.ts
+32
@@ -428,6 +428,38 @@ it.layer(layerTest, { excludeTestServices: true })("WorkspaceFileSystemLive", (i
428 }),
429 );
430
431 + it.effect("saves over an existing file without rescanning the workspace", () =>
432 + Effect.gen(function* () {
433 + const workspaceFileSystem = yield* WorkspaceFileSystem.WorkspaceFileSystem;
434 + const fileSystem = yield* FileSystem.FileSystem;
435 + const path = yield* Path.Path;
436 + const cwd = yield* makeTempDir;
437 + yield* writeTextFile(cwd, "src/main.ts", "export {};\n");
438 +
439 + yield* workspaceFileSystem.writeFile({
440 + cwd,
441 + relativePath: "src/main.ts",
442 + contents: "export const edited = true;\n",
443 + });
444 +
445 + expect(yield* fileSystem.readFileString(path.join(cwd, "src/main.ts"))).toBe(
446 + "export const edited = true;\n",
447 + );
448 + }).pipe(
449 + Effect.provide(
450 + Layer.fresh(WorkspaceFileSystem.layer).pipe(
451 + Layer.provide(layerKnownWorkspacesTest),
452 + Layer.provide(WorkspacePaths.layer),
453 + Layer.provide(
454 + Layer.mock(WorkspaceEntries.WorkspaceEntries)({
455 + refresh: () => Effect.die("An overwrite rescanned the workspace."),
456 + }),
457 + ),
458 + ),
459 + ),
460 + ),
461 + );
462 +
463 it.effect("rejects writes outside the workspace root", () =>
464 Effect.gen(function* () {
465 const workspaceFileSystem = yield* WorkspaceFileSystem.WorkspaceFileSystem;
apps/server/src/workspace/WorkspaceFileSystem.ts
+9 -1
@@ -531,6 +531,9 @@ export const make = Effect.gen(function* () {
531 yield* knownWorkspaces.assertContains(input.cwd);
532 const target = yield* resolveWriteTarget(input);
533 const realTargetPath = target.realTargetPath;
534 + const replacesFile = yield* fileSystem
535 + .exists(realTargetPath)
536 + .pipe(Effect.orElseSucceed(() => false));
537
538 yield* fileSystem.makeDirectory(path.dirname(realTargetPath), { recursive: true }).pipe(
539 Effect.mapError(
@@ -565,7 +568,12 @@ export const make = Effect.gen(function* () {
568 cause,
569 }),
570 });
568 - yield* workspaceEntries.refresh(input.cwd);
571 + // Editor autosave overwrites existing files, which leaves the indexed paths unchanged, and
572 + // fff's watcher applies the new contents on its own. A forced rescan re-walks the whole
573 + // workspace, and the save would wait for it.
574 + if (!replacesFile) {
575 + yield* workspaceEntries.refresh(input.cwd);
576 + }
577 return { relativePath: target.relativePath };
578 });
579