[Feature]: Permanently delete archived sessions from the desktop app, plus an optional retention policy
Problem
Terminated sessions stay in the database forever. Archiving in the desktop app is reversible by design: it moves the session to the board's Archive section (and optionally deletes its artifacts), so every session ever spawned keeps piling up there and in SQLite.
#7440 (for #3402) adds a safe permanent delete, but only on the CLI and API:
ao session delete <id>andDELETE /api/v1/sessions/{id}- refused until the session is terminated and its worktree is cleaned up (
WORKSPACE_NOT_RELEASED), while another operation holds the session, or when its turns belong to a shared orchestrator conversation (SESSION_HISTORY_SHARED) - removes the session's AO history (conversation, PR facts, attachments, artifacts), keeps its spend in the agent account usage totals, and never reuses its id
Desktop users have no way to reach it, and nothing ever removes old sessions on its own. These are the two parts of #3402 Finding 3 that #7440 leaves out on purpose.
Proposed direction
1. A desktop delete action for archived sessions. It would sit on archived session cards (board Archive section and the standalone archive view) and call the existing endpoint. Design decisions, per DESIGN.md:
- where the action lives (card menu vs. a bulk action in the Archive section)
- the confirmation, which must say the delete is permanent and what goes with it
- what to show when the worktree is not cleaned up yet: offer "Clean up and delete", or explain and link to cleanup
- how the 409 refusals (
WORKSPACE_NOT_RELEASED,SESSION_HISTORY_SHARED,SESSION_OPERATION_IN_PROGRESS) read in the UI
The board already refetches on the project-level session_updated event the delete emits, so the card disappears without extra wiring.
2. An optional retention policy (needs a product call):
- opt-in vs. on by default, and the age threshold (e.g. archived for N days)
- whether it deletes only sessions whose worktree is already released, or also runs cleanup first (dirty worktrees must never be forced)
- whether a project or a session can be exempted
- where it runs: the daemon's existing 10-minute workspace cleanup pass from #7440 is a natural home
Alternatives considered
- Keep CLI-only delete. It works, but desktop users never see it.
- Add this to #7440. Left out to keep that PR to the backend fix, since the UI needs a design review and retention needs a product decision first.
Before submitting
- [x] I searched existing issues / discussions for something similar
- [ ] I am willing to help implement this if maintainers agree on scope
Closing: both parts are now in #7440 instead of a follow-up.
- Desktop delete: a trash action next to Restore on archived session cards, with a destructive confirmation. If the worktree is still on disk, it is cleaned up first (never forced), and a refusal is shown in the dialog with the session kept. The same option is available as
ao session delete --cleanupandDELETE /api/v1/sessions/{id}?cleanup=true. Cloud sessions don't get the action. - Retention: opt-in under Settings → Sessions → "Delete archived sessions" (Never by default, or 7, 30 or 90 days). It runs in the daemon's 10-minute workspace pass and deletes only sessions whose worktree is already released, so it never removes a worktree.
Per-project or per-session exemptions are not included; that can be a new issue if needed.