Skip to content

Delete Orca chats when their workspace is deleted, and cap saved tool output at 64 KiB - #51700

Merged
brennanb2025 merged 25 commits into
mainfrom
brennanb2025/chat-history-retention-pruning
Nov 30, 2026
Merged

brennanb2025 merged 25 commits into
mainfrom
brennanb2025/chat-history-retention-pruning

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

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.

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).

Settings > Agents with both switches

An existing user turning it on confirms first, since it also deletes chats from workspaces deleted earlier:

Turn-on confirmation

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
  • pnpm check:changed passes

@brennanb2025
brennanb2025 marked this pull request as ready for review November 28, 2026 09:58
@coderabbitai

coderabbitai Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Note

Reviews paused

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.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • Resume reviews
  • Trigger review

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: Passed 4

Check name Status Explanation
Title check Passed 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 Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed 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.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9ff64262-c3a7-4082-8d82-f783f64d5338
Commits

Reviewing files that changed from the base of the PR and between c55fac3 and 8fe38bd.

Files selected for processing: 7

  • src/main/native-chat/agent-session-journal/journal-chat-copy-state.test.ts
  • src/main/native-chat/agent-session-journal/journal-sql-database-read.ts
  • src/main/runtime/agent-session/records/agent-session-record-forgets.ts
  • src/main/telemetry/deleted-chats-telemetry.ts
  • src/main/workspaces/cleanup/chat-history/deleted-workspace-native-chats.ts
  • src/main/workspaces/cleanup/chat-history/gone-workspace-folder-groups.ts
  • src/shared/telemetry/schemas/telemetry-deleted-chats-event-schemas.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c010ff4b-a14b-48a7-abee-78781c33db12
Commits

Reviewing files that changed from the base of the PR and between 95f6bb9 and 549c2d2.

Files ignored due to path filters: 1

  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
Files selected for processing: 36

  • docs/site/content/docs/cli/reference.mdx
  • src/main/codex/history/journal-views/codex-history-workspace.ts
  • src/main/ipc/telemetry.ts
  • src/main/native-chat/agent-session-journal/database/journal-sql-database.ts
  • src/main/native-chat/agent-session-journal/journal-domain-current-item.ts
  • src/main/native-chat/agent-session-journal/journal-domain-import-discard.ts
  • src/main/native-chat/agent-session-journal/journal-domain-item.ts
  • src/main/native-chat/agent-session-journal/journal-domain-lifecycle-item.ts
  • src/main/native-chat/agent-session-journal/journal-domain-maintenance.ts
  • src/main/native-chat/agent-session-journal/journal-forgotten-chats.ts
  • src/main/native-chat/agent-session-journal/journal-sql-background-maintenance.ts
  • src/main/native-chat/agent-session-journal/journal-tool-output-cap.test.ts
  • src/main/native-chat/agent-session-journal/journal-tool-output-cap.ts
  • src/main/orca-profiles/storage/new-profile-state.ts
  • src/main/persistence/applying-settings/settings-update.ts
  • src/main/persistence/existing-profile-default-cohorts.test.ts
  • src/main/persistence/loading-store/profile-loading/loaded-cohort-migrations.ts
  • src/main/persistence/loading-store/profile-loading/loaded-state-parsing.ts
  • src/main/runtime/agent-session/records/agent-session-record-forgets.ts
  • src/main/runtime/construction/runtime-store-contract.ts
  • src/main/telemetry/deleted-chats-telemetry.ts
  • src/main/workspaces/cleanup/chat-history/chat-history-sweep-schedule.ts
  • src/main/workspaces/cleanup/chat-history/deleted-workspace-chat-history.ts
  • src/main/workspaces/cleanup/chat-history/deleted-workspace-codex-history.test.ts
  • src/main/workspaces/cleanup/workspace-cleanup-runner.ts
  • src/renderer/src/components/settings/agents/DeleteAgentHistoryWithWorkspaceSetting.fixture.tsx
  • src/renderer/src/components/settings/agents/agents-search.ts
  • src/renderer/src/components/settings/agents/behavior/DeleteAgentHistoryWithWorkspaceSetting.tsx
  • src/renderer/src/components/settings/agents/behavior/delete-agent-history-search.ts
  • src/renderer/src/i18n/locales/en.json
  • src/shared/settings/global-settings-base.ts
  • src/shared/settings/global-settings-types.ts
  • src/shared/settings/host-owned-settings.ts
  • src/shared/settings/workspace-chat-history-settings.ts
  • src/shared/telemetry/schemas/telemetry-deleted-chats-event-schemas.ts
  • src/shared/telemetry/telemetry-event-registry.ts
Files with no reviewable changes: 1

  • src/shared/settings/global-settings-types.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.

…builds' switch changes; match cut outputs in Codex catch-up

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a0b67340-d7f7-4493-be77-13371d8b817d
Commits

Reviewing files that changed from the base of the PR and between 3cf63a9 and 898b793.

Files selected for processing: 4

  • src/main/native-chat/agent-session-journal/journal-sql-conversions.ts
  • src/main/runtime/agent-session/records/agent-session-record-forgets.ts
  • src/main/workspaces/cleanup/chat-history/gone-workspace-folder-groups.test.ts
  • src/main/workspaces/cleanup/chat-history/gone-workspace-folder-groups.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.

@greptile-apps

greptile-apps Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

Confidence Score: 5/5 · The latest changes appear safe to merge; the earlier translation issue remains non-blocking.RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The latest changes appear safe to merge; the earlier translation issue remains non-blocking.

Findings

  1. P2 Deletion warnings lose their translations ▶

Summary

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.

Reviews (9) · Last reviewed commit: "Delete a tabless chat without loading th..." · Reviewed by Greptile

Comment thread src/renderer/src/i18n/locales/en.json Resolved
…tory-retention-pruning

# Conflicts:
#	src/main/workspaces/cleanup/chat-history/deleted-workspace-native-chats.ts
…ffline writes; hold a failed MCP call's cut copy in Codex catch-up
…ts a cleanup left for later, backing off from 10 min to 6 h
… on a timer; keep a saved cut output through Claude catch-up; push skipped ids without copying
@brennanb2025

Copy link
Copy Markdown
Contributor Author

Perf scan (fresh reviewer, head 6e5dea1): clean, no P0/P1.

  • Purge of 10k of 30k chats in deleted folders at 1,900 workspaces: 4.4 s CPU, longest main-thread block 28.8 ms, versus 21.8 s and 184.5 ms on base.
  • Sweep with nothing to delete: 412 ms CPU, longest block 3.4 ms, versus 703 ms and 15.3 ms on base.
  • Vacuum step on the journal worker: typical 0.1 ms, worst 5 ms, inside the existing 10% duty cycle.
  • New tab index: 0.46 ms to create at 2k tabs, 0.3 µs per lookup.
  • Retries of chats waiting to be copied: at most 6 an hour, about 0.33 ms/s on main at fleet size, none while nothing waits.
  • No new idle wakeups on main, renderer or daemon.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review loop done on 6e5dea1.

  • Claude review: clean after one fix (catch-up revised unchanged rows of some tools).
  • Codex regression audits: SAFE on every change since the last full round.
  • Perf scan: clean (comment above).
  • Windows QA at 2,186 workspaces: purge and Codex catch-up flows pass (on cb49e44).
  • Approach checked against reference designs.
  • Known and ticketed: STA-19547, STA-19901.

@brennanb2025
brennanb2025 merged commit b77b0b8 into main Nov 30, 2026
70 of 71 checks passed
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