Skip to content

O(screen) replay: headless terminal-state emulation so reconnect renders correctly without the resize nudge #1354

Closed

Description

@amrmelsayed

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

  1. added
    area/terminal
    on Aug 5, 2026
  2. amrmelsayed commented on Aug 11, 2026

    @amrmelsayed
    CollaboratorAuthor

    On it! Working on this with the PIR protocol (plan + dev-approval gates before PR).

  3. added 14 commits that reference this issue on Aug 11, 2026
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/terminal

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions