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
Delete Orca chats when their workspace is deleted, and cap saved tool output at 64 KiB - #51700
Orca's chat database grows by about 1 GB a day, and most of it is chats from workspaces that were already deleted. Now deleting a workspace deletes its Orca chats too: this is on for new installs, existing users can turn it on in Settings, and Claude Code / Codex transcripts stay a separate opt-in. Separately, a finished tool call keeps at most 64 KiB of its output in the saved chat, its start and its end.
Files
Added
Deleted
Net
Test
10
$\color{#1a7f37}{\Huge{\mathbf{+}}}$493
$\color{#cf222e}{\Huge{\mathbf{−}}}$12
$\color{#1a7f37}{\Huge{\mathbf{+}}}$481
Prod
63
$\color{#1a7f37}{\Huge{\mathbf{+}}}$1337
$\color{#cf222e}{\Huge{\mathbf{−}}}$251
$\color{#1a7f37}{\Huge{\mathbf{+}}}$1086
What Changed
New setting: "Delete Orca chats when a workspace is deleted" (Settings > Agents, deleteOrcaChatsWithWorkspace).
New profiles (no saved Orca data at first load, or a new secondary profile) start with it on.
Existing profiles start off. If a profile already had the old combined switch on, it keeps both parts on.
Turning it on asks first. The next cleanup run (about 10 s later, then at startup and every 6 h) also deletes Orca chats from workspaces deleted before today.
Claude Code and Codex transcripts get their own switch. It is "Delete Claude Code and Codex history when a workspace is deleted" (deleteAgentTranscriptsWithWorkspace), off by default, and behaves as before when on. Orca never deletes another tool's files unless the user asks.
Older builds and hosts stay safe. The old combined key (deleteChatHistoryWithWorkspace) is kept true only while both switches are on, because older builds read it. A downgrade or an older paired host therefore never deletes what one switch keeps. A write from an older client sets both parts.
A new desktop paired with an older host shows that host's combined switch, so it can still be turned off.
Only a proven deletion counts. The existing sweep rules are unchanged:
The workspace folder must be gone, and the folder must not be listed by any project.
The chat must be local (not SSH or WSL), at rest, not open, and idle for an hour.
A chat in a workspace that is only hidden, or on an unreachable host, is never touched.
The deleted chats' rows go in the background. They are removed on the journal's worker thread in bounded pages (at most 64 rows, 1 MB or 8 ms per page, 10% duty cycle). Freed pages are given back with incremental vacuum in steps of up to 16 pages and about 4 ms, never a full VACUUM.
A cleanup never copies in a chat an older Orca saved. It waits until background conversion has copied it, so the cleanup never waits on running agents and never writes while disk is low.
Tool output cap. When a finished tool call is saved, an output over 64 KiB keeps its first and last ~32 KiB with a marker between, and the row shows "Showing 64 KB of N".
The middle is gone for good, including from Show full output, right after the call ends. A running call already showed only a 16 KiB preview.
A row an earlier build already saved whole is never cut later, so imported history and the old-journal retirement check are unaffected.
Facts read from the middle (a git push in a long command) are read before the cut.
Codex history catch-up holds the saved cut copy in place of a matching whole output (same length and digest). So memory stays inside its 16 MiB budget, large outputs no longer make catch-up give up, and an unchanged item is not rewritten.
Telemetry (buckets only, nothing identifying):
deleted_chats_sweep: chats and transcripts deleted and failed per run, and which settings were on.
deleted_chats_discard: chats whose rows were removed, bytes removed, and whether the pass failed.
Why
On a large real profile (copy), 82% of the 25 GB chat database is chats whose workspace was deleted, and tool output is 70% of every bucket. Deleting a workspace is the user saying they're done with it, so its chats go with it: nothing is deleted just because time passed. Capping saved tool output is the usual way to keep bulky output from dominating stored history. Keeping other tools' transcripts opt-in follows the rule that Orca never deletes data outside its own folder by default. An age-based cleanup is a separate, later change.
Linked Issue
Internal item 683.
Visual Proof
New profile, Settings > Agents: Orca chats follow a deleted workspace (on, recommended); Claude Code and Codex transcripts stay a separate opt-in (off).
An existing user turning it on confirms first, since it also deletes chats from workspaces deleted earlier:
Testing
Measured on a copy of a large real profile (26.6 GB database, 11,475 chats in deleted workspaces): see Performance.
Electron QA on Windows at fleet scale (2,186 workspaces, 1,997 chats seeded by the pre-PR build):
Purge: turned on in Settings, the cleanup started 10.2 s later and took 1.36 s: 62 deleted, 0 failed. They were exactly the chats whose folders are gone, including 3 saved by the older build. Live, slept and kept workspaces kept every chat, as did one created through the UI while the cleanup ran.
Main process during the cleanup: p99 event-loop delay 21.3 ms, max 38 ms, peak RSS 446 MB. Switching workspace took 43-156 ms against a 43-128 ms baseline, and opening a chat 24-32 ms.
Codex catch-up: one real turn ran 20 commands of about 1 MiB each. After quitting and relaunching, every row shows "Showing 64.0 KB of 1.00 MB" with its own start and end. Catch-up didn't skip, including on a thread with 63 MB of output, and main RSS rose 43-128 MB on reopen.
Automated tests added/updated, or explained why not below
journal-tool-output-cap.test.ts: the saved output fits 64 KiB, keeps both ends, never splits a character, and an output saved whole stays whole.
existing-profile-default-cohorts.test.ts: on for new and new secondary profiles, off for existing ones, carried over from the old switch.
Performance
Measured on a copy of a large real profile (26.6 GB, 13,086 chats, 11,475 in deleted workspaces), with the PR's own page functions:
Size: the first 5,091 chats freed 6.8 GB of pages. The remaining 6,384 hold 8.5 GB of row text. The file should go from 26.6 GB to about 9 GB once deletion and reclaim finish. The copy ran short of disk before the end, so this last step is extrapolated.
Where the work runs: on the journal's worker thread, at a 10% duty cycle.
Deletion: about 20 MB/s while working, so about 2 MB/s in the background, about 2 hours of uptime for 14.6 GB.
Each freed page costs about one page write (WAL bytes about equal deleted bytes), once.
Reclaim step: 16 pages per step, p50 0.19-2.5 ms. One page at a time cost 0.34 ms p50, so the old budget would have taken more than a day to give back 6.8 GB.
Memory: the harness peaked at 98 MB RSS for the whole process.
Main thread: each chat's deletion still re-checks its gone folder and Orca's workspace list right before it deletes. The workspace list is rebuilt only after a saved change to it, using a counter bumped by every such write. A folder listing is reused only while the folder is unchanged since a read made at least 2 s after its last change, the same rule git uses for timestamps. For 11,000 chats in 700 gone folders with 1,900 workspaces listed, the checks went from 19.9 s to 1.1 s of CPU.
Steady state: the sweep runs at startup, on a settings change and every 6 hours. Chats it skips because they aren't copied yet are retried only after conversion copies them, at least 10 min apart: at most 6 retries an hour at about 200 ms of main-thread CPU each, and none while waiting. The cap adds one bounded size check per finished tool write, and output rows get smaller. No new timers or idle wakeups.
Risk
Level: Medium. The riskiest part is deleting chats. Deletion only follows the existing proven-gone checks, it is on by default only for new profiles, and existing users opt in through a confirm dialog. A revert stops future deletions but does not bring back deleted chats; a saved tool output over 64 KiB keeps only its start and end.
Known limits, filed as follow-ups:
STA-19547: if an older build toggles its combined switch on and then off, that leaves no trace after re-upgrading.
A chat an older Orca saved is deleted only after background conversion has copied it in. Until then a sweep counts it as skipped, and only those chats are retried, once conversion has copied them and gone quiet for 30 s. There is no timer while they wait.
STA-19901: a chat that crashed mid-turn keeps a saved open turn, so cleanup never deletes it. This is inherited, and it errs safe: the chat is kept.
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
Cross-platform: no platform-specific code.
Remote: SSH and WSL chats are never swept; the setting is host-owned, and an older host shows "Update Orca".
Mobile: no change.
Folder workspaces: not swept, unchanged.
Checklist
This PR is small and focused
I explained what changed and why
I stated the risk
Before/after screenshots or videos attached for UI changes
Self-reviewed for correctness, security, and performance
Cross-platform, SSH/remote, and path/shortcut impact considered
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
Workspace history deletion now uses separate settings for Orca chats and Claude Code/Codex transcripts. Cleanup returns separate results, defers chats with pending copy state, and reports bucketed telemetry. Journal maintenance reports deleted bytes and discard completion. The journal also caps saved completed tool-call output at 64 KiB, while related pending actions and Codex history accounting handle capped output.
Merge Risk: Low · previous review 8fe38
This change splits workspace-deletion cleanup into separate Orca-chat and CLI-transcript settings and caps saved tool output at 64 KiB. Three smaller issues remain open: a full settings write can silently turn off Orca-chat cleanup, deleted-byte telemetry can be understated after a failure, and Codex restore memory accounting may undercount large truncated outputs. Merging is reasonable with owner awareness, preferably after the restore-budget accounting is checked.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the two main changes: deleting Orca chats when their workspace is deleted, and capping saved tool output at 64 KiB. Both match the changeset. The title is long and joins two unrelated …
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 follows the template and covers most required sections: ELI5, What Changed, Why, Linked Issue, Visual Proof, Testing, Performance, Risk, and Checklist. It explains the new Orca-chat an…
Full details: Title check
Explanation
The title names the two main changes: deleting Orca chats when their workspace is deleted, and capping saved tool output at 64 KiB. Both match the changeset. The title is long and joins two unrelated changes with a comma, but it is specific and accurate.
Full details: Description check
Explanation
The description follows the template and covers most required sections: ELI5, What Changed, Why, Linked Issue, Visual Proof, Testing, Performance, Risk, and Checklist. It explains the new Orca-chat and transcript settings, the 64 KiB tool-output cap, the migration and compatibility behavior, and the risk. Gaps: the Linked Issue is an internal item ('Internal item 683') rather than a linked GitHub issue, and the template expects a 'Fixes #' reference. The Risk level is given, but the AI Disclosure section is blank (it applies only to non-team contributors). The 'Before' visual for the UI change is missing, and the 'Visual Proof' section shows only AFTER-state screenshots, while the template asks for a BEFORE and AFTER. The 'Ensure no issues in' Notes list is replaced by specific notes, which is acceptable. The 'I manually tested these changes locally' box is not checked, though Electron QA is described.
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; 5 remain after this review.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.
This PR splits workspace chat deletion into separate Orca and transcript settings, deletes forgotten chats' rows in background pages, and caps newly saved finished tool output at 64 KiB.
Workspace cleanup keeps Orca chats and other tools’ transcripts on separate switches.
Finished tool calls save at most 64 KiB of output.
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
Orca's chat database grows by about 1 GB a day, and most of it is chats from workspaces that were already deleted. Now deleting a workspace deletes its Orca chats too: this is on for new installs, existing users can turn it on in Settings, and Claude Code / Codex transcripts stay a separate opt-in. Separately, a finished tool call keeps at most 64 KiB of its output in the saved chat, its start and its end.
What Changed
deleteOrcaChatsWithWorkspace).deleteAgentTranscriptsWithWorkspace), off by default, and behaves as before when on. Orca never deletes another tool's files unless the user asks.deleteChatHistoryWithWorkspace) is kept true only while both switches are on, because older builds read it. A downgrade or an older paired host therefore never deletes what one switch keeps. A write from an older client sets both parts.VACUUM.git pushin a long command) are read before the cut.deleted_chats_sweep: chats and transcripts deleted and failed per run, and which settings were on.deleted_chats_discard: chats whose rows were removed, bytes removed, and whether the pass failed.Why
On a large real profile (copy), 82% of the 25 GB chat database is chats whose workspace was deleted, and tool output is 70% of every bucket. Deleting a workspace is the user saying they're done with it, so its chats go with it: nothing is deleted just because time passed. Capping saved tool output is the usual way to keep bulky output from dominating stored history. Keeping other tools' transcripts opt-in follows the rule that Orca never deletes data outside its own folder by default. An age-based cleanup is a separate, later change.
Linked Issue
Internal item 683.
Visual Proof
New profile, Settings > Agents: Orca chats follow a deleted workspace (on, recommended); Claude Code and Codex transcripts stay a separate opt-in (off).
An existing user turning it on confirms first, since it also deletes chats from workspaces deleted earlier:
Testing
journal-tool-output-cap.test.ts: the saved output fits 64 KiB, keeps both ends, never splits a character, and an output saved whole stays whole.existing-profile-default-cohorts.test.ts: on for new and new secondary profiles, off for existing ones, carried over from the old switch.Performance
Measured on a copy of a large real profile (26.6 GB, 13,086 chats, 11,475 in deleted workspaces), with the PR's own page functions:
Steady state: the sweep runs at startup, on a settings change and every 6 hours. Chats it skips because they aren't copied yet are retried only after conversion copies them, at least 10 min apart: at most 6 retries an hour at about 200 ms of main-thread CPU each, and none while waiting. The cap adds one bounded size check per finished tool write, and output rows get smaller. No new timers or idle wakeups.
Risk
Level: Medium. The riskiest part is deleting chats. Deletion only follows the existing proven-gone checks, it is on by default only for new profiles, and existing users opt in through a confirm dialog. A revert stops future deletions but does not bring back deleted chats; a saved tool output over 64 KiB keeps only its start and end.
Known limits, filed as follow-ups:
Review
Agent skill upstream boundary
Notes
Checklist
pnpm check:changedpasses