You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
O(screen) replay: headless terminal-state emulation so reconnect renders correctly without the resize nudge #1354
Goal (the deferred structural end-state from #1205)
Serve reconnecting terminal clients the current screen state (plus bounded recent scrollback) instead of a truncated raw byte stream — making reconnect render correctly for alt-screen TUIs without the post-connect resize-nudge crutch. This was #1205's acceptance criterion #2, deliberately unmet by PR #1353's capping fixes (which solved the memory crisis: bounded retention, bounded connect-time allocation, ESC-aligned cuts).
⚠️ Placement correction — supersedes #1205's own proposal
#1205 proposed running the emulator 'inside the shellper'. That placement would deliver the goal to NOBODY: terminal clients read Tower's RingBuffer on attach; the shellper's REPLAY frame only seeds Tower's buffer on adoption/reconnect — clients never see it. (Discovered during pir-1205; the arch.md correction documenting the actual data path shipped with PR #1353.)
Tower-side is the likelier home: an emulator fed by Tower's PTY data path serves every viewer attach, subsumes PR #1353's Phase-3 ring-partial capping, and needs no shellper-binary deployment (so no restart-to-benefit caveat — it applies to adopted legacy shellpers too). A shellper-side emulator would additionally shrink shellper→Tower replay itself, but as a second phase at most. The plan should settle: Tower-only vs both, emulator library choice (headless xterm / vt100 impl) vs hand-rolled state machine, per-session memory budget (cols×rows + scrollback ≈ hundreds of KB), and the failure mode when emulation desyncs (fall back to raw-tail + nudge — never worse than today).
Acceptance criteria (inherited/adapted from #1205)
Reconnect replay renders the current screen correctly for alt-screen TUIs with NO dependence on the resize nudge.
Replay payload size is O(screen), independent of session age.
Existing containment caps remain as defense-in-depth for the raw path / legacy binaries.
Fidelity fallback: emulation failure degrades to today's behavior (capped tail + nudge), detectable in logs.
Context
#1205 (closed — 3 of 4 ACs met, field crash resolved), PR #1353 (the caps + the splicing-bug fix + the exhaustive contiguity property test), PR #1204 (frame tolerance), #1047 (line-based wire contract history). SPIR-or-PIR; the emulator-library decision alone warrants the plan gate.
Activity
amrmelsayed commentedon Aug 11, 2026
On it! Working on this with the PIR protocol (plan + dev-approval gates before PR).
[PIR #1354] Plan draft
[PIR #1354] Thread log: architect review note on adoption-seeding sta…
[PIR #1354] SessionScreen.serialize(): O(screen) snapshot via @xterm/…
[PIR #1354] PtySession.replaySnapshot: flush-until-quiescent token lo…
[PIR #1354] Serve the O(screen) snapshot from both WS attach sites vi…
[PIR #1354] Seed the screen mirror from the full shellper replay on a…
[PIR #1354] Wire-level e2e: real PTY alt-screen TUI renders from the …
[PIR #1354] Update tower-websocket tests for the async snapshot attac…
[PIR #1354] Thread log: implement phase
[PIR #1354] Review + retrospective
[PIR #1354] Commit the ITerminalAddon type bridge (was working-tree o…
[PIR #1354] Consultation fixes: flush before buffer-type routing, att…
[PIR #1354] Iteration-1 consultation rebuttals
[PIR #1354] Thread log: review phase / pr gate
Merge pull request #1402 from cluesmith/builder/pir-1354
docs(release-notes): O(screen) terminal reconnect snapshots (#1354, PR …