diff --git a/apps/server/src/orchestration/Layers/CheckpointReactor.ts b/apps/server/src/orchestration/Layers/CheckpointReactor.ts index da0e08b931..a90a276d37 100644 --- a/apps/server/src/orchestration/Layers/CheckpointReactor.ts +++ b/apps/server/src/orchestration/Layers/CheckpointReactor.ts @@ -14,6 +14,7 @@ import { checkpointRefForThreadTurn, resolveThreadWorkspaceCwd, } from "../../checkpointing/Utils.ts"; +import { clearWorkspaceIndexCache } from "../../workspaceEntries.ts"; import { CheckpointStore } from "../../checkpointing/Services/CheckpointStore.ts"; import { ProviderService } from "../../provider/Services/ProviderService.ts"; import { CheckpointReactor, type CheckpointReactorShape } from "../Services/CheckpointReactor.ts"; @@ -218,6 +219,10 @@ const make = Effect.gen(function* () { checkpointRef: targetCheckpointRef, }); + // Invalidate the workspace entry cache so the @-mention file picker + // reflects files created or deleted during this turn. + clearWorkspaceIndexCache(checkpointCwd); + const files = yield* checkpointStore .diffCheckpoints({ cwd: checkpointCwd, @@ -493,6 +498,10 @@ const make = Effect.gen(function* () { return; } + // Invalidate the workspace entry cache so the @-mention file picker + // reflects the reverted filesystem state. + clearWorkspaceIndexCache(sessionRuntime.value.cwd); + const rolledBackTurns = Math.max(0, currentTurnCount - event.payload.turnCount); if (rolledBackTurns > 0) { yield* providerService.rollbackConversation({ diff --git a/apps/server/src/workspaceEntries.ts b/apps/server/src/workspaceEntries.ts index 2c215bb6db..dbce5c427d 100644 --- a/apps/server/src/workspaceEntries.ts +++ b/apps/server/src/workspaceEntries.ts @@ -409,6 +409,11 @@ async function getWorkspaceIndex(cwd: string): Promise { return nextPromise; } +export function clearWorkspaceIndexCache(cwd: string): void { + workspaceIndexCache.delete(cwd); + inFlightWorkspaceIndexBuilds.delete(cwd); +} + export async function searchWorkspaceEntries( input: ProjectSearchEntriesInput, ): Promise { diff --git a/apps/web/src/routes/__root.tsx b/apps/web/src/routes/__root.tsx index 3d7a815f09..0b378ccda9 100644 --- a/apps/web/src/routes/__root.tsx +++ b/apps/web/src/routes/__root.tsx @@ -22,6 +22,7 @@ import { preferredTerminalEditor } from "../terminal-links"; import { terminalRunningSubprocessFromEvent } from "../terminalActivity"; import { onServerConfigUpdated, onServerWelcome } from "../wsNativeApi"; import { providerQueryKeys } from "../lib/providerReactQuery"; +import { projectQueryKeys } from "../lib/projectReactQuery"; import { collectActiveTerminalThreadIds } from "../lib/terminalStateCleanup"; export const Route = createRootRouteWithContext<{ @@ -192,6 +193,9 @@ function EventRouter() { if (needsProviderInvalidation) { needsProviderInvalidation = false; void queryClient.invalidateQueries({ queryKey: providerQueryKeys.all }); + // Invalidate workspace entry queries so the @-mention file picker + // reflects files created, deleted, or restored during this turn. + void queryClient.invalidateQueries({ queryKey: projectQueryKeys.all }); } void syncSnapshot(); },