Skip to content

Bring terminals back after a server restart, with OSC 7577 program resume - #1482

Merged
dylanplayer merged 1 commit into
mainfrom
codevisor/pasty
Nov 26, 2026
Merged

dylanplayer merged 1 commit into
mainfrom
codevisor/pasty

Conversation

@dylanplayer

Copy link
Copy Markdown
Member

After a server restart (an update, a crash, a reboot) every open terminal now
comes back under the same terminal ID: its earlier output, then a live shell in
the folder it was last in. Programs that speak the Program Resume Protocol
(OSC 7577) come back running too, in the same pane.

  • Server: each terminal's launch and last folder (OSC 7, read from libghostty)
    are saved with its buffer, and restore restarts every open terminal instead of
    showing it as exited. Input typed while the shell starts is queued, and a pane
    closed while it starts stops the new shell. The restart only leaves the
    alternate screen when a full-screen program had it, so plain shells keep their
    output.
  • OSC 7577: zsh and bash 4+ get a per-terminal OSC7577_TOKEN. Reports are
    verified (SHA-256 mac, 60 s window, per-pid ordering, strict parsing) and
    accepted only from processes in that terminal's tree; records end when the
    program clears them or exits (2 s grace). The resumed command runs from a
    Codevisor startup hook layered on Ghostty's shell integration, after the
    user's startup files, as a job of the shell with each argument passed intact.
    Records are saved within a second of a report.
  • processes: the tree tracker can look up a member on demand and say whether a
    process was alive recently; processCwd reads a process's directory.
  • terminal: OSC 7501 now shares an OSC scanner and base64 reader with OSC 7577.
  • Docs: the terminal protocol page describes restarts and OSC 7577.

Co-Authored-By: Claude Opus 5.5 [email protected]

…sume

After a server restart (an update, a crash, a reboot) every open terminal now
comes back under the same terminal ID: its earlier output, then a live shell in
the folder it was last in. Programs that speak the Program Resume Protocol
(OSC 7577) come back running too, in the same pane.

- Server: each terminal's launch and last folder (OSC 7, read from libghostty)
  are saved with its buffer, and restore restarts every open terminal instead of
  showing it as exited. Input typed while the shell starts is queued, and a pane
  closed while it starts stops the new shell. The restart only leaves the
  alternate screen when a full-screen program had it, so plain shells keep their
  output.
- OSC 7577: zsh and bash 4+ get a per-terminal OSC7577_TOKEN. Reports are
  verified (SHA-256 mac, 60 s window, per-pid ordering, strict parsing) and
  accepted only from processes in that terminal's tree; records end when the
  program clears them or exits (2 s grace). The resumed command runs from a
  Codevisor startup hook layered on Ghostty's shell integration, after the
  user's startup files, as a job of the shell with each argument passed intact.
  Records are saved within a second of a report.
- processes: the tree tracker can look up a member on demand and say whether a
  process was alive recently; processCwd reads a process's directory.
- terminal: OSC 7501 now shares an OSC scanner and base64 reader with OSC 7577.
- Docs: the terminal protocol page describes restarts and OSC 7577.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant