Skip to content

(sessions): persist open sessions and restore them on restart - #80

Merged
JeanBaptisteRenard merged 1 commit into
mainfrom
feat/session-restore
Jun 17, 2026
Merged

(sessions): persist open sessions and restore them on restart#80
JeanBaptisteRenard merged 1 commit into
mainfrom
feat/session-restore

Conversation

@JeanBaptisteRenard

Copy link
Copy Markdown
Collaborator

What

Switchboard now remembers which Claude sessions were open when it last closed, and re-opens them on the next launch. Each is resumed in turn via claude --resume, so the conversation history is intact (it lives in the JSONL on disk — Switchboard just re-clicks the sessions for you).

Configurable via a new global setting Restore Sessions on Startup:

Option Behavior
off Don't restore
ask (default) Show a non-modal toast: "Restore N session(s) from last time?"
auto Restore silently on launch

How

  • The open working set ({sessionId, projectPath, options, active} per open Claude session, in open order) is persisted to the global.openWorkingSet setting.
  • Written incrementally on open / close / exit / fork — not only at quit — so it survives a crash/SIGKILL.
  • Persist uses a serialized read-modify-write (_persistChain) so it can't clobber other global keys (windowBounds, sidebarWidth, …).
  • Restore is strictly sequential (awaited per session + small stagger) to avoid spawning N claude --resume processes at once.
  • Plain shell sessions are excluded — their process/shell state can't be meaningfully resumed.
  • Guards: skips sessions no longer indexed (deleted JSONL / missing project / vanished worktree), skips already-open and closed/exited sessions.

Scope & safety

Renderer-only (public/app.js, public/settings-panel.js, public/style.css) — no main.js / native-module changes.

Tests

test/session-restore.test.js — 20 tests (jsdom harness): working-set build (order, plain-terminal & closed exclusion, key-preserving RMW), runRestore (sequential ordering proven via deferred promises, skip-missing, skip-open, activate-marked), and mode gating (off/ask/auto + toast button). task check green: 354 pass, 0 fail.

Switchboard now remembers which Claude sessions were open and re-opens
them on the next launch — each is resumed in turn via `claude --resume`,
so the conversation is intact. Plain shell sessions are excluded (their
process state can't be restored).

The open working set is persisted to the `global.openWorkingSet` setting
(serialized read-modify-write so it can't clobber other global keys),
updated incrementally on open/close/exit/fork rather than only at quit,
so it survives a crash. Restore is gated by a new `restoreOnStartup`
setting with three options: off / ask (default) / auto. In ask mode a
non-modal toast offers to restore; auto restores silently. Restore is
strictly sequential to avoid spawning N claude processes at once.

Renderer-only change.
@JeanBaptisteRenard
JeanBaptisteRenard merged commit 65bd884 into main Jun 17, 2026
7 checks passed
@JeanBaptisteRenard
JeanBaptisteRenard deleted the feat/session-restore branch June 17, 2026 12:13
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