You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Keep only on-screen chats loaded, so memory stays flat - #45916
Before: every chat you opened stayed fully loaded in the background for the rest of the session. After a long day with many chats, Orca's window grew to several GB of memory and never gave it back.
Now: Orca keeps only the chats on screen loaded. A chat loads again when you switch back to it, and it comes back as you left it: your unsent draft, the place you were reading (up to 600 rows back), open sections, a half-answered question or approval, a queued message you were editing, Find and its selected match, and any reply still streaming in. Undo history in the message box starts fresh after a switch, as it does when you open a chat.
Files
Added
Deleted
Net
Test
16
$\color{#1a7f37}{\Huge{\mathbf{+}}}$1301
$\color{#cf222e}{\Huge{\mathbf{−}}}$62
$\color{#1a7f37}{\Huge{\mathbf{+}}}$1239
Prod
100
$\color{#1a7f37}{\Huge{\mathbf{+}}}$2649
$\color{#cf222e}{\Huge{\mathbf{−}}}$682
$\color{#1a7f37}{\Huge{\mathbf{+}}}$1967
What Changed
Before: switching back to any chat visited earlier was instant, but memory grew about 13 MB per chat visited. After: switching back reloads the chat, at about the cost of opening it the first time (switch times below), and memory stays roughly flat.
native-chat-view-retention.ts decides which chat views stay mounted across the window: the shown chats, in every split. StructuredAgentSessionPaneOverlayLayer.tsx mounts from that set. Bot rooms are unchanged.
native-chat-view-memory.ts is a small per-tab store for view state that used to live only in the mounted view (reading position, expanded turns, Find, question answers, approval detail, new-message marker, the /compact and fork guards). It is bounded per tab and dropped when the tab closes; native-chat-closed-tab-release.ts releases closed tabs from the tab store, including tabs whose workspace is not on screen.
The draft text already lives in the draft store, so it survives the reload; the editor and its Undo history are not kept for a released chat.
An open queued-message edit stays open across a switch: the edit and its delivery hold are kept with the tab and handed back to the chat's draft only when the tab closes.
A chat's read owner is now dropped once its last send settles, so a chat released mid-send does not keep its transcript.
Why
Hidden chat views were the largest piece of renderer memory on heavy profiles. Visiting 150 chats with 2 long turns each on a 1,901-workspace profile (Linux, production build, memory after GC):
Chats visited
Renderer before
Renderer after
Whole app before
Whole app after
10
617 MB
490 MB
1,128 MB
964 MB
60
1,426 MB
722 MB
1,916 MB
1,257 MB
150
2,710 MB
764 MB
3,334 MB
1,348 MB
Mounting only the chat on screen and keeping each chat's view state and drafts outside the view is the usual shape for chat apps with many threads. Keeping hidden chats mounted, or keeping each chat's editor for its Undo history, would bring the growth back.
Linked Issue
None: maintainer change from a memory investigation on heavy profiles.
Visual Proof
N/A: nothing looks different. A released chat reloads with the same transcript, draft and reading position. The change is in memory use, measured above.
Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
QA ran on a Linux production build with a profile of about 1,900 workspaces and real Claude and Codex agents. The final run covered every flow below in both a Claude and a Codex chat:
Memory: after visiting 150 chats, the renderer used 650 MB on this change, against 2,710 MB on main (76% less). An earlier version that still kept 3 hidden chats loaded used 764 MB (766 MB with a draft left in every chat).
Coming back after release: a released chat returned with its draft, reading position, expanded turns, a pending approval it could still answer, a reply still streaming in, and Find with its selected match. A chat scrolled near the start of a 1,200-message history opened at the end after reading 3 older pages.
Remount flows:
/clear then coming back: the expanded turn returned, and the cleared turns stayed hidden.
Queued message reorder while switched away: the moved order was kept.
Rewind while switched away: Send was enabled again once the rewound conversation showed.
Closing a switched-away chat with a draft, then reopening it from Session History.
Renaming the workspace of a switched-away chat.
A queued edit across a switch: still open with its text, and handed back to the draft when the tab closed.
A draft across a switch.
Switch time: from clicking a previously opened chat to its text showing, over 30 switches between 10 chats with long transcripts. On main the chat is already loaded; here it reloads.
Run
This change, median / p95
Main, median / p95
Machine load average
1
95.6 / 243 ms
49.8 / 63.6 ms
about 7 (other work on the machine)
2
74.2 / 99.6 ms
43.5 / 54.7 ms
6.5 falling to 3
3
72.9 / 84.2 ms
–
about 3
In run 1, switches 14 to 20 took 156 to 259 ms while the machine was busy; the other switches took 67 to 124 ms. An earlier run gave 72 / 86 ms here and 46 / 66 ms on main.
Reading position: after a keyboard scroll, it came back exactly, including inside one long reply.
Unit tests cover the logic where a silent regression would cost the most:
Only shown chats stay mounted.
Closed tabs release their state, while renamed or moved tabs keep it, and that work stays bounded.
Writes from a closed tab's old requests are ignored.
A guard still in flight is never evicted.
After a release, these come back and block a second request: an async answer, a queued reorder, a queued edit, /clear's hold and the rewind guard.
The new-message marker and the reading-position bookmark come back too.
Each test fails with its fix reverted.
Performance
Renderer memory at 150 visited chats drops from 2,710 MB to 650 MB (76% less). The trade is that each switch back to a chat now reloads it: about 73 ms median against about 45 ms on main, with p95 84 to 100 ms on a quiet machine and 243 ms in one run on a busy one (Testing above). A chat that was scrolled up reads up to 3 older pages (600 rows) to get back to where the reader was; past that it opens at the end. Nothing new runs while idle, and no work grows with the number of tabs or workspaces on a keystroke, store update or switch.
Risk
The riskiest part is a chat coming back after release: if some piece of view state was missed, a user would see it reset (a section collapsed again, or the reading position back at the end). Drafts, running turns, approvals and questions belong to the session or are kept per tab, so no work or text is lost. Nothing is saved to disk; settings, SSH servers and paired phones are unaffected. Back out with a plain revert.
Every guard a chat view held for a send, request or action now lives with the chat tab. A chat released mid-request comes back still waiting on it and can't send it twice. Each guard belongs to the chat tab's lifetime and to the conversation it shows: a request that settles after its tab closed, or after the tab switched to another chat, changes nothing. A guard is dropped when its request settles, and they all end when the tab closes:
Sends and answers: async question answers, approvals and worker approvals, paired-device asks, the queued-message send/delete guard, /compact, /clear's hold on sends until the new conversation shows, fork and rewind (each held per conversation, so a late reply never blocks the chat that replaced it), and Continue after an interruption.
Queued messages: reorder (its pending flag and the previewed order), and an open edit (kept open, with its delivery hold, until Save, Cancel, the tab closing or a reload, which hands the typed text back to the chat's draft).
Stops: background-task Stop, and joining a repeated Stop on older hosts.
Composer and account: leaving plan mode, taking input back from a phone, redeeming a Codex reset credit (and its retry key), cancelling an automatic continue after a usage limit, the Antigravity sign-in switch, Claude account sign-in (held per account, so no chat can cancel another's login, and a login that finishes while the chat is switched away shows as signed in on return), model and option picks in flight, reconnecting or starting a stopped host, and opening a terminal for a host command.
Cards in the transcript: automation save, run and wait-cancel, Send again on an automation run, create-bot offers, added bot tools, auto-review approvals, the thread goal, the worker dock, and bot tool and Composio app sign-ins, finishing a sign-in from a pasted address, Google setup (sign-in and its waiting state, including one started from the account picker, accounts, client file, stop, step answers, blocker answers, the signed-in account step).
Left in the view on purpose:
Terminal-chat sends, their prompt card and session-option commands: unmounting cancels the pending terminal write, so nothing is left in flight.
Fork's same-click flag: it is set and cleared together with the kept fork guard.
Stop's "Stopping" label: it's only presentation, and a repeated Stop joins the kept Stop request.
Orca Cloud sign-in: its progress is already held app-wide, not in the view.
Reads, not actions: copying session context, preparing a hand-off, re-checking an agent install, retrying an MCP or link lookup, Slack mirror status, command refresh, and history jumps.
After a request settles: the "stop confirmed" marker on a background task (a second Stop on a stopped task does nothing). In a Google setup card the account picks are kept until Add; in a dialog they last as long as the dialog is open.
Coming back to a chat you left far up its history reads at most 3 older pages (600 rows) to get back to where you were. Past that, the chat opens at the end instead of replaying the history page by page on every switch.
Level: Medium
AI Disclosure
Review
Agent skill upstream boundary
Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.
Notes
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Checklist
This PR is small and focused
I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
I stated the risk: what could break, for whom, and how to back it out
Before/after screenshots or videos attached for UI changes, or N/A with reason
Self-reviewed for correctness, security, and performance
Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)
brennanb2025
changed the title
perf(native-chat): keep only shown and recently shown chat views mounted
Keep only on-screen and recently viewed chats loaded, so memory stays flat
Nov 20, 2026
…nd abandoned runs beyond the newest few are dropped
brennanb2025
changed the title
Keep only on-screen and recently viewed chats loaded, so memory stays flat
Keep only on-screen chats loaded, so memory stays flat
Nov 28, 2026
It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.
No actionable comments were generated in the recent review.
Walkthrough
The PR adds per-tab native-chat view memory, retention, and release handling. It moves state for setup flows, prompts, in-progress actions, composer operations, and queued-session operations into keyed tab memory. It adds transcript-scoped state for expanded turns, disclosures, new-row markers, Find, and reading-position restoration. Navigation supports waiting rows and offsets. Tests cover remounts, tab closure and movement, and pending operations.
Merge Risk: Low · up to c32c5
The change keeps only on-screen chats loaded and restores view state when a chat is revisited. Several edge cases remain open where a failure or completion arriving after a chat switch is not shown on return. These are minor and recoverable, so the change is mergeable with follow-up.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the main change: only on-screen chats stay loaded, which keeps memory flat. The changeset matches this. The title is concise and specific, so a teammate scanning history would understa…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Description check
The description is thorough and covers every template section. It has a clear ELI5, a detailed What Changed section, a Why section with measured memory and switch-time data, and a Performance line tha…
Full details: Title check
Explanation
The title names the main change: only on-screen chats stay loaded, which keeps memory flat. The changeset matches this. The title is concise and specific, so a teammate scanning history would understand the primary change.
Full details: Description check
Explanation
The description is thorough and covers every template section. It has a clear ELI5, a detailed What Changed section, a Why section with measured memory and switch-time data, and a Performance line that states the trade-off. It also has a Risk section with a Level and a back-out plan, and it includes Testing with checked items and QA steps. Two gaps remain. The Linked Issue section says 'None' and gives a maintainer reason, which the template does not cover for outside contributors. The AI Disclosure section is empty. The template says to leave that section blank for internal team members, so the empty section may be acceptable, but the author should confirm it.
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.
QA on a test copy with about 1,900 workspaces, at 00cc9de026f. A remounted chat keeps its draft, scroll position, open sections, pending approvals and questions, the queued message being edited, and streaming output. Renderer memory at 150 visited chats: 764 MB (2,710 MB on main). Switching back to a chat: median 72 ms and p95 86 ms (main: 46 ms and 66 ms).
Since QA: guards are now held per conversation. A return reads at most 3 older pages of history. Find keeps its selected match, and a Claude sign-in that finishes while you're in another chat shows on return. Each fix has a test that fails without it.
Checks:pnpm check:changed passes on this head (45 checks), and CI is green.
QA at 9e91ed6d90d, on a Linux production build with 1,901 workspaces and 1,800 chat tabs, using real Claude (Opus 5.5, Medium) and Codex chats.
Renderer memory at 150 visited chats: 650 MB here, 2,710 MB on main.
Every flow passed for both agents:
draft, reading position, pending approval, streaming reply, Find with its selected match, queued-message edit, and /clear (Claude only), each across a switch
a chat left near the start of a 1,200-message history opens at the end after reading 3 older pages
Switch time (median / p95, 30 switches):
Here: 95.6 / 243 ms on a busy machine (load average about 7), then 74.2 / 99.6 and 72.9 / 84.2 ms.
Main: 49.8 / 63.6 and 43.5 / 54.7 ms.
Since QA: two later commits cap the kept errors per tab, keep the worker dock's Retry with the view that made it, refill a refused address that arrives late, and fix a test. None of them touches a QA flow.
Checks:pnpm check:changed passes on this head (45 checks), CI is green, and all review threads are resolved.
Perf-scan on 0cd0d9d19a9: clean. It covers the last shipped changes, the per-tab caps on kept errors and the worker dock's Retry, plus the subscribe surface across the PR.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ELI5
Before: every chat you opened stayed fully loaded in the background for the rest of the session. After a long day with many chats, Orca's window grew to several GB of memory and never gave it back.
Now: Orca keeps only the chats on screen loaded. A chat loads again when you switch back to it, and it comes back as you left it: your unsent draft, the place you were reading (up to 600 rows back), open sections, a half-answered question or approval, a queued message you were editing, Find and its selected match, and any reply still streaming in. Undo history in the message box starts fresh after a switch, as it does when you open a chat.
What Changed
native-chat-view-retention.tsdecides which chat views stay mounted across the window: the shown chats, in every split.StructuredAgentSessionPaneOverlayLayer.tsxmounts from that set. Bot rooms are unchanged.native-chat-view-memory.tsis a small per-tab store for view state that used to live only in the mounted view (reading position, expanded turns, Find, question answers, approval detail, new-message marker, the/compactand fork guards). It is bounded per tab and dropped when the tab closes;native-chat-closed-tab-release.tsreleases closed tabs from the tab store, including tabs whose workspace is not on screen.Why
Hidden chat views were the largest piece of renderer memory on heavy profiles. Visiting 150 chats with 2 long turns each on a 1,901-workspace profile (Linux, production build, memory after GC):
Mounting only the chat on screen and keeping each chat's view state and drafts outside the view is the usual shape for chat apps with many threads. Keeping hidden chats mounted, or keeping each chat's editor for its Undo history, would bring the growth back.
Linked Issue
None: maintainer change from a memory investigation on heavy profiles.
Visual Proof
N/A: nothing looks different. A released chat reloads with the same transcript, draft and reading position. The change is in memory use, measured above.
Testing
QA ran on a Linux production build with a profile of about 1,900 workspaces and real Claude and Codex agents. The final run covered every flow below in both a Claude and a Codex chat:
Memory: after visiting 150 chats, the renderer used 650 MB on this change, against 2,710 MB on main (76% less). An earlier version that still kept 3 hidden chats loaded used 764 MB (766 MB with a draft left in every chat).
Coming back after release: a released chat returned with its draft, reading position, expanded turns, a pending approval it could still answer, a reply still streaming in, and Find with its selected match. A chat scrolled near the start of a 1,200-message history opened at the end after reading 3 older pages.
Remount flows:
/clearthen coming back: the expanded turn returned, and the cleared turns stayed hidden.Switch time: from clicking a previously opened chat to its text showing, over 30 switches between 10 chats with long transcripts. On main the chat is already loaded; here it reloads.
In run 1, switches 14 to 20 took 156 to 259 ms while the machine was busy; the other switches took 67 to 124 ms. An earlier run gave 72 / 86 ms here and 46 / 66 ms on main.
Reading position: after a keyboard scroll, it came back exactly, including inside one long reply.
Unit tests cover the logic where a silent regression would cost the most:
/clear's hold and the rewind guard.Each test fails with its fix reverted.
Performance
Renderer memory at 150 visited chats drops from 2,710 MB to 650 MB (76% less). The trade is that each switch back to a chat now reloads it: about 73 ms median against about 45 ms on main, with p95 84 to 100 ms on a quiet machine and 243 ms in one run on a busy one (Testing above). A chat that was scrolled up reads up to 3 older pages (600 rows) to get back to where the reader was; past that it opens at the end. Nothing new runs while idle, and no work grows with the number of tabs or workspaces on a keystroke, store update or switch.
Risk
The riskiest part is a chat coming back after release: if some piece of view state was missed, a user would see it reset (a section collapsed again, or the reading position back at the end). Drafts, running turns, approvals and questions belong to the session or are kept per tab, so no work or text is lost. Nothing is saved to disk; settings, SSH servers and paired phones are unaffected. Back out with a plain revert.
Every guard a chat view held for a send, request or action now lives with the chat tab. A chat released mid-request comes back still waiting on it and can't send it twice. Each guard belongs to the chat tab's lifetime and to the conversation it shows: a request that settles after its tab closed, or after the tab switched to another chat, changes nothing. A guard is dropped when its request settles, and they all end when the tab closes:
/compact,/clear's hold on sends until the new conversation shows, fork and rewind (each held per conversation, so a late reply never blocks the chat that replaced it), and Continue after an interruption.Left in the view on purpose:
Coming back to a chat you left far up its history reads at most 3 older pages (600 rows) to get back to where you were. Past that, the chat opens at the end instead of replaying the history page by page on every switch.
Level: Medium
AI Disclosure
Review
Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)