Summary
Follow up to #334341 by permanently deleting archived agent sessions whose associated pull requests have merged after a configurable retention period. This would align the Agents Window lifecycle more closely with the GitHub app while preserving auto-archive as a reversible grace period before deletion.
Proposed behavior
- Only consider sessions that are already archived and whose associated pull requests are all merged.
- Require an additional retention period after archival before permanent deletion.
- Keep permanent deletion disabled by default.
- Revalidate pull request state, archived state, activity, and the current setting immediately before deletion.
- Use the existing session deletion lifecycle so persistence, provider callbacks, worktree cleanup, and client updates remain consistent.
- Provide an enterprise policy for administrators to disable or configure permanent deletion.
Design considerations
- Define behavior for local, remote, and externally sourced sessions.
- Decide whether associated worktrees and branches are deleted, retained, or independently configurable.
- Surface clear user messaging because deletion is irreversible.
- Handle partial failures without reporting a successful deletion.
- Ensure active or recently restored sessions can never be deleted from a stale candidate list.
Related: #334341
Summary
Follow up to #334341 by permanently deleting archived agent sessions whose associated pull requests have merged after a configurable retention period. This would align the Agents Window lifecycle more closely with the GitHub app while preserving auto-archive as a reversible grace period before deletion.
Proposed behavior
Design considerations
Related: #334341