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
feat(settings): show how much space Codex chat history takes - #43894
Codex keeps a log file for every chat, and on busy machines these logs quietly grow to tens of gigabytes (#16776 saw 11 GB). Orca can already delete the ones from deleted workspaces ("Delete agent history when a workspace is deleted"), but that setting is off by default and nothing told you how much space was at stake. The setting's row now shows a small "Codex history: 49.8 GB" badge: the space Codex's own chat history takes on that computer, so you can decide whether to turn it on.
Files
Added
Deleted
Net
Test
3
$\color{#1a7f37}{\Huge{\mathbf{+}}}$228
0
$\color{#1a7f37}{\Huge{\mathbf{+}}}$228
Prod
23
$\color{#1a7f37}{\Huge{\mathbf{+}}}$848
$\color{#cf222e}{\Huge{\mathbf{−}}}$29
$\color{#1a7f37}{\Huge{\mathbf{+}}}$819
What Changed
Settings › Agents: next to the "Recommended" badge of "Delete agent history when a workspace is deleted", a muted badge reads "Codex history: {size}" ("{size}+" when the measurement stops early). Its tooltip, also reachable by keyboard, says this is the space Codex uses for its own chat history on that host, including chats from workspaces you still have, and that the setting removes only chats from workspaces that no longer exist. Nothing is deleted and no setting or default changes.
It shows the whole Codex total rather than what the setting would free. That number needs each rollout's working folder from inside the file and a second copy of the deletion's rules, so the honest total plus the tooltip was chosen instead (light design council, unanimous).
How it's measured: a new workspaceCleanup.codexHistoryDiskUsage runtime method runs on the host that owns the workspaces (local or remote server). It lists the same Codex homes the cleanup deletes from. Main lists the folders asynchronously, and the account ownership check runs in a dedicated worker thread, which then walks each home's sessions, archived_sessions, .orca-set-aside-rollouts and *.orca-profile-merge folders.
It reads directory entries and file metadata only. It never opens, moves or changes a log.
Links inside history are never followed, and a folder that stops resolving to itself mid-walk is dropped.
A rollout hard-linked into several homes counts once (by device and inode). Size is the allocated blocks, which is what deleting would give back (APFS compresses many rollouts). Windows has no block count, so it uses file length.
Bounds: the walk stops at 4M entries or 60 s, counted from when the worker starts it, and then reports a lower bound. One walk runs at a time and its result is reused for 5 minutes. An Orca chat-history deletion stops the running walk and clears the cached result. Each read names itself, and the walk stops once no reader waits: a Settings view that closes, hides or switches host releases its read, and so does a window whose connection ends (reload, crash or disconnect). A new walk waits up to 10 s for a stopped walk's worker to exit, and fails fast after that if the worker is stuck on a hung drive. The row reads only while it is visible (settings search shows it and the window is shown), and again once after each cleanup run.
Packaging: the worker ships in the desktop build and in the remote server bundle, and it is covered by the worker-entry build guards.
Why
Codex itself never deletes rollouts on its own. It offers user-driven archive and delete, and its app-server measures its home with a metadata-only scan. The common pattern for an app hosting Codex is to read these files and leave deletion to an explicit user choice. The opt-in delete already shipped in #43000. What was missing was visibility.
On one heavy real profile, 87% of the 37.4 GB of unique Codex rollouts came from deleted workspaces, which that setting already covers. Only 0.1 GB was older than 30 days and from a workspace that still exists. So an age-based delete or automatic retention would add a new destructive path for almost no gain.
This carries forward community PR #16990 by @maxmilian, who agreed to a credited redesign. He is credited as co-author.
Linked Issue
Tracked in #16776. The cleanup itself shipped in #43000. This adds the size report.
Visual Proof
Before, the row had only the switch, its "Recommended" badge and its description. After:
Light
Dark
Badge
Tooltip (keyboard focus)
(Component fixtures with a mocked 53.5 GB result, shown as 49.8 GB because sizes use 1024-based units like the rest of the page. Taken on a Mac, so the host reads "Local Mac".)
Testing
Real-scale benchmark (read-only, on a heavy macOS profile with the walk taken from this head): 42,567 rollouts, 54.3 GB, complete count, 7.5 s, 111 MB RSS, at a machine load average of about 9–11. It runs in the worker, so nothing is on Electron main.
codex-history-disk-usage-worker-entry.test.ts checks the following on temp Codex homes, with the expected values written by hand:
each rollout is counted once across a hard link and a shared (symlinked) sessions folder;
set-aside, merge-folder and .zst rollouts are counted;
a symlinked log and non-rollout files are skipped;
an unreadable folder or an exhausted budget yields "at least";
off Windows, the result is in whole allocated blocks.
codex-history-disk-usage-reader.test.ts checks that a deletion stops the obsolete walk and later reads get a fresh one, and that a walk survives its first reader leaving and stops when the last one does.
workspace-cleanup-runner-methods.test.ts checks, at the RPC layer, that closing one window's connection keeps a walk another window still waits on, and that closing the last waiting connection stops it.
pnpm check:changed passes on Linux.
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
Risk
Level: Low.
Read-only: the change only reads metadata.
Disk activity: the riskiest part is the disk work while the walk runs. It is bounded by 60 s and 4M entries, runs one at a time, and its result is reused for 5 minutes.
Leftover walk: a walk that is already running when Settings closes runs to its bound and its result is reused. That was a deliberate choice over adding cancellation to the RPC layer.
Older hosts: an older host without the method shows no badge.
WSL: Codex history inside a WSL distro is not counted, the same as the cleanup.
Back out: a plain revert. Nothing is persisted.
Review
Fresh Claude and Codex reviewers ran three passes, each with a perf scan, followed by a three-member council on the final head. The council found no P0 or P1.
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
Security: no writes, no content reads, no link traversal.
Cross-platform: allocated blocks on macOS and Linux, file length on Windows. Junctions and symlinks are skipped.
Remote SSH and remote servers: measured on the owning host. The worker ships in the server bundle.
Mobile: not affected.
Backwards compatibility: new optional RPC. Older hosts show no badge.
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)
The Chat history setting can delete Codex chats from deleted workspaces,
but nothing showed how large that history had grown (#16776 saw 11 GB).
The row now says how much the host's Codex chats use, measured read-only
on a worker thread across every Codex home, counting each hard-linked
rollout once (set-aside copies included) and never reading through links.
Co-authored-by: Max Hsu <[email protected]>
…not on main
The main-blocking helper ratchet flagged the account ownership reads; main now
lists account folders asynchronously and the worker verifies them.
Co-authored-by: Max Hsu <[email protected]>
DONE: PASS — I found no perf regressions. The size walk runs only while Settings > Agents is visible and the row matches search, at most one walk runs per host, it's capped at 4M entries or 60 s, and Electron main does no sync filesystem calls for it.
Perf scan: PR #43894, Codex history disk usage line (head 47210bd)
Range: 3477418ccca..47210bdf065 (23 files, +783/−50). I traced this from the source at head. I ran no tests or benchmarks myself. The benchmark result below is the author's own run.
Findings
No P0 or P1 findings. Each piece of new work is bounded, runs only on a user action, runs off Electron main and stops when it should. The numbers are below.
Population: at most one per window that has Settings open.
The row renders only from renderAgentsSettingsSection with showDeleteAgentHistory set. The Agents dialog (AgentSettingsDialog.tsx:94) doesn't set it, and paired web client windows are excluded (AgentsPane.tsx:75).
SettingsSection returns null for any section that isn't active (SettingsSection.tsx:56-63), so the hook only exists while Agents is the active section.
AppWorkspaceShell.tsx:94 unmounts the whole Settings page when you leave it.
What starts a read: opening the section (mount), a change of host scope, or a workspaceCleanup:runFinished event for the same host.
A read is skipped while settings search hides the row (shown) or the window is parked (windowVisible).
readRevision === revision limits it to one RPC per mount and cleanup revision. A failed read is stored as usage: null for that revision, so it never retries in a loop.
Subscriptions:
useAppStateValue(state => state.settingsSearchQuery) selects a string, compared by equality. That adds one matchesSettingsSearch over this row's single search entry per keystroke, a constant cost.
One window park visibility listener (useSyncExternalStore).
One window event listener for finished cleanup runs, keyed on ownerKey.
Repeat calls: hiding the row or window mid-read, or typing that flips shown before the first answer, sends another RPC. Main joins it to the walk already in flight (reader.read). Cost per flip is one small RPC and no new walk.
Per walk: two async readdir calls on the account roots (a handful of entries each) plus pure path joins. That covers getSystemCodexHomePath, resolveOrcaManagedCodexHomePath, codexHomeSessionsDir and resolveHostCodexSessionSourceHome.
No sync filesystem calls on main. The sync ownership check (ownedCodexAccountHomes: lstatSync, readFileSync, realpathSync, statSync) now runs in the worker (commit e494978).
The size walk also drops configuredAdditionalCodexHomePaths() and its sync account check (commit e02a3e4).
Payload: a request of well under 1 KB (homes, a few accounts, budget) and a 3-field response.
Deletion path (pre-existing pattern, slightly changed):listHostCodexRolloutHomes still runs the sync ownership check on main per deletion.
It now also accepts account folders that are symlinks (isSymbolicLink()), adding one ownership check per relocated account.
The count is the number of accounts (a handful), not history size, so this is constant.
3. Worker walk (codex-history-disk-usage-worker-entry.ts)
Per walk:
each home: one realpathSync, plus an opendirSync listing streamed one entry at a time;
each history folder: one lstatSync, two realpathSync and one opendirSync (folders are dated, roughly 365 per year per home);
each rollout name: one regex test and one lstatSync({bigint:true}).
Reads metadata only. Links are never followed. Hard-linked twins count once, via the seenFiles dev:ino set.
Budgets:
MAX_ENTRIES is 4,000,000. Every step counts, including folders and home entries, and a single huge folder is streamed, so the cap holds inside it too.
WALK_BUDGET_MS is 60 s, measured from when the worker picks the request up.
The queue timeout is 90 s and the renderer RPC timeout is 120 s.
When a budget runs out, the walk returns a lower bound (complete: false) and the row says "at least".
Thread: a dedicated worker. Sync calls there block neither main nor the libuv pool.
Memory:
seenFiles holds one string per unique inode. That's about 42k now and about 420k at 10× (roughly 35 MB), and the 60 s budget stops the walk sooner anyway.
found holds one folder's rollouts at a time, so a flat 400k-file folder is about 30 MB, briefly.
The worker is torn down after 30 s idle.
Author-reported benchmark (macOS, real profile, load average 28–36): 42,387 rollouts, 54.1 GB, complete, 13,364 ms, 108 MB RSS.
4. Cache and abort (codex-history-disk-usage-reader.ts)
Sharing: one module-level reader and queue per host process, so every window and paired client shares one walk in flight and its result for REUSE_MS (5 min).
On deletion:forgetCodexHistoryDiskUsage() runs only when deletedPaths.length > 0. It clears the cached result and aborts the running walk; dispatch's abort calls host.destroy() while the walk is active, which ends the worker.
A burst of deletions therefore leaves at most one live walk, and only if a visible row asks. A deletion alone starts no walk.
Leaving the page doesn't stop the walk. Hiding or unmounting in the renderer leaves the host walk running (60 s at most). Its result is cached and served to the next read within 5 min, so the work isn't wasted.
No per-entity state: the queue and reader are singletons, with no maps keyed by host, worktree or tab.
5. Server bundle and startup
orcad build: gains one child entry point (codexHistoryDiskUsage). The worker imports only node:fs/path/worker_threads, the ownership module, the absence helper and the send ledger.
Main build: gains one worker entry, also listed in config/main-blocking-worker-entries.json.
Eager imports:workspace-cleanup-runner-methods.ts now imports codex-history-disk-usage.ts. Its dependencies (codex-host-rollout-homes via deleted-workspace-chat-history.ts, and the worker queue/spawn modules via workspace-space-scan-worker-client.ts) were already on main's import graph, so this adds one small module and no SDK.
Cost at the reference fleet
Item
Trigger rate
Work per trigger
Thread
Price
Size walk
User opens Settings > Agents (or a cleanup run finishes while it's visible); at most 1 walk per 5 min per host, otherwise reused
~42k rollout lstats plus folder steps; 13.4 s and 108 MB (author run); at 10×, capped at 60 s / 4M entries, then a lower bound
Worker
0 ms on main; disk metadata I/O for up to 60 s per user visit
Main preparation
Same as the walk
2 async readdirs, path joins, request under 1 KB
Main (async)
Under 1 ms
RPC
Per mount and cleanup revision while visible
1 small round trip, also over SSH for a remote host
Renderer, main or remote
Constant; doesn't grow with worktrees, terminals or agents
Search selector
Per settings search keystroke while Agents is mounted
String equality plus one search-entry match
Renderer
Constant
forget() on deletion
Per deletion that removed rollouts
Clears the cache and aborts at most one walk
Main
Constant
Nothing scales with worktrees, terminals, agents, refs or remotes. Cost grows only with Codex history size, and the entry and time caps bound it.
Regression classes the diff touches
Class
Disposition
Hidden or unobserved owners keep working
Disproved. The section unmounts when inactive, the Settings page unmounts when left, and the hook checks window visibility and the search shown gate before starting a read.
Sync fs or SQLite on Electron main
Disproved for the new path. Ownership checks and the walk run in the worker; main does async readdir only. The deletion path's sync check on main predates this PR; the PR adds one check per symlinked account (constant).
Re-reading unchanged input
Disproved. Results are reused for 5 min; a new walk needs a user visit at least 5 min later, or a deletion. Unchanged, the output still needs a stat per rollout (st_blocks grows as files are appended), and it's capped at 60 s / 4M.
Fixed-cadence poll
No matching code. No intervals or self-rescheduling timers; renderer reads come only from mount and finished-run events.
Unbounded fan-out or queues
Disproved. One walk in flight per host process; later callers join it.
Per-entity state outlives the entity
Disproved. Only module singletons; renderer state is local to the hook.
Eager startup imports
Disproved. One small module; its dependencies were already loaded.
Whole map or settings selected
Disproved. The new selector picks a string; the settings prop was already there.
Subprocess per item
No matching code.
Six questions
Unused work paid for before the skip gate? Reviewed. The shown and windowVisible gates run before the RPC, and deletions only clear the cache. Nothing is measured unless a visible row asks.
Ownership multiplying work? Reviewed. There's at most one hook per Settings window, and a single reader and queue per host shares the walk across windows and clients.
Which thread and storage layer pays? Reviewed. The walk and ownership checks run on a dedicated worker with sync calls by design, kept off the libuv pool. Main does only async readdir and messaging. No SQLite involved.
What grows, and does the next attempt advance? Reviewed. Cost grows with history size and is capped at 4M entries / 60 s.
At 10× the fleet, each walk hits the cap and the next one starts over from the beginning.
That's acceptable here: the output is defined as a lower bound, no accepted data is lost or left behind, and walks happen only on user visits at least 5 min apart.
What does the execution host change? Partly reviewed. WSL UNC homes are skipped, and Windows uses size because it reports no allocated blocks. Remote hosts make one RPC per read.
Not measured: walk time on Windows NTFS, network filesystems or SSH hosts. Each is still bounded by the 60 s budget.
Does obsolete work stop and release its budget? Reviewed.
A deletion aborts the walk and ends the worker.
A renderer hide or unmount leaves the host walk running (60 s at most), and its result is reused.
The worker is torn down after 30 s idle, and the queue timeout is 90 s.
Reader, queue and abort: worker-thread-request-queue.ts
Homes and ownership: home listing, ownership module
Worker walk
Build entries: orcad and main
Hosts: local macOS (by source). Windows, Linux and SSH by source only.
Not perf: for you to pass on
Size line can vanish after a deletion. The queue uses awaitRetirement: true. If a deletion aborts a running walk and the renderer's follow-up read arrives before the terminated worker has exited, that read fails as unavailable. The hook stores usage: null and doesn't retry until the next cleanup run, so the size line disappears until then. The window is a few milliseconds.
Relocated account homes now get deleted too.listHostCodexRolloutHomes now includes account folders that are symlinks, so the existing deletion path removes history from relocated account homes as well. That's a behaviour change in deletion beyond the new size line.
Residual gaps
No walk time measured on Windows, network filesystems or remote SSH hosts. Each is bounded at 60 s per walk, and walks happen at most once per 5 min per host.
The benchmark is the author's, not reproduced here.
DONE: PASS. The new history-size walk only runs when someone looks at it, runs on its own worker thread, and has hard limits. At most one walk runs at a time, and each result is reused for 5 minutes. The PR adds no sync file reads on Electron main, no timers and no background polling. I found no perf regression.
Scope:git diff 3477418ccca..4c479b19e6c, 24 files. Code citations are at the head commit.
Findings
None at P0 or P1.
Pre-existing, not caused by this PR and not blocking:
What happens:deleteRollout lists every home again for each rollout it deletes (src/main/codex/history/cleanup/codex-rollout-permanent-delete.ts:196). That listing runs a sync ownership check on Electron main for each account (codex-host-rollout-homes.ts:46-65). Each check is a realpath, an lstat and a marker read.
Cost: about R × A checks per deletion, where R is rollouts deleted and A is account folders. For example, 50 rollouts × 5 accounts is about 250 checks, roughly 10–25 ms spread over awaits on main.
What this PR changes: account folders that are symlinks (relocated accounts) are now checked too, so A grows by that count, usually 0–2. That is required: otherwise links in relocated homes would be missed.
Overall: this PR lowers the main-thread blocking count for this file, because the disk-usage path now runs its ownership checks in the worker (the main-blocking baseline goes from 3 to 2).
What would prove a fix: a count of ownership checks for one deletion at R = 10 and R = 100.
each settings-search keystroke while the Agents section is mounted
1 row (Settings is unmounted when you leave it, AppWorkspaceShell.tsx:94; the Agents section mounts lazily, settings-load-performance.ts:1; the paired-web-client window excludes the row, AgentsPane.tsx:75)
row shown, window visible, and this revision not yet read
1 owner
at most 1 RPC per revision. A failure stores null for that revision, so nothing retries. Re-showing the row mid-read can send another RPC, which main joins to the walk already running. No timers.
renderer / IPC; one round trip on SSH
Main preparation: listHostCodexRolloutHomeSources (codex-host-rollout-homes.ts:89-105)
each RPC that misses the reuse cache
4 fixed homes plus 2 async readdir of the account roots (A entries)
path joins are pure; getSystemCodexHomePath, resolveOrcaManagedCodexHomePath and codexHomeSessionsDir do no I/O; no sync fs; request clone is under a few KB
Electron main, under 1 ms; readdir uses the libuv pool
Worker: ownership loop (worker-entry.ts:208-222)
each walk
A account folders
sync realpath/lstat/marker reads, bounded by A (tens at most)
worker
Worker walk (measureCodexHistoryDiskUsage, worker-entry.ts:153-198)
each walk
every history folder in every home; every rollout-*.jsonl[.zst] name
1 lstat per rollout name; 1 lstat + 2 realpath per folder; checks Date.now and the entry cap at every step. Budget is MAX_ENTRIES 4M and WALK_BUDGET_MS 60 s; past either it reports a lower bound. The worker is killed after 90 s (WORKER_TIMEOUT_MS).
worker thread; sync calls do not use the libuv pool
Cache and abort (codex-history-disk-usage-reader.ts)
every read; forget() after a deletion that removed rollouts
1 module singleton
one walk at a time (inFlight); result reused for 5 min (REUSE_MS). An aborted walk never fills the cache. forget aborts the running walk, which ends the worker via host.destroy() (worker-thread-request-queue.ts:107-113). A burst of deletions aborts at most one walk.
main
Worker lifetime
the queue is created on first read (getQueue)
1 worker
shut down after 30 s idle; maxConsecutiveDeaths 3; awaitRetirement blocks a new spawn until the old worker exits
—
Server bundle
build
1 new child entry (orcad-entry-build.mjs:39)
the worker file imports only fs/path, the ownership module, shared errors and the send ledger; it is not on the startup graph. Size is unmeasured but small.
—
Priced at the reference fleet
Author's benchmark at 47210bd (macOS, load average about 28–36, not reproduced by me):
42,387 rollouts, 54.1 GB, complete: true
13,364 ms on the worker, 108 MB RSS
The walk loop is unchanged since then. Only the ownership loop moved into the worker, which adds work bounded by A.
At the reference fleet (tens of thousands of transcripts, tens of GB): the benchmark matches that size.
One walk is about 13 s on one worker thread.
Electron main: 0 sync fs. Renderer: 0 ms at idle.
How often: at most once per 5 min per host, and only while Settings → Agents is visible in a visible window. A cleanup run that deleted rollouts can add one more, again only while visible.
At 10× (about 420k rollouts, hard-linked into several homes, so 1–2M names):
The walk hits the 60 s limit and shows "at least {size}".
The worker thread and disk metadata I/O are busy for at most 60 s per walk.
Memory:
seenFiles holds one key per unique inode visited within the limits.
At the benchmark's rate (about 3k rollouts/s), 60 s is at most about 200k keys, roughly 20 MB.
The 4M cap is the theoretical ceiling, about 400 MB, but the 60 s deadline stops it far earlier on any measured rate.
All of it is freed when the walk returns. The worker shuts down after 30 s idle.
Per keystroke: constant work on one row; no work over the fleet.
Regression classes the diff touches
Class
Disposition
Fixed-cadence poll or loop that never settles
Not present. There is no interval or self-rescheduling timer. A failed read stores null per revision and never retries (use-codex-history-disk-usage.ts:68-72).
Hidden or unobserved owners keep working
Present but bounded and disproved. RPCs are gated on shown && windowVisible, and Settings unmounts when left. A walk started before Settings closes runs to its ≤60 s limit and its result is cached for the next visit within 5 min. That is one bounded, reused unit of work, not repeated.
Sync fs on Electron main
Present and disproved for the new path. Main-side prep is async readdir plus pure path code; the ownership checks and walk run in the worker. The baseline drops from 3 to 2. The deleter's per-rollout ownership loop is pre-existing (above).
Re-reading unchanged input
Present and disproved within the window. The reuse cache returns the last result for 5 min; the last assertion in codex-history-disk-usage-reader.test.ts:42 shows no new walk. After 5 min a fresh walk runs; that pace is set by when the user opens the page, and the walk is the measurement itself.
Unbounded fan-out or queues
Disproved. The reader allows one walk at a time; concurrent readers and other windows share the same promise; the queue has one worker.
Update published when nothing changed
Disproved. A finished cleanup run that deleted nothing causes one RPC, served from the cache, and one re-render. Constant per run.
Per-entity state outlives the entity
Disproved. Hook state holds one ownerKey; listeners unsubscribe on unmount; main holds constant module singletons and the worker shuts down when idle.
Whole keyed map or settings selected
Disproved. The selector returns a primitive string.
Eager startup imports
Disproved. The runner-methods import pulls in only the reader and queue code; the worker loads lazily on first read; no SDK is added.
The six questions
Is unused work paid for before the skip gate? Reviewed. The gate (row shown, window visible, revision unread) is checked before the RPC, and the reuse cache is checked before any home listing. Nothing is built for a hidden row.
Does ownership multiply or recreate work? Reviewed. There is one row, and it is not per-worktree or per-host-row. Main deduplicates across windows and repeated reads. Switching host reads that host once, served from its own cache.
Which thread pays? Reviewed. Main pays only async readdir and path work. All sync fs runs in the dedicated worker. A sync walk on a worker thread does not use the libuv pool.
What grows, and does the next attempt advance? Reviewed. Walk work grows with rollout names × homes, capped by 4M entries and 60 s, after which the line reads "at least". The walk keeps no cursor, so a walk that hits the cap repeats the same prefix next time. Acceptable: the trigger is the user and the result is only a lower-bound label.
What does the execution host change? Partly assessed. macOS has the author's benchmark only. Windows uses stats.size and NTFS lstat is slower, so the 60 s limit applies sooner (not measured). WSL homes are deliberately excluded, so no distro boot. On SSH hosts the walk runs in the remote orcad worker and the RPC payload is small. On a hung network mount, a native call cannot be interrupted, so the worker cannot be terminated. The 90 s timeout settles the request, but awaitRetirement refuses this feature's later reads until that worker exits. Only this feature is affected, with no cost to main.
Does obsolete work stop and release its budget? Reviewed. forget aborts the running walk and terminates the worker. A late result from an aborted walk never fills the cache (reader.ts:30-33). The timeout kills the worker; idle teardown releases it. Unmounting the renderer does not cancel the main walk, which is bounded and its result reused (above).
Evidence types and remaining gaps
Source-proven: every count and bound above.
Tests inspected but not run: the reader tests (abort, fresh walk, cache reuse) and the worker-entry tests (dedupe across homes, never following a link, lower bound when over budget, allocated blocks).
Author-reported: the 13.4 s / 42k-rollout benchmark.
Unmeasured: walk speed on Windows/NTFS and on SSH or remote orcad hosts, and the size added to the server bundle.
Not perf, unverified: if a deletion aborts a walk the row is waiting on, or the next read lands while the old worker is still shutting down ("previous worker still exiting"), the size line is hidden until the next revision or the next visit to the page.
Problem. Codex keeps a log for every chat. On heavy machines they reach tens of GB (#16776 saw 11 GB; one profile measured here has 54 GB). #43000 added an opt-in "Delete agent history when a workspace is deleted", but it is off by default and nothing showed how much space was at stake.
What users see. Settings › Agents: under that switch, "All Codex chat history on {host} takes {size}." It reads "takes at least {size}" when the walk stops early. Nothing is deleted and no default changes. Scope was confirmed by a three-member council: option 1, the size line. An "older than N days" delete would have freed 0.1 GB of the 37.4 GB on the measured profile, and automatic retention is not what Codex itself does.
How it works. A new workspaceCleanup.codexHistoryDiskUsage RPC runs on the host that owns the workspaces. Main lists Codex homes and account folders asynchronously. A worker thread then checks account ownership and walks sessions, archived_sessions, .orca-set-aside-rollouts and *.orca-profile-merge:
It reads metadata only, follows no links inside history, and drops a folder whose real path changes mid-walk.
Hard-linked rollouts count once, by allocated blocks (file length on Windows).
The walk is capped at 4M entries or 60 s, counted from when the worker starts it.
One walk runs at a time and is reused for 5 minutes. An Orca deletion aborts the running walk.
The renderer reads only while the row is visible (search and window) and once per finished cleanup run.
Fixed during review (three review passes plus a council, then reviews of the moved code):
the deadline had started at queue time, which starved a post-deletion walk;
async per-file stats were about 50× slower, so the walk went back to sync calls in the worker entry;
the budget didn't cover the home listing or empty folders, so it does now;
a symlink swap mid-walk could be counted, and now isn't;
merge folders were uncounted;
an unreadable folder was reported as a complete total;
the worker was missing from the server bundle;
a search-hidden row still triggered a scan;
sync account-ownership checks on main (one through session discovery's callback) moved to the worker;
relocated account folders were missing;
duplicate home spellings were walked twice.
The cleanup's delete list is unchanged except that an Orca-owned account reached through a symlinked folder is now included. Ownership by canonical path is the gate, and reviewers verified it.
Deferred / known limits.
Leftover walk: a walk that is already running when Settings closes runs to its bound, and its result is reused (council: unanimous).
WSL: history inside a WSL distro is not counted, the same as the deleter.
Windows: sizes are file length.
Staleness: after changing the Codex history source or adding an account, the old number can show for up to 5 minutes.
Pre-existing, not from this PR: the cleanup re-lists homes, including sync ownership checks on main, once per rollout it deletes (R × A checks per run). Separate follow-up.
Packaging: no smoke test of the packaged app. The worker is registered in the desktop and server bundles and in the worker-entry guards, and CI's builds cover packaging.
Verified.
check:changed on Linux: 41/41 at 4c479b19e6cf6939fa057a9892f8737b019d37b1.
Real-profile benchmark: Benchmark: head=47210bdf065a47190aaf8c476b89b11db0c4a4f5 gate=PASS (walk unchanged since; later commits only moved the ownership check). 42,387 rollouts, 54.1 GB, complete, 13.4 s, 108 MB RSS in the worker. Read-only, on macOS at load ≈28.
Unit tests: the walk on temp homes (hard links, shared folder, set-aside, merge folder, .zst, symlinked log, unreadable folder, budget, allocated blocks), plus the reader's deletion abort and fresh read.
Screenshots are in the PR body (component fixture).
QA by tests, no app run: the change is a settings line backed by an RPC and a worker. Tests drive the walk end to end, and the layout is shown by the fixture.
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 change adds a worker that measures Codex rollout disk usage across discovered history homes. The main process exposes measurements through workspace RPC methods and reuses cached results until they expire or are forgotten. The settings interface requests usage when its row and window are visible, then displays the size and whether the measurement is complete. Worker scanning, reader invalidation, and settings display changes include tests or fixtures.
Merge Risk: Low · up to b23e9
The new Codex history size line is bounded and read-only. Two minor open points remain: a size could briefly reflect a previously selected history source, and relocated account homes may be left out of the total. Neither is likely to cause serious harm.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the main change: a Settings > Agents line that shows how much disk space Codex chat history uses. The changeset adds a host-level disk-usage measurement worker, an RPC method, and a se…
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 required template section: ELI5, What Changed, Why, Linked Issue (#16776 with the cleanup shipped in #43000), Visual Proof (before/after images and fixture…
Full details: Title check
Explanation
The title names the main change: a Settings > Agents line that shows how much disk space Codex chat history uses. The changeset adds a host-level disk-usage measurement worker, an RPC method, and a settings row that displays the size, so the title matches the primary change. The conventional-commit prefix 'feat(settings)' fits the work.
Full details: Description check
Explanation
The description is thorough and covers every required template section: ELI5, What Changed, Why, Linked Issue (#16776 with the cleanup shipped in #43000), Visual Proof (before/after images and fixture notes), Testing (manual and automated checks with checkboxes), Risk (level Low, rollback, and backwards-compatibility notes), Review, the upstream boundary checkbox, Notes, and the Checklist. The Linked Issue section says 'Tracked in #16776' and 'Fixes #' is not filled in, which is a minor gap because the template asks for a 'Fixes #' link. The AI Disclosure section is left blank, which the template allows for StablyAI team members but which is unclear for outside contributors. The Visual Proof section gives before and after images for both light and dark themes. The PR is mostly complete, so the check passes.
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; 2 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
⚠️ Outside diff range comments (1)
Minor · Reuse the cached size only for the same host history source. · codex-history-disk-usage.ts:90
src/main/codex/history/disk-usage/codex-history-disk-usage.ts:90 Minor · Functional Correctness · Quick win
Reuse the cached size only for the same host history source.
The reader reuses the last result for five minutes, and it joins an active walk, without comparing the host history source. Changing codexSessionSourceHome.host does not clear the reader. Only a Codex history deletion calls forgetCodexHistoryDiskUsage. A read after the change can therefore show the size measured for the previous source.
Make the reader compare the effective host source before it returns last or inFlight. Start a new walk when that value differs. Keep reuse for an unchanged source, because the current design depends on it.
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: 67f201e0-ca73-435d-8186-f67f1c3e8e5f
Commits
Reviewing files that changed from the base of the PR and between 80c7d95 and 4c479b1.
Files ignored due to path filters: 1
src/shared/rpc-contract/rpc-params-catalog.generated.ts is excluded by !**/*.generated.*
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.
…ew stops waiting
Each read names its view; a view that closes, hides or switches host before the size
arrives releases it, and the host stops the walk once no view waits.
Co-authored-by: Max Hsu <[email protected]>
…s; bound the wait for a stopped walk
A window that reloads, crashes or disconnects never sends its release, so each read
now registers against its connection and is released when that connection retires.
Waiting for a stopped walk's worker is capped and ends when the read is abandoned, so
a worker stuck on a hung mount can't hang every later read.
Co-authored-by: Max Hsu <[email protected]>
…e the read is abandoned
Each retry no longer attaches a waiter to a worker stuck on a hung mount, and a read
released before its wait began returns at once.
Co-authored-by: Max Hsu <[email protected]>
Listing the account folders can't be cancelled, so reads abandoned while it stalls
each left one pending. Reads now share one listing and one wait for a stopped worker,
each capped at 10 s, and fail fast past the cap without attaching more waiters.
Co-authored-by: Max Hsu <[email protected]>
Reviewed PR #43894 at 3477418ccca8c79af6c00dd5d7e36904fb988cb8..9f692abad4e8bd94366865cd27af653a4b49249e, tracked in #16776. No performance regression remains demonstrated. No repository files edited.
The previous preparation blocker is fixed.sharedCappedTask():63 now owns both account discovery and worker-retirement waits. Caller cancellation releases the reader without reopening admission to the underlying stalled task. Its ten-second cap settles waiters; subsequent attempts fail promptly until the underlying task ends.
I reran the pending-listing reproduction using the actual discovery function, coordinator, reader, request queue and lazy worker host, with filesystem listing held pending:
Abandoned reads
Previous head: outstanding listings
This head: outstanding listings
This head: listings after recovery and a successful fresh read
100
100
1
4
1,000
1,000
1
4
The four listings are two for the original shared discovery and two for the fresh discovery after recovery. Both populations started exactly one worker, for the surviving read. The previous head performed 202/2,002 listings with its live successor.
Post-GC v8.queryObjects(Promise) comparison also confirms that the cap releases abandoned waiters:
Abandoned reads
Previous head: retained promises
This head before cap
This head after cap
After another N failed attempts while still stalled
100
800
109
8
8
1,000
8,000
1,009
7
7
Counts are relative to each harness baseline, not retained bytes. Before the cap, abandoned callers temporarily leave promise reactions on the shared capped wait. These drain at ten seconds; retries thereafter accumulate neither filesystem requests nor retained promises. One underlying discovery can remain pending and finish its second listing after abandonment, but that tail is constant per host.
The retirement fix still passes. With simulated worker termination held pending:
Failed replacement attempts
Previous head: retained promises
This head: retained promises
This head: retirement waits
100
5
6
1
1,000
5
6
1
No overlapping worker started. Both revisions recovered after worker exit; retained counts fell below their respective pre-retry baselines afterward.
The new work, its triggers and reference-fleet price are:
Work
Trigger, population and owner
Work and bound
Renderer hook and search
One setting per mounted Settings > Agents view, selecting one host. Mount, host change, matching-search transition or cleanup revision.
One added scalar search selector; fixed setting text matched against a query capped at 2 KiB. No history-dependent work per keystroke, status update, PTY chunk or CLI request. Primitive effect dependencies avoid restarts from target-object identity changes.
Renderer subscriptions
Each mounted hook.
One visibility listener, one stale-visibility recovery registration and one cleanup-completion listener. Recovery’s global input/focus listeners are shared. Each cleanup event performs one host comparison per hook. Teardown unregisters them.
Renderer admission
Matching row in a visible window, with an unread host/revision.
Hidden/search-filtered views admit zero measurements. Other settings sections unmount this setting. Paired web clients and the composer omit it. Completed or failed revisions do not poll. An unsettled effect sends at most one release RPC on teardown.
RPC preparation
Each requested read on the selected host.
One in-memory settings-reference lookup; bounded consumer-ID validation and connection-scoped registration. No history-sized payload. C consumers cost O(C) bookkeeping and requested responses, sharing one measurement.
Main-side discovery
Each cold measurement, shared across simultaneous or abandoned attempts while preparation remains pending.
Constant path construction, two sequential asynchronous account-root listings, O(A) filtering/allocation, and O(A) request cloning for A account candidates. No transcript enumeration on main. A=100/1,000 means 100/1,000 candidate records, independent of worktrees and live agents.
Synchronous preparation
Same cold measurement.
Syntactic path operations and constant homedir() OS lookups—six on the ordinary macOS path including dispatch preparation. No new synchronous filesystem traversal, ownership verification, SQLite call or shell child on this route.
Preparation cap
Stalled account discovery.
One shared underlying discovery and one ten-second deadline per host. After expiry, retries start no discovery and add no retained waiters. Completion/rejection clears the shared task so a fresh attempt can progress.
Account verification
A candidates, on the worker before traversal.
Normally seven filesystem API calls/account, potentially eight with marker fallback, plus marker contents. A=100/1,000 prices at roughly 700/7,000 calls. This is distinct from live-agent population.
Worker walk
One admitted cold measurement per host process.
O(E) directory entries and O(F) rollout-name stats. Zero transcript-body reads or decompression. Canonical roots deduplicate; internal links are skipped. Hard-linked names still require stats, while allocated bytes count once per inode.
Worker memory
One scan’s lifetime.
O(unique inode identities + directory frontier + current-folder records + roots). Directory entries stream; no recursive promise fan-out. Four million steps bound traversal operations, not a measured heap-byte limit.
Worker budgets
Each dispatched scan.
Four million traversal steps or 60 seconds returns complete=false with the counted lower bound. Ownership verification precedes that traversal deadline. Dispatch has a 90-second timeout. Native I/O may delay physical termination; replacement remains fenced. Later requested scans restart, without automatic retry loops.
Cache
Singleton per host process.
One three-scalar result reused for five minutes, one current measurement and O(C) active consumer names. At 100/1,000 consumers, sharing checks started one measurement; cache hits started none. Expiry schedules no work.
Deletion clears the cached result and aborts obsolete work without eagerly replacing it. Surviving consumers preserve the scan. Last release terminates active traversal. Connection registrations clear. Shared preparation/retirement tasks retain only their bounded underlying owners.
Worker retirement and idle
Cancellation/timeout, or successful completion.
One shared ten-second retirement wait. An idle worker is unreferenced and receives one 30-second teardown timer. No periodic inventory or respawn loop.
Publication
Measurement completion.
One small worker result and one requested response per waiting reader, containing three usage scalars. Zero new unsolicited frames/s under idle, status or PTY traffic. Existing cleanup-completion publication is unchanged.
Desktop/server bundle
Build/package time; worker starts on demand.
One additional worker artifact. Server output uses its basename beside orcad.js, matching runtime resolution. Coordinator plus reader contain 8,451 source bytes; walker contains 8,219. These are source sizes, not measured bundle deltas. No per-file SSH RPCs or shell children.
The reference fleet’s 750 worktrees, dozen repositories, hundreds of terminals, 100+ agents, frequent status updates, CLI callers, branches, refs and remotes add zero scan multiplicity, including at 10× those populations. Distinct selected hosts pay independently. Consumer count increases small responses and ownership bookkeeping, not filesystem walks.
Existing cleanup scheduling can supply hourly completion events while this view remains visible; explicit runs and settings changes can also invalidate its renderer revision. The five-minute host cache coalesces reads unless deletion explicitly invalidates it. There is no new timer-driven measurement.
Fresh deterministic traversal checks produced:
Workload
Rollout stats
Directory readSync calls
Open/close pairs
Unique rollouts counted
42,567 files
42,567
42,570
2
42,567
425,670 files
425,670
425,673
2
425,670
425,670 files across four hard-linked trees
1,702,680
1,702,692
8
425,670
Duplicate home spellings added no traversal. Transcript-body reads were zero. The cutoff control retained its counted prefix, returned complete=false, and closed every opened directory handle.
The supplied [author-run macOS benchmark](author-run benchmark, read-only) reports 54,341,025,792 allocated bytes, 42,580 rollouts, complete=true, 6,426 ms elapsed and 102 MB process RSS. I verified that the worker file is byte-identical between that revision and this head, and that the benchmark’s traversal core matches it. The benchmark bypasses account verification, worker startup, RPC and Electron; RSS measures the whole benchmark process.
At that measured population, an hourly traversal prices at 1.79 ms/s averaged scan wall time. Repeated requested traversals every five minutes would price at 21.42 ms/s, absent intervening deletion invalidations. These are neither CPU utilization nor automatic cadence. Ten times history bytes with unchanged filenames adds no traversal operations; ten times filenames increases metadata work linearly until cutoff.
The regression-class dispositions are:
Class
Disposition
No-op store writes
No matching new store mutation. Hook state records requested results/revisions.
Whole-map/settings selection
No matching broad selection. Added search selection is scalar.
Per-row whole-collection derivation
No matching code. One settings row; fixed search text.
Streaming whole-message processing
No matching code. Transcript contents are unread.
Fixed-cadence polling
No matching new poll. Deadlines and idle teardown are one-shot timers.
Hidden/unobserved owners
Matched and disproved: visibility/search admission, release, shared preparation and capped wait retention.
Subprocess per item/event
No matching code: zero new shell/git children.
Sync filesystem/SQLite on main
Matched and disproved for measurement: synchronous ownership and traversal run on the worker; main discovery is asynchronous.
Re-reading unchanged input
Matched and proportionate: concurrent sharing and five-minute result reuse; stalled preparation is now shared.
Unchanged publication
Matched and disproved: requested scalar responses; no new unsolicited publication.
Whole snapshots/N notices
No history-sized publication. O(C) responses answer C accepted reads.
Whole-file rewrite
No matching code: measurement writes no history or persisted state.
Per-entity state outlives entity
Matched and disproved: teardown controls clear registrations; post-cap retained promises remain constant at N/10N.
Hot-path rescans
Matched and disproved: no scan on unrelated store, status, PTY or CLI traffic.
Unbounded fan-out/queues
Previous finding fixed: one pending discovery and retirement owner; one worker; streamed traversal; recovery controls pass.
Eager startup imports
Matched and bounded: small coordinator/reader additions; lazy queue and worker creation; no new SDK import or startup filesystem scan. Startup latency was not measured.
All six scan questions were assessed:
Question
Disposition
1. Unused work before the skip gate?
Checked: renderer visibility/search/revision gates and host cache precede scanning. Discovery’s unavoidable abandoned tail is shared and constant.
2. Does ownership multiply work?
Checked: 100/1,000 consumers share one measurement; abandoned generations retain one underlying discovery.
3. Which thread/storage pays?
Reviewed: main pays asynchronous listing completion and O(A) preparation/cloning; worker pays ownership and metadata traversal. No new SQLite/history writes.
4. What grows; does another attempt advance?
Checked: entries, filenames and accounts scale linearly. Cutoffs disclose lower bounds. Stalled owners reject retries after ten seconds and reopen admission after recovery.
5. What does the host change?
Source-reviewed: work executes on the selected host; WSL UNC roots are excluded; Windows uses logical size; no per-file transport round trips. Native host timing beyond macOS remains unmeasured.
6. Does obsolete work release its budget?
Checked: last-reader abort, survivor preservation, connection teardown, shared deadlines, worker fencing and post-exit recovery pass. Underlying hung native I/O may persist as one fenced owner.
Verification: three targeted test files passed, six tests total, through tc-gate. Fresh in-memory checks covered pending discovery, retained promises, N/10N sharing and traversal, cache reuse, deletion invalidation, cutoff cleanup, navigation, renderer loss, destruction, request abort and remote connection closure.
Pre-existing deletion discovery still performs O(A) synchronous ownership checks on its existing deletion path; this measurement performs those checks on its worker instead.
No app launch, build or new real-profile scan ran. Packaged loading, actual hung native I/O, Windows/Linux/SSH timing, startup latency and peak memory at the traversal cap remain unmeasured. The marker retains the supplied detector’s shipped-file classification; the server bundle script was also reviewed.
Problem. Codex keeps a log for every chat. On heavy machines they reach tens of GB (#16776 saw 11 GB; one profile measured here has 54 GB). #43000 added an opt-in "Delete agent history when a workspace is deleted", but it is off by default and nothing showed how much space was at stake.
What users see. Settings › Agents: under that switch, "All Codex chat history on {host} takes {size}." It reads "takes at least {size}" when the walk stops early. Nothing is deleted and no default changes. Scope was confirmed by a three-member council: option 1, the size line. An "older than N days" delete would have freed 0.1 GB of the 37.4 GB on the measured profile, and automatic retention is not what Codex itself does.
How it works. A new workspaceCleanup.codexHistoryDiskUsage RPC runs on the host that owns the workspaces. Main lists Codex homes and account folders asynchronously. A worker thread then checks account ownership and walks sessions, archived_sessions, .orca-set-aside-rollouts and *.orca-profile-merge:
It reads metadata only, follows no links inside history, and drops a folder whose real path changes mid-walk.
Hard-linked rollouts count once, by allocated blocks (file length on Windows).
The walk is capped at 4M entries or 60 s, counted from when the worker starts it.
One walk runs at a time and is reused for 5 minutes. An Orca deletion aborts the running walk.
Each read names itself. The walk stops once no reader waits: a view that closes, hides or switches host releases its read, and so does a window whose connection ends (reload, crash, disconnect).
Listing the account folders and waiting for a stopped walk's worker to exit are each one shared run, capped at 10 s. Past the cap, reads fail fast while a hung drive keeps it stuck, so abandoned reads can't pile work up.
The renderer reads only while the row is visible (search and window) and once per finished cleanup run.
Fixed during review (17 Claude + Codex review rounds, perf scans and a council):
the deadline had started at queue time, which starved a post-deletion walk;
async per-file stats were about 50× slower, so the walk went back to sync calls in the worker entry;
the budget didn't cover the home listing or empty folders, so it does now;
a symlink swap mid-walk could be counted, and now isn't;
merge folders were uncounted;
an unreadable folder was reported as a complete total;
the worker was missing from the server bundle;
a search-hidden row still triggered a scan;
sync account-ownership checks on main (one through session discovery's callback) moved to the worker;
relocated account folders were missing;
duplicate home spellings were walked twice;
a walk kept running after the last Settings view stopped waiting, or after its window reloaded, crashed or disconnected (perf P1s);
a quick close-and-reopen failed while the old worker exited, and the wait for it could hang or pile up waiters on a hung drive;
reads abandoned while the account-folder listing stalled each left another listing pending;
crypto.randomUUID is unavailable in non-secure contexts, so the read id uses the existing helper.
The cleanup's delete list is unchanged except that an Orca-owned account reached through a symlinked folder is now included. Ownership by canonical path is the gate, and reviewers verified it.
Deferred / known limits.
Remote host shown in a reloading desktop window: the shared remote socket stays open across the reload, so that host's walk runs to its 60 s bound. The gap is in the shared transport, not new here.
WSL: history inside a WSL distro is not counted, the same as the deleter.
Windows: sizes are file length.
Staleness: after changing the Codex history source or adding an account, the old number can show for up to 5 minutes.
Pre-existing, not from this PR: the cleanup re-lists homes, including sync ownership checks on main, once per rollout it deletes (R × A checks per run). Separate follow-up.
Packaging: no smoke test of the packaged app. The worker is registered in the desktop and server bundles and in the worker-entry guards, and CI's builds cover packaging.
Verified.
check:changed on Linux: 41/41 at 9f692abad4e8bd94366865cd27af653a4b49249e; b6f361c76f2287e61a59dd16dae4c4460cd4fc65 only merges main (three times) (the generated RPC params catalog was regenerated).
Real-profile benchmark: Benchmark: head=b6f361c76f2287e61a59dd16dae4c4460cd4fc65 gate=PASS. 42,591 rollouts, 54.4 GB, complete, 10.8 s, 103 MB RSS. Read-only, on macOS at load ≈11, running the walk from 9f692abad4e8bd94366865cd27af653a4b49249e directly; the merge doesn't touch it.
Unit tests: the walk on temp homes (hard links, shared folder, set-aside, merge folder, .zst, symlinked log, unreadable folder, budget, allocated blocks); the reader's deletion abort and last-reader release; the RPC layer's release when a window's connection closes.
Screenshots are in the PR body (component fixture).
QA by tests, no app run: the change is a settings line backed by an RPC and a worker. Tests drive the walk end to end, and the layout is shown by the fixture.
Perf scan carried to the merged head. 7e9a1e130ca5d6e4d060bc4ef232d1427b1bf061 merges main twice into 9f692abad4e8bd94366865cd27af653a4b49249e, the head the full scan above ran on (verdict clean). The PR's own diff against main is unchanged line for line; the only difference is the regenerated RPC params catalog, which verify:rpc-params-catalog checks.
Perf scan carried to the merged head. b6f361c76f2287e61a59dd16dae4c4460cd4fc65 merges main three times into 9f692abad4e8bd94366865cd27af653a4b49249e, the head the full scan above ran on (verdict clean). The PR's own diff against main is unchanged line for line; the only difference is the regenerated RPC params catalog, which verify:rpc-params-catalog checks.
Brennan's review: the size belongs to Codex, and a sentence was wordy. The row now shows
'Codex history: <size>' (with '+' when the walk stopped early) as a muted badge; its
tooltip says the space is Codex's own history and that the setting frees only chats
from workspaces that no longer exist, so the number isn't read as what turning it on saves.
Co-authored-by: Max Hsu <[email protected]>
DONE: CLEAN The badge tooltip adds bounded local UI work; the earlier clean verdict holds for PR #43894 at cb12fdf.
No performance findings. No files edited.
Verified that the PR’s added/deleted lines are identical from 9f692ab through b6f361c; differences are main-merge context. The final span changes exactly the renderer row, fixture and two copy files. The disk-usage hook, coordinator, reader, worker and RPC implementation remain byte-identical to the previously reviewed head.
The added cost is source-bounded:
Surface
Trigger and cost
Render
The row adds one badge and one translation per existing render when usage is present. Byte formatting remains one call, capped at five divisions.
Ownership
AgentsPane mounts one such setting per eligible settings pane, independent of worktree, terminal, agent and transcript counts. Search exclusion unmounts the tooltip subtree.
Subscription
Zero added app-store subscriptions, cleanup listeners or RPC registrations. Tooltip state/context is local; opening it does not update the parent row or restart its measurement effect.
Closed tooltip
Radix Presence omits content: zero positioning observers, content scroll listeners or positioning frame loops. One pending hover timer is possible after interaction; leave/unmount clears it.
Open tooltip
One content subtree mounts positioning and dismissal machinery. Positioning uses the optimized strategy with animationFrame=false. Opening dispatches one local tooltip.open DOM event; it adds zero runtime publication or history requests. Close/unmount releases content resources after exit presence.
Startup
The tooltip module is already imported by the row’s existing form controls and app provider. No newly introduced dependency graph or startup scan.
At 750 worktrees/100+ agents and at 10× those populations, the added population remains one tooltip per mounted settings pane. Existing parent renders pay fixed badge/copy work; fleet or history size introduces no tooltip fan-out. Additional panes add their own required UI.
All six scan questions were assessed:
Question
Disposition
Work before skip gates
Fixed text/element construction only; no new measurement admission.
Ownership multiplication
One instance per pane; existing shared provider, no provider per row.
Thread/storage cost
Added work stays in renderer UI; no storage, worker or transport changes.
Growth/progress
Constant per pane; prior scan’s shared preparation, cache and traversal bounds remain intact.
Host differences
No added host-dependent work or remote round trips.
Touched regression classes—render/context fan-out, hidden owners, timers, resource retention, publication and eager imports—were matched and disproved by these bounds. No new broad selector, collection derivation, poll or repeated scan appears.
This was a source/count review, including installed Radix tooltip/popover internals. Earlier runtime checks are inherited from the supplied full report, not rerun. No timing, CPU or heap improvement is claimed. Its packaged-loading and non-macOS runtime limitations remain unchanged. The previously reported synchronous ownership checks on the deletion path remain pre-existing.
Verified cb12fdf..72e3980 changes only the fixture and two static badge classes. shrink-0 and whitespace-nowrap affect layout on two existing elements; class merging receives one additional constant string per render. Cost remains constant per mounted settings pane at fleet N and 10N.
All six scan questions remain satisfied: no added computation before gates, owners, storage work, collection growth, host calls or resources requiring cleanup. Publication/subscription paths are unchanged; no regression class introduces amplified work.
Source review only; runtime measurements were not rerun. No files edited.
Problem. Codex keeps a log for every chat. On heavy machines they reach tens of GB (#16776 saw 11 GB; one profile measured here has 54 GB). #43000 added an opt-in "Delete agent history when a workspace is deleted", but it is off by default and nothing showed how much space was at stake.
What users see. Settings › Agents: next to that switch's "Recommended" badge, a muted badge "Codex history: {size}" ("{size}+" when the walk stops early). Its tooltip says the space is Codex's own chat history on that host, including live workspaces' chats, and that the setting removes only chats from workspaces that no longer exist. (Brennan's review moved it from a sentence into the badge; a light council chose the honest Codex total over a "would free" number, which needs content reads and a second copy of the deletion rules.) Nothing is deleted and no default changes. Scope was confirmed by a three-member council: option 1, the size line. An "older than N days" delete would have freed 0.1 GB of the 37.4 GB on the measured profile, and automatic retention is not what Codex itself does.
How it works. A new workspaceCleanup.codexHistoryDiskUsage RPC runs on the host that owns the workspaces. Main lists Codex homes and account folders asynchronously. A worker thread then checks account ownership and walks sessions, archived_sessions, .orca-set-aside-rollouts and *.orca-profile-merge:
It reads metadata only, follows no links inside history, and drops a folder whose real path changes mid-walk.
Hard-linked rollouts count once, by allocated blocks (file length on Windows).
The walk is capped at 4M entries or 60 s, counted from when the worker starts it.
One walk runs at a time and is reused for 5 minutes. An Orca deletion aborts the running walk.
Each read names itself. The walk stops once no reader waits: a view that closes, hides or switches host releases its read, and so does a window whose connection ends (reload, crash, disconnect).
Listing the account folders and waiting for a stopped walk's worker to exit are each one shared run, capped at 10 s. Past the cap, reads fail fast while a hung drive keeps it stuck, so abandoned reads can't pile work up.
The renderer reads only while the row is visible (search and window) and once per finished cleanup run.
Fixed during review (20 Claude + Codex review rounds, perf scans and a council):
the deadline had started at queue time, which starved a post-deletion walk;
async per-file stats were about 50× slower, so the walk went back to sync calls in the worker entry;
the budget didn't cover the home listing or empty folders, so it does now;
a symlink swap mid-walk could be counted, and now isn't;
merge folders were uncounted;
an unreadable folder was reported as a complete total;
the worker was missing from the server bundle;
a search-hidden row still triggered a scan;
sync account-ownership checks on main (one through session discovery's callback) moved to the worker;
relocated account folders were missing;
duplicate home spellings were walked twice;
a walk kept running after the last Settings view stopped waiting, or after its window reloaded, crashed or disconnected (perf P1s);
a quick close-and-reopen failed while the old worker exited, and the wait for it could hang or pile up waiters on a hung drive;
reads abandoned while the account-folder listing stalled each left another listing pending;
crypto.randomUUID is unavailable in non-secure contexts, so the read id uses the existing helper.
The cleanup's delete list is unchanged except that an Orca-owned account reached through a symlinked folder is now included. Ownership by canonical path is the gate, and reviewers verified it.
Deferred / known limits.
Remote host shown in a reloading desktop window: the shared remote socket stays open across the reload, so that host's walk runs to its 60 s bound. The gap is in the shared transport, not new here.
WSL: history inside a WSL distro is not counted, the same as the deleter.
Windows: sizes are file length.
Staleness: after changing the Codex history source or adding an account, the old number can show for up to 5 minutes.
Pre-existing, not from this PR: the cleanup re-lists homes, including sync ownership checks on main, once per rollout it deletes (R × A checks per run). Separate follow-up.
Packaging: no smoke test of the packaged app. The worker is registered in the desktop and server bundles and in the worker-entry guards, and CI's builds cover packaging.
Verified.
check:changed on Linux: 42/42 at 72e3980cda85a71460cfc3e98334844d5707bdda.
Real-profile benchmark: Benchmark: head=72e3980cda85a71460cfc3e98334844d5707bdda gate=PASS. 42,691 rollouts, 54.5 GB, complete, 14.8 s, 85 MB RSS. Read-only, on macOS at load ≈36 (busy machine), running the walk from this head directly.
Unit tests: the walk on temp homes (hard links, shared folder, set-aside, merge folder, .zst, symlinked log, unreadable folder, budget, allocated blocks); the reader's deletion abort and last-reader release; the RPC layer's release when a window's connection closes.
Screenshots of the badge and its open tooltip, light and dark, are in the PR body (component fixtures).
QA by tests, no app run: the change is a settings line backed by an RPC and a worker. Tests drive the walk end to end, and the layout is shown by the fixture.
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
Codex keeps a log file for every chat, and on busy machines these logs quietly grow to tens of gigabytes (#16776 saw 11 GB). Orca can already delete the ones from deleted workspaces ("Delete agent history when a workspace is deleted"), but that setting is off by default and nothing told you how much space was at stake. The setting's row now shows a small "Codex history: 49.8 GB" badge: the space Codex's own chat history takes on that computer, so you can decide whether to turn it on.
What Changed
workspaceCleanup.codexHistoryDiskUsageruntime method runs on the host that owns the workspaces (local or remote server). It lists the same Codex homes the cleanup deletes from. Main lists the folders asynchronously, and the account ownership check runs in a dedicated worker thread, which then walks each home'ssessions,archived_sessions,.orca-set-aside-rolloutsand*.orca-profile-mergefolders.Why
Codex itself never deletes rollouts on its own. It offers user-driven archive and delete, and its app-server measures its home with a metadata-only scan. The common pattern for an app hosting Codex is to read these files and leave deletion to an explicit user choice. The opt-in delete already shipped in #43000. What was missing was visibility.
On one heavy real profile, 87% of the 37.4 GB of unique Codex rollouts came from deleted workspaces, which that setting already covers. Only 0.1 GB was older than 30 days and from a workspace that still exists. So an age-based delete or automatic retention would add a new destructive path for almost no gain.
This carries forward community PR #16990 by @maxmilian, who agreed to a credited redesign. He is credited as co-author.
Linked Issue
Tracked in #16776. The cleanup itself shipped in #43000. This adds the size report.
Visual Proof
Before, the row had only the switch, its "Recommended" badge and its description. After:
(Component fixtures with a mocked 53.5 GB result, shown as 49.8 GB because sizes use 1024-based units like the rest of the page. Taken on a Mac, so the host reads "Local Mac".)
Testing
Real-scale benchmark (read-only, on a heavy macOS profile with the walk taken from this head): 42,567 rollouts, 54.3 GB, complete count, 7.5 s, 111 MB RSS, at a machine load average of about 9–11. It runs in the worker, so nothing is on Electron main.
codex-history-disk-usage-worker-entry.test.tschecks the following on temp Codex homes, with the expected values written by hand:.zstrollouts are counted;codex-history-disk-usage-reader.test.tschecks that a deletion stops the obsolete walk and later reads get a fresh one, and that a walk survives its first reader leaving and stops when the last one does.workspace-cleanup-runner-methods.test.tschecks, at the RPC layer, that closing one window's connection keeps a walk another window still waits on, and that closing the last waiting connection stops it.pnpm check:changedpasses on Linux.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
Risk
Level: Low.
Review
Fresh Claude and Codex reviewers ran three passes, each with a perf scan, followed by a three-member council on the final head. The council found no P0 or P1.
Agent skill upstream boundary
Notes
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)