authorgravatar for crazywolf132@gmail.com0x1f99d <crazywolf132@gmail.com> 2026-03-11 08:42:39+11:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2026-03-10 14:42:39-07:00
logddd98876b5fe3dcb789a36ab799e6e211a1bcb5a
tree519ccd1a2d7ec1a979ad9583b501ffe136d829c6
parentdfd41da2fdc7e9268fe0e46d3ab29d1f2161b3a2
signature Signed by PGP key B5690EEEBB952194

fix: invalidate workspace entry cache after turn completion and revert (#796)


3 files changed, 18 insertions(+), 0 deletions(-)

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