Skip to content

fix(site): fall back to chat detail cache for archive-and-delete confirmation - #25055

Closed
blinkagent[bot] wants to merge 1 commit into
mainfrom
blink/codagt-317-chat-cache-fallback
Closed

fix(site): fall back to chat detail cache for archive-and-delete confirmation#25055
blinkagent[bot] wants to merge 1 commit into
mainfrom
blink/codagt-317-chat-cache-fallback

Conversation

@blinkagent

@blinkagent blinkagent Bot commented May 7, 2026

Copy link
Copy Markdown
Contributor

Closes CODAGT-317 (partially — see Caveat below).

Problem

The "Archive agent & delete workspace" molly-guard (typing the workspace name) was firing inconsistently for chats whose workspaces were clearly auto-provisioned. The heuristic in resolveArchiveAndDeleteAction is:

if (chatCreatedAt && isWorkspaceAutoCreated(workspace.created_at, chatCreatedAt)) {
  return "proceed";
}
return "confirm";

The chatCreatedAt callback only read from the infinite chat-list cache:

() =>
  readInfiniteChatsCache(queryClient)?.find((c) => c.id === chatId)?.created_at,

If the chat row wasn't in a currently-loaded page of the infinite list query (different filter active, scrolled past the loaded pages, or invoked from a context where the sidebar list wasn't materialized for that chat), the lookup returned undefined, the chatCreatedAt && ... short-circuited to false, and the dialog was shown regardless of who created the workspace. From the user's perspective the molly-guard appeared at random.

Fix

Fall back to the per-chat detail cache (chatKey(chatId)) when the list cache misses. That cache is populated whenever the user has visited the chat — which is essentially always true in the archive-and-delete flow.

() =>
  readInfiniteChatsCache(queryClient)?.find((c) => c.id === chatId)
    ?.created_at ??
  queryClient.getQueryData<TypesGen.Chat>(chatKey(chatId))?.created_at,

The resolver itself is unchanged — the existing "chat not found in cache → confirm" test still holds. Only the call site widens where it looks for created_at.

Caveat

This fixes one source of the false-positive dialog (cache miss). There are reports of the dialog still firing after a full page reload with the chat open, which would not be addressed by this change — those cases likely involve a workspace whose created_at genuinely predates the chat's created_at (e.g. rebound to a pre-existing workspace, or a recreated-with-same-name workspace whose timestamp comparison goes the wrong way). Diagnostic info is being collected for that path; a more durable fix is in flight in #25053 which replaces the timestamp heuristic with an explicit workspace_auto_created column.

Test plan

  • pnpm lint:types passes.
  • pnpm vitest run --project=unit src/pages/AgentsPage/utils/agentWorkspaceUtils.test.ts — 28/28 pass; existing "chat not found in cache → confirm" case still covers the both-caches-miss scenario.
  • pnpm biome check passes on the changed file.

Created on behalf of @kylecarbs (reported) and @johnstcn (asked for the PR).

@github-actions github-actions Bot added the community Pull Requests and issues created by the community. label May 7, 2026
@johnstcn

johnstcn commented May 8, 2026

Copy link
Copy Markdown
Member

Closing in favour of #25057

@johnstcn johnstcn closed this May 8, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators May 8, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

community Pull Requests and issues created by the community.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant