Skip to content

Persistent live sessions: detach, reattach and restore #125

Description

@raiseCatError

Goal

Closing or crashing the NMSh frontend should not necessarily kill the user's shell or foreground command. A local session service owns the PTYs and zsh processes. The NMSh frontend becomes a client that can detach and reattach.

nmsh frontend/client
      │
      ▼
persistent local session service
      │
      ├─ PTY + zsh session A
      ├─ PTY + zsh session B
      └─ PTY + zsh session C

Why

Today the PTY and managed zsh live inside the frontend process, so closing a Ghostty window or a frontend crash kills the shell and any running build, server or long job. #22/#88 already restore presentation after exit; this issue keeps the live process alive. It is also a prerequisite for Flow / Classic (#132).

Product direction (decided)

Not hidden tmux. tmux keeps working normally inside an NMSh session.

Launch behavior:

State at launch Behavior
No detached live sessions Create a new session
Exactly one detached live session Reattach automatically, with a brief notice
Multiple detached live sessions Offer the session restore picker
Live sessions attached elsewhere Do not hijack them; create a new session by default

/resume becomes the unified continuity hub:

  • LIVE: still-running attachable sessions.
  • ARCHIVED: historical sessions whose process no longer exists.

No separate /sessions UI. A /sessions alias may be considered later.

Detach vs exit:

  • Frontend disappearance (window close, Ghostty crash, frontend crash) detaches.
  • Real termination (zsh exits, Ctrl+D where zsh would exit, explicit Kill Session) ends and archives the session.

Output while detached: the service keeps reading PTY output and recording it. Reattach shows the existing transcript, output produced while detached, any still-running process, and current session state.

Single controlling client per live session is enough for v1. Multiple simultaneous writable clients are not a v1 requirement.

Limitation

No process resurrection across OS reboot, logout or power loss. After those, only archived history/presentation can be restored (existing #22/#88 behavior).

Non-goals

  • Remote/network sessions, collaboration, multi-writer clients.
  • Hidden tmux/screen as the implementation.
  • Cloud sync.

Architectural constraints

Checkpoints

Dependencies / related

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:executionCommand execution and lifecyclearea:shellShell backend and integrationtype:featureNew feature or improvement

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions