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 25, 08:45 UTC
fix: invalidate workspace entry cache after turn completion and revert (#796)
0x1f99d committed
Mar 11, 2026 at 08:42 UTC
ddd98876b5fe3dcb789a36ab799e6e211a1bcb5a
3 files changed
+18
apps/server/src/orchestration/Layers/CheckpointReactor.ts
+9
@@ -14,6 +14,7 @@ import {
14
checkpointRefForThreadTurn,
15
resolveThreadWorkspaceCwd,
16
} from "../../checkpointing/Utils.ts";
17
+import { clearWorkspaceIndexCache } from "../../workspaceEntries.ts";
18
import { CheckpointStore } from "../../checkpointing/Services/CheckpointStore.ts";
19
import { ProviderService } from "../../provider/Services/ProviderService.ts";
20
import { CheckpointReactor, type CheckpointReactorShape } from "../Services/CheckpointReactor.ts";
@@ -218,6 +219,10 @@ const make = Effect.gen(function* () {
219
checkpointRef: targetCheckpointRef,
220
});
221
222
+ // Invalidate the workspace entry cache so the @-mention file picker
223
+ // reflects files created or deleted during this turn.
224
+ clearWorkspaceIndexCache(checkpointCwd);
225
+
226
const files = yield* checkpointStore
227
.diffCheckpoints({
228
cwd: checkpointCwd,
@@ -493,6 +498,10 @@ const make = Effect.gen(function* () {
498
return;
499
}
500
501
+ // Invalidate the workspace entry cache so the @-mention file picker
502
+ // reflects the reverted filesystem state.
503
+ clearWorkspaceIndexCache(sessionRuntime.value.cwd);
504
+
505
const rolledBackTurns = Math.max(0, currentTurnCount - event.payload.turnCount);
506
if (rolledBackTurns > 0) {
507
yield* providerService.rollbackConversation({
apps/server/src/workspaceEntries.ts
+5
@@ -409,6 +409,11 @@ async function getWorkspaceIndex(cwd: string): Promise<WorkspaceIndex> {
409
return nextPromise;
410
}
411
412
+export function clearWorkspaceIndexCache(cwd: string): void {
413
+ workspaceIndexCache.delete(cwd);
414
+ inFlightWorkspaceIndexBuilds.delete(cwd);
415
+}
416
+
417
export async function searchWorkspaceEntries(
418
input: ProjectSearchEntriesInput,
419
): Promise<ProjectSearchEntriesResult> {
apps/web/src/routes/__root.tsx
+4
@@ -22,6 +22,7 @@ import { preferredTerminalEditor } from "../terminal-links";
22
import { terminalRunningSubprocessFromEvent } from "../terminalActivity";
23
import { onServerConfigUpdated, onServerWelcome } from "../wsNativeApi";
24
import { providerQueryKeys } from "../lib/providerReactQuery";
25
+import { projectQueryKeys } from "../lib/projectReactQuery";
26
import { collectActiveTerminalThreadIds } from "../lib/terminalStateCleanup";
27
28
export const Route = createRootRouteWithContext<{
@@ -192,6 +193,9 @@ function EventRouter() {
193
if (needsProviderInvalidation) {
194
needsProviderInvalidation = false;
195
void queryClient.invalidateQueries({ queryKey: providerQueryKeys.all });
196
+ // Invalidate workspace entry queries so the @-mention file picker
197
+ // reflects files created, deleted, or restored during this turn.
198
+ void queryClient.invalidateQueries({ queryKey: projectQueryKeys.all });
199
}
200
void syncSnapshot();
201
},