Skip to content

Fix stale transcript rendered under a new thread selection (#83) - #102

Merged
currentbits merged 1 commit into
mainfrom
coder/stale-transcript-shown-under-the-new-sel-28ac1b
Aug 16, 2026
Merged

currentbits merged 1 commit into
mainfrom
coder/stale-transcript-shown-under-the-new-sel-28ac1b

Conversation

@currentbits

Copy link
Copy Markdown
Owner

Problem

When switching threads, useCoder keeps the previous thread's detail until the new threads.get resolves, and ThreadView had no guard that detail.thread.id matches the selection. Over --serve-web latency the old transcript and composer rendered under the new sidebar selection — and a fast send would go to the NEW thread while the user was still reading the old one.

Fix

Gate the detail on the selection at render time. App.tsx now derives:

const visibleDetail =
  detail && detail.thread.id === selectedThreadId ? detail : null;

and uses visibleDetail for ThreadView, AgentsPanel (workflow/thread/usage), and project resolution. While the fetch for a freshly clicked thread is in flight, the view falls back to the existing "Select a thread" empty state instead of showing the previous thread.

Chose the render gate over clearing detail on selection change in useCoder: the load effect runs after paint, so clearing there would still flash one stale frame. The gate is correct at render time, and ThreadView already handles detail === null, so no component changes were needed.

Test

New app-level regression test in test/appWiring.test.tsx ("never renders the previous thread's transcript under a new selection"): it patches the fake's threads.get into a deferred promise to simulate latency, clicks another thread, asserts the old transcript is gone and the empty state shows, then resolves the fetch and asserts the new transcript renders. Verified non-vacuous — it fails with the gate removed.

Full renderer suite 672/672 green, tsc --noEmit clean.

Closes #83

  • PR created by the Kimi Code agent

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@currentbits
currentbits merged commit 614ba14 into main Aug 16, 2026
1 check passed
@currentbits
currentbits deleted the coder/stale-transcript-shown-under-the-new-sel-28ac1b branch October 3, 2026 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stale transcript shown under the new selection while switching threads

1 participant