Skip to content

Gate PTY delivery to hidden terminal views#5135

Closed
nwparker wants to merge 11 commits into
nwparker/term-speed-2-side-effect-cleanupfrom
nwparker/term-speed-2-hidden-delivery-gate
Closed

Gate PTY delivery to hidden terminal views#5135
nwparker wants to merge 11 commits into
nwparker/term-speed-2-side-effect-cleanupfrom
nwparker/term-speed-2-hidden-delivery-gate

Conversation

@nwparker

@nwparker nwparker commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Summary

Phase 4 of the terminal model/view architecture: main stops sending PTY bytes to hidden terminal views entirely.

  • hiddenRendererPtys gate in pty.ts: bytes for hidden views are dropped after model ingestion (never queued) — the headless model owns them and reveal reconciles via snapshot+seq; SSH relay parity in wireUpPtyEvents
  • ref-counted delivery-interest registry: byte-needing sidecars (paste-draft readiness, background launches, automation observers) keep delivery automatically through their existing subscribeToPtyData registrations; the codex 10s startup query window stays exempt
  • parked tabs and hidden mounted panes set/clear the hidden bit with strict ordering (unhide before restore); mode-2031 subscribes become a fact from main's tracker with the renderer replying — fixing today's post-latch subscribe drop — and ownership is structural (isHiddenDeliveryGateManagedPty: fact is the sole responder for gated panes)
  • new out-of-band pty:modelRestoreNeeded IPC replaces any in-band signaling (an OSC-9999-only chunk can strip to empty — it must never masquerade as a restore marker)
  • restore reconciliation hardened: main reports pendingDeliveryStartSeq with each snapshot so the renderer arms a duplicate-suppression baseline only for a real undelivered window; seq-continuity gap detection forces a fresh snapshot when the pending-cap trims behind a completed restore
  • the previously-unbounded pendingData growth under ACK starvation is capped (2 MB oldest-drop + restore marker), gated on the same kill switches; switches-off is byte-identical to today
  • dual kill switches: terminalMainSideEffectAuthority AND new terminalHiddenDeliveryGate (default on), read main-side

Review hardening (3-lens adversarial review + deterministic e2e regression fix, all red-verified)

  • in-band marker/OSC-9999 collision eliminated (spurious visible repaints)
  • post-restore backlog duplication and gap-blind drains fixed via the reported pending window + continuity detection; a follow-up e2e regression (baseline misreading foreign seq domains) was root-caused to the missing empty-backlog invariant and fixed by never arming a baseline without a real window
  • 2031 fact registers the pane's mode-2031 subscription so theme flips push after reveal; reply ownership races eliminated structurally
  • drop memory survives hidden remount/reload cycles (mark never clears; unmark is the sole consumer); renderer-scoped gate state resets on reload/crash

Validation

  • typecheck clean; oxlint clean; 1,020+ unit tests green across the gate, connection, transport, watcher, runtime, and SSH suites (red-verified per fix)
  • e2e on fresh builds: hidden TUI visual restore 4/4 (incl. the regression's solo repro), parking 3/3, parked memory 2/2, attention, sleep/wake, long-table — 12-17 per sweep; artificial-opencode hidden/cross-workspace/revisit pressure 6/6 under the new byte-free contract (hidden bytes die in main: mainHiddenDroppedChars carries the evidence, renderer queues ~0); golden 2/2
  • perf annotations now expose mainHiddenGatedPtys/mainHiddenDroppedChars/mainPendingDroppedChars for the over-time report

Cut-off

Independently mergeable; completes the Phase 3–4 arc. Phase 5 (model query authority for hidden panes, design committed next) is the final behavioral phase before the skip-grammar deletion.

Made with Orca 🐋

nwparker and others added 2 commits June 10, 2026 17:10
Co-authored-by: Orca <help@stably.ai>
…r/term-speed-2-hidden-delivery-gate

# Conflicts:
#	src/preload/api-types.ts
#	src/preload/index.ts
#	src/renderer/src/components/terminal-pane/pty-connection.ts
@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