Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.
fix: invalidate workspace entry cache after turn completion and revert (#796)
0x1f99dddd98876b5fe
diff --git a/apps/server/src/orchestration/Layers/CheckpointReactor.ts b/apps/server/src/orchestration/Layers/CheckpointReactor.tsindex da0e08b93..a90a276d3 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.tsindex 2c215bb6d..dbce5c427 100644--- a/apps/server/src/workspaceEntries.ts+++ b/apps/server/src/workspaceEntries.ts@@ -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> {diff --git a/apps/web/src/routes/__root.tsx b/apps/web/src/routes/__root.tsxindex 3d7a815f0..0b378ccda 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();},