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

This commit is contained in:
0x1f99d authored and GitHub committed 2026-03-10 14:42:39 -07:00
1 parent dfd41da2fd
commit ddd98876b5
3 files changed
+18

No files matched your search

@@ -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({
+5
View File
@@ -409,6 +409,11 @@ async function getWorkspaceIndex(cwd: string): Promise<WorkspaceIndex> {
return nextPromise;
}
export function clearWorkspaceIndexCache(cwd: string): void {
workspaceIndexCache.delete(cwd);
inFlightWorkspaceIndexBuilds.delete(cwd);
}
export async function searchWorkspaceEntries(
input: ProjectSearchEntriesInput,
): Promise<ProjectSearchEntriesResult> {
+4
View File
@@ -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();
},