Skip to content

Reuse one chat page across plain chats, behind a debug switch (851-4336) - #1413

Merged
pondorasti merged 3 commits into
mainfrom
alexandru/851-4336-reused-page
Nov 18, 2026
Merged

pondorasti merged 3 commits into
mainfrom
alexandru/851-4336-reused-page

Conversation

@pondorasti

Copy link
Copy Markdown
Member

Part of 851-4336 (choose how tabs are presented), under 851-4331.

What this adds

A second way to present chats, off by default, behind the debug default workspaceDeck.reusedChatPage: instead of keeping five whole pages alive and rebuilding the rest, one page is reused for every plain chat (a workspace that is a single chat pane) and re-pointed at the chat being shown. Anything else (splits, terminals, browser, extra tabs, bots, archived) keeps its own page exactly as today.

With the switch off nothing changes for users; that path measures the same as main.

How it works

  • One shared deck slot for plain chats (Workspace.isPlainChat, unit tested). A workspace is never mounted in two pages: a route whose workspace is already mounted reuses that page.
  • Stable identities inside the shared page (route view, split leaf, pane content, chat screen), so SwiftUI updates the page instead of rebuilding it.
  • Transcripts are set aside, not detached. The container keeps a set-aside chat's transcript view hidden and brings it back on return, so nothing is re-mounted or redrawn. Set-aside transcripts skip layout until they return, count as detached for eviction, and the warm limit is 12 instead of 6 in this mode.
  • Live rows per chat. ActiveTranscriptProjection (CodevisorUI, unit tested) holds a chat's live rows next to its cached transcript, like the settled rows from Keep a chat's projected rows and composer height with its transcript (851-4335) #1406. Used on macOS in both modes; iOS is unchanged.
  • Re-point hooks. The page container re-wires itself and shows the new workspace; the chat screen moves its presentation, prompt-queue flag, history load and focus registrations; the composer resets its caret, prompt history, slash menu and undo stack. Per-chat counters (userSendSignal, transcriptPickSignal, submitRequest) are compared through ChatSignal, so a chat swap is never mistaken for a new signal.

Numbers

Debug build, 500-turn chats, main-thread work per switch, same script, fresh launches:

Switch Switch off (same as main) Switch on
Hotkey step between neighbouring chats 28-31 ms 34-35 ms
Jump back to any chat visited earlier (8 in rotation) 112-117 ms 40-43 ms
First visit to a chat ~195 ms ~140 ms

The neighbour step is a few ms slower than a kept-alive flip because hiding and unhiding a transcript makes its hosted rows refresh their environment; that is the next thing to remove before this can become the default.

Known gaps before it can be the default

  • The composer's remaining view state is reset by hand on a chat switch; it should move to a per-chat model like the rest (851-4335). A submission still in flight when the chat is switched can clear the in-flight flag of the next chat.
  • Composer undo history does not survive a chat switch.
  • Memory per warm transcript is not measured yet.
  • Only plain chats use the shared page.

Tophat (dev app, TRANSCRIPT_STRESS=1)

Switch on:

  • Sidebar clicks, the tab-step hotkeys and client navigation land on the right chat: title, highlight, transcript and scroll position follow, the composer is focused, and typing right after a switch goes to the shown chat. Drafts stay with their chats; a message sent in one chat does not appear in another.
  • Streaming chat: output that arrived while another chat was shown is there 120 ms after returning, with no duplicate or missing text; a turn that finished while away shows settled.
  • Undo after a switch does not replay the other chat's edits.
  • Splitting a chat that lives in the shared page works in place; focus moves between the panes; leaving and returning keeps the split; closing it works; plain chats keep using the shared page throughout.
  • New Chat, Bots mode and back.
  • Changing the sidebar width while a chat is set aside: it lays out correctly on return.

Switch off:

  • Same measurements as main; switching, a streaming chat while visible, kept alive, evicted and finished all behave as before.

Checks: swift test for ActiveTranscriptProjectionTests, TranscriptPresentationMountTests, WorkspacePlainChatTests, TranscriptFollowUpActivityTests, TranscriptRestorationTests, PageDeckTests; swift:format:check; swift:lint; build:ios.

🤖 Generated with Claude Code

pondorasti and others added 3 commits November 18, 2026 11:35
Work in progress: the page, its identities, the re-point hooks, the per-chat
live-rows model and the transcript container's set-aside behaviour.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…d stale focus (851-4336)

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…(851-4336)

Forget live rows when the last view leaves, clear the composer's undo stack
on a chat switch, never mount one workspace in two pages, skip layout for
set-aside transcripts, and hold a returning transcript until its live rows
arrive.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@pondorasti
pondorasti merged commit 8f450c6 into main Nov 18, 2026
@pondorasti
pondorasti deleted the alexandru/851-4336-reused-page branch November 18, 2026 19:40
pondorasti added a commit that referenced this pull request Nov 19, 2026
The reused chat page shipped behind a debug switch in #1413. Measured on a
release build with real chats it costs about the same per switch as a
kept-alive page, it makes going back to any visited chat as fast as a warm
switch, and it uses the same memory, so it is now on unless
workspaceDeck.reusedChatPage is set to false.

Co-authored-by: Claude Fable 5.2 <[email protected]>
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.

1 participant