Skip to content

Restore last closed session / suggest recent closed sessions when creating a new session #46

@AThraen

Description

@AThraen

This was generated by AI during triage.

Problem

If you accidentally close a session (e.g. via Ctrl+W, the sidebar , or the terminal toolbar close button) and only afterwards realize you still needed it, there is currently no easy way to get it back. Once MainViewModel.OnSessionCloseRequested removes the session, SessionManager.RemoveSession() drops the ShellSession from state.json — and on the next save the prior state is gone. The user has to recreate the session from scratch and lose any captured terminal scrollback / FTS5 history that was associated with it.

Sleep/wake (💤) already solves the intentional "keep it around for later" case, but does not help when the close was a mistake.

Proposed direction (open to discussion)

Two complementary ideas, either or both:

  1. Undo last close — a short-lived buffer of the most recently closed sessions. Reachable via:
    • Ctrl+Shift+T (mirrors browsers / Windows Terminal)
    • A "Reopen closed session" entry in the button's dropdown (if there is one) or in a tray-icon / sidebar context menu
      The reopened session would relaunch its PTY just like a wake-from-dormant.
  2. Suggestions in New Session dialog — when the user opens NewSessionDialog, show a small "Recently closed" list (last N, e.g. 5) above the existing form. Clicking one pre-fills all fields (folder, command, SSH config, profile overrides, run commands) — or, more directly, recreates the session immediately with the same settings.

Open questions

  • How long do we keep "recently closed" entries? Just for the current run, or persisted across app restarts (e.g. last 10 in state.json)?
  • Do we keep the underlying SQLite FTS5 output history when a session is closed so that a "reopen" can keep prior scrollback searchable? Today OutputIndexer writes everything to a single DB — we'd need a way to mark rows as belonging to a closed session and either keep or evict them.
  • Does "reopen" want to be exactly the same as wake-from-dormant (same ShellSession, same Id) — meaning we essentially keep a tombstoned dormant entry for a while — or should it create a new session with copied settings?
  • Should there be a confirmation prompt on Ctrl+W (configurable in settings) as a complementary safety net, or do we lean entirely on the undo path?

Acceptance

  • There is at least one obvious, discoverable way to recover a session that was just closed by mistake
  • Recovery preserves the session's settings (working folder, command, SSH config, profile overrides, run commands, group membership)
  • Behavior on app restart is documented (does the undo buffer survive a restart?)
  • Keyboard shortcut and/or menu entry is documented in CLAUDE.md under "Keyboard Shortcuts"

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions