agent pane: per-chat pieces keep their last value across a switch, reconnect or reload

Merged
TE
18d ago
+418-76

Many pieces of the agent pane are read per chat, folder, scope or harness. Each drew nothing, a stand-in or Loading on a switch, reconnect or reload until its read came back, then popped in or changed size. Each now keeps its last answer on the page and draws it in the first render; the read that follows only refreshes it.

piecebefore, on a switch, reconnect or reloadnow
edited-files card, Changes countstool-call counts, then the checkpoint's (numbers and height change)each chat's answered checkpoints (16 chats; a running turn's incomplete checkpoint isn't kept)
worktree pillgone, then back, pushing the header toolslast worktree per folder
Changes view on Retry, stage, unstage, commitwhole list to Loadingkeeps the list, branch names and threads, still clickable, until the new answer; picking a scope still starts from Loading
harness health noticecleared on disconnect, pops in late and pushes the composerlast answer per harness, kept through a reconnect
slash commands"No commands" until the attacheach chat's commands from its last visit (32 chats)
empty chat while connectingblank transcript, then the herothe hero (only a failed connect drops it)
bookmark dotsdropped on reconnect, then backkept until the new connection's read
chats list and peers on a new chat's handshakeemptied until the first client framekept
subagent view on a chat switchone frame of the old subagent (empty child view)closed in the same render
transcript first framedrawn at a guessed 600x760, then measuredmeasured before first paint, starting from the last box
composer location rowone frame of the wrong computer with no folderthe chat's computer in the same render
#123 linksthe chat before's repositoryeach folder's repository from its last read; none until read

Evidence

Probes record committed renders (layout effects, before paint). Each test failed on the base before its fix:

  • webviews/test/agent-pane-switch-frames.test.ts (Chromium) passes in CI at aa4a298.
  • webviews/test/agent-pane-keeps-last-on-switch.test.tsx: checkpoints, worktree pill, Changes reload, empty chat hero. 4 of 4 red at ea4d53d, green at d8b1d72.
  • webviews/test/thread-bookmarks.test.tsx: reconnect keeps marks. Red at 0c78f31, green at 3b75e26.

Health, commands, the handshake list, the subagent view, the transcript box, the location row and links have no test of their own here.

Other checks:

  • tsc --noEmit: 0 errors.
  • vp fmt and vp lint are clean on the changed files.
  • bun test test/: no failures beyond the base run except tests that pass alone and fail only under load. Those are changes-more-lines and changes-file-review, which pass alone and together with the new test; and app-theme and palette-eval, as on base.
  • Not done: a live app dogfood.

The All chats list on the New Tab page is left out; the New Tab work owns it.

Changelog

Fixed: in agent chats, the edited-files card, worktree pill, Changes list, sign-in notice, slash commands and bookmarks no longer blink or jump when you switch chats, reconnect or reload.

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.


Summary by cubic

Fixes the agent pane so per-chat, per-folder, per-scope, and per-harness pieces keep their last value across a chat switch, reconnect, or reload, instead of drawing nothing, a stand-in, or Loading until their read came back.

Bug Fixes

  • The edited-files card, Changes counts, worktree pill, Changes list, harness health notice, slash commands, bookmark dots, the composer location row, and transcript links draw their last answer in the first render; the read that follows only refreshes it.
  • An empty chat keeps its hero while the pane connects; only a failed connect drops it.
  • A new chat's handshake keeps the chats list and peers until the first client frame.
  • A chat switch closes the subagent view in the same render, not an effect later.
  • The transcript measures its box before first paint, starting from the last measured size.
  • Reloading the Changes scope on screen (Retry, stage, unstage, commit) keeps the list, branch names, and threads until the new answer; picking a scope still starts from Loading.
  • During a held switch, actions (Stop, archive, queue edits, permission and secret answers, picks, fork, ask) go to the chat on screen, never the hidden one; a send waits for the switch to draw and reads the handoff first, refusing with "The agent connection is not open." when it cannot.
  • Answers land only in their own chat's state, a failed read (a removed worktree or unreachable connection) drops the kept value, and a new chat never inherits a prior chat's computer pick.