Repository navigation
Add Storage page for Codex session usage and cleanup policy #42
Description
Problem
Codex session data can grow quietly over time, but the dashboard currently does not show where that storage is going or offer a guided way to reclaim space.
On one active Windows setup, the largest Codex-related storage buckets were roughly:
- archived sessions: ~3.1 GB
- active sessions: ~1.3 GB
- logs sqlite: ~1.1 GB
- attachments / remote attachments / deletion manifests: smaller, but still useful to surface
The exact numbers will vary by user, but the important part is that storage is split across multiple Codex-owned areas. Users often only notice the problem after disk space has already dropped sharply.
Proposal
Add a dashboard Storage page that starts with read-only diagnostics, then grows into cleanup controls if the direction makes sense.
Phase 1: storage diagnostics
Show a compact breakdown for:
- active sessions
- archived sessions
- logs database / WAL files
- attachments
- remote attachments
- deletion manifests
- total tracked size
Useful fields:
- size
- count
- oldest item
- newest item
- largest few items, capped to avoid rendering a huge table
Phase 2: manual archived cleanup
Add an archived-session cleanup flow with preview first:
- slider for deleting the oldest archived conversations by percentage
- quick presets such as 10%, 25%, 50%
- preview button before any deletion
- confirmation modal showing estimated count and bytes to remove
- optional checkbox for immediate permanent deletion
- safer default can be quarantine/trash if preferred by the project
Active sessions should probably stay read-only at first.
Phase 3: optional auto-cleanup policy
Add an opt-in policy for users who want storage to stay bounded:
- default off
- threshold such as "archived sessions exceed N GB"
- cleanup target such as "reduce to N GB" or "delete oldest N%"
- schedule such as startup / daily / weekly / manual
- deletion mode: quarantine/trash or permanent delete
- last run, next run, and freed bytes summary
This should run as a batch policy, not delete one item every time a new session appears.
Implementation concerns
Deleting Codex history is not just a simple filesystem delete. The implementation may need to account for:
- rollout JSONL files
state_5.sqlitethread rows and rollout paths- attachments linked to removed sessions
- deletion manifests / audit trail if quarantine is used
- database locks while Codex is active
Because of that, I think the first PR should probably be read-only diagnostics plus cleanup preview, with actual deletion added only after the data model is clear.
Open questions
- Should opencodex directly manage Codex session deletion, or only expose diagnostics?
- Should
logs_2.sqlitebe shown on the Storage page, cleaned separately, or left as diagnostics only? - Should permanent deletion be supported behind an explicit checkbox, or should quarantine be the only supported cleanup mode?
- If you agree with this direction, would you prefer to implement it yourself, or should I prepare a phased PR starting with read-only diagnostics?
Activity
lidge-jun commentedon Jun 29, 2026
Promoting this to a long-term epic with phased delivery. Splitting the work as you proposed:
Phase 1 — Storage diagnostics (read-only) · low risk · first PR
A dashboard Storage page that shows where
~/.codexdisk goes, with zero deletion.GET /api/storage(read-only) aggregating per-bucket size/count/oldest/newest.gui/src/pages/Storage.tsxnext to Usage/Logs.fs.stat; any DB row counts via?mode=ro&immutable=1with graceful skip on lock — never opens an in-use DB for writing.Phase 2 — Manual archived cleanup · C4 high-risk · separate PR
Reclaim space from old archived sessions, preview-first, quarantine by default.
threadsrow (rollout_path,archived) + attachments + deletion manifest, plus WAL-lock safety while Codex is running.Phase 3 — Opt-in auto-cleanup policy · default OFF · separate PR
Threshold + target + schedule + deletion mode, with last/next-run and freed-bytes summary. Inherits all Phase 2 safety.
Measured layout (this Mac,
~/.codex)sessions/<YYYY>/<MM>/<DD>/rollout-<ts>-<uuid>.jsonl— 2.4 GB / 858 files (dominant consumer). JSONL line types:session_meta,event_msg,response_item.state_5.sqlite—threadstable (236 rows, 1 archived) withrollout_pathas the JOIN key to each session's JSONL, plusarchived/archived_at.logs_2.sqlite— 78,037 rows, separate lifecycle (estimated_bytesper row).archived_sessions/— flat dir of archived rollout JSONL.Recommendation: ship Phase 1 (read-only) first; Phase 2/3 land as separate, carefully-reviewed PRs with quarantine as the default cleanup mode and explicit lock safety.
docs(storage): promote issue #42 to 500_ epic with phased plan
docs(storage): expand #42 epic to jawdev granularity
Wibias commentedon Jul 10, 2026
@lidge-jun Have u already started working on this one?
lidge-jun commentedon Jul 10, 2026
@Wibias not yet I think upstream will fixing issue with somehow but planning in weeks
Chang-Jin-Lee commentedon Jul 20, 2026
Hi @lidge-jun — I'd like to take Phase 1 (read-only diagnostics) as scoped in your epic comment and
devlog/_plan/500_storage-page-session-cleanup(31–33): a storage scanner module +GET /api/storage+ a read-only Storage page next to Usage/Logs, with fixture tests asserting the read-only invariant (no writes under CODEX_HOME during a scan). Zero deletion logic — Phases 2/3 untouched.Planning to open a PR within a day or two — please flag me if this collides with anything you've already started.
feat(gui): read-only Storage diagnostics page (Phase 1 of #42) (#173)
lidge-jun commentedon Jul 22, 2026
Status update: Phase 1 (storage diagnostics page) has landed. The remaining phases — cleanup actions and auto-cleanup policy — touch session lifecycle and are deliberately gated behind more careful design, since a bad cleanup pass can destroy user threads. Still planned, keeping this open to track Phase 2+.
Wibias commentedon Jul 27, 2026
Phase 2 (Option A) opened in #529 — preview-first archived cleanup with quarantine under
CODEX_HOME/.trash(permanent delete behind checkbox). Phase 1 hygiene (.trashscan skip, dead imports, docs) folded into that PR. No restore UI / auto-policy yet (Phase 2.1 / Phase 3).github-actions commentedon Jul 27, 2026
Merge pull request #529 from Wibias/feat/storage-phase2-cleanup
docs(devlog): correct the decision ledger against an independent audit
Merge pull request #559 from Wibias/feat/storage-phase3-auto-policy
feat(storage): restore quarantined archived sessions (phase 2.1 of #42)…
docs(storage): promote issue lidge-jun#42 to 500_ epic with phased plan
docs(storage): expand lidge-jun#42 epic to jawdev granularity
feat(gui): read-only Storage diagnostics page (Phase 1 of lidge-jun#42)…
Merge pull request lidge-jun#529 from Wibias/feat/storage-phase2-cleanup
Merge pull request lidge-jun#559 from Wibias/feat/storage-phase3-auto…
feat(storage): restore quarantined archived sessions (phase 2.1 of li…