Feature: age-based session auto-archive / retention (esp. scheduled-routine runs) to keep the session list findable
Summary
Please add an age-based session auto-archive / retention setting — a sibling to the existing "Auto-archive on PR close" option — so the session list stays findable when recurring/scheduled agents generate many sessions.
Problem
Scheduled routines (cron-style agents) each spawn a new session per run. A handful of routines at a few-times-a-day cadence produces ~25–30 sessions/week that never self-clean. This quickly floods the session list, and it has two concrete costs:
- Real sessions get buried. The routine runs crowd out the handful of sessions a user actually cares about — including recent ones. On the mobile / remote-control experience this is especially painful: a recent, actively-used session can be effectively unfindable in the noise.
- No practical cleanup path. Today the only options are:
- "Auto-archive on PR close" — helpful, but routine runs never open PRs, so it doesn't touch them.
- Manual archive, which prompts once per session with no bulk / "apply to all" option — unusable for dozens of items.
Editing the on-disk session JSON directly (setting isArchived) does not work reliably, because the app serves the session list from an in-memory/LevelDB cache that doesn't pick up file edits live — so there's no safe external workaround either.
Proposed solution
An opt-in retention policy in Settings, e.g.:
- Auto-archive sessions older than N days (default off; user-set threshold).
- Optionally scoped to scheduled-task-spawned sessions — these records already carry a
scheduledTaskId, so the app can distinguish routine runs from manual/one-off sessions and leave the latter alone. - Optional second stage: auto-delete archived sessions older than M days (with the existing archive as the reversible intermediate state).
An even cleaner source-side option would be a per-scheduled-task "auto-archive this run on completion" toggle, so routine runs never accumulate in the active list in the first place.
Why it matters
Scheduled/background agents are increasingly central to how people use Claude Code, and each one is a session generator. Without a retention story, the more automation a user adopts, the less usable their session list becomes — particularly on mobile. Auto-archive-on-PR-close already establishes the pattern; this extends it to the time/routine dimension.
Related
- #29726 (Remote Control: iOS … no session cleanup)
- #20200 ([BUG] Memory Leak from Unbounded Session File Growth)
_Filed as a feature request from a heavy scheduled-routine user whose session list became unnavigable on mobile._