Skip to content

Re-register slept terminal sessions on wake - #5034

Closed
nwparker wants to merge 8 commits into
nwparker/term-speed-2-hidden-sync-state-resetfrom
nwparker/term-speed-2-wake-session-reregister
Closed

nwparker wants to merge 8 commits into
nwparker/term-speed-2-hidden-sync-state-resetfrom
nwparker/term-speed-2-wake-session-reregister

Conversation

@nwparker

@nwparker nwparker commented Jun 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • re-register a woken slept session in activeSessionIds and re-attach its history writer when spawn() returns the cached sleep cold-restore payload
  • add HistoryManager.reopenSession: registers the writer without deleting checkpoint.json (still the only recovery data until the next tick) and clears endedAt/exitCode so future sleep captures can cold-restore again

Why

Sleep kills the daemon PTY; the exit event closes the session history (removes the writer, sets meta.endedAt). The wake spawn() hit the coldRestoreCache early return — added for StrictMode double-mounts, where the first call had already registered everything — and skipped activeSessionIds.add plus all history re-registration. After wake:

  • markSessionDirty no-ops, so periodic checkpoints stop for the woken terminal
  • the next sleep's checkpoint() silently no-ops (no writer) and detectColdRestore returns null (endedAt set), so the second wake restores a blank terminal — post-wake scrollback is lost
  • hasPty() stays false, degrading the pty:writeAccepted path for woken panes

Both re-registrations are idempotent, so the StrictMode double-mount path is unaffected.

Validation

  • New regression test cold restores the second sleep/wake cycle with post-wake output fails without the product fix (at the hasPty assertion) and passes with it
  • pnpm exec vitest run --config config/vitest.config.ts src/main/daemon/daemon-pty-adapter.test.ts passed: 63 tests
  • npx playwright test tests/e2e/terminal-sleep-wake-restore.spec.ts --config tests/playwright.config.ts --project electron-headless --workers=1 passed 1/1 on a fresh build including this fix
  • pnpm exec oxlint on touched files passed
  • pnpm run typecheck passed
  • git diff --check passed

Made with Orca 🐋

Co-authored-by: Orca <help@stably.ai>
@nwparker
nwparker force-pushed the nwparker/term-speed-2-hidden-sync-state-reset branch from 2baaa51 to 0318394 Compare June 10, 2026 00:08
@nwparker
nwparker force-pushed the nwparker/term-speed-2-wake-session-reregister branch from 4d5410e to 8cc550e Compare June 10, 2026 00:08
nwparker added 2 commits June 16, 2026 15:23
…arker/term-speed-2-wake-session-reregister

# Conflicts:
#	src/main/daemon/history-manager.ts
@ghost

ghost commented Jun 16, 2026 •

Copy link
Copy Markdown

Ready to review this PR? Stage has broken it down into 3 individual chapters for you:

Title
1 Add reopenSession to HistoryManager
2 Re-register sessions during wake-up spawn
3 Verify multi-cycle sleep/wake restoration
Open in Stage

Chapters generated by Stage for commit b2e8cf3 on Jun 17, 2026 9:10am UTC.

@nwparker

Copy link
Copy Markdown
Contributor Author

Closing as superseded by merged PR #7214 (merge e84a8dd), which explicitly revived the complete term-speed-2 model/view chain into current main and then added newer scheduler, producer flow-control, snapshot, and reliability work. This old component/rollup branch no longer has an independent delta to rebase.

@nwparker nwparker closed this Jul 11, 2026
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