Skip to content

fix(remote-terminal): no keystroke lost, duplicated or split across a silent outage (P1-1, P1-2, P1-3) - #26630

Merged
OrcaWin merged 8 commits into
OrcaWin/phase37from
OrcaWin/p37-reliable-remote-input
Oct 9, 2026
Merged

OrcaWin merged 8 commits into
OrcaWin/phase37from
OrcaWin/p37-reliable-remote-input

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Oct 8, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 17 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​2235 $\color{#cf222e}{\Huge{\mathbf{−}}}$​31 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​2204
Prod 36 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​927 $\color{#cf222e}{\Huge{\mathbf{−}}}$​125 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​802
Files Added Deleted Net
Test 16 $

ELI5

When the network to a remote machine dies silently, Orca takes about 20 seconds to notice. Keys typed in that window went into a dead connection and were lost. Keys still waiting to be sent when Orca noticed were thrown away, so half a command reached the shell and got glued onto the next one. And keys held during "Reconnecting…" were deleted after about 3 minutes, even though the terminal later came back.

Now every key typed into a remote terminal is numbered. The remote host writes the numbers strictly in order and says which number it has reached. Orca keeps everything the host has not confirmed and sends it again from that point whenever the host asks, the connection is replaced, or confirmations stop arriving. The host skips anything it already wrote. Keys arrive once, in order, whole.

What Changed

Before (real SSH host, 65 s network black hole, one token every 0.5 s): 42 of 200 typed lines lost. 200 s black hole, one token every 2 s: 103 of 120 lost.

After (same runs on this head): 200/200 and 120/120, with no duplicates, no reordering and no split lines.

Mechanism: standard go-back-N

The pane and host negotiate an inputAck capability. A host that does not offer it gets today's unsequenced input, and the pane never resends to it.

Host (per PTY + pane input session; the ledger belongs to one host runtime):

  • It keeps one number, appliedSeq: the highest sequence whose write was confirmed. Sequenced input uses the provider's settled write, so for an SSH-backed PTY "confirmed" means the provider took the bytes, not merely queued them.
  • Frames are handled one at a time, in arrival order, from any connection:
    • seq ≤ appliedSeq: a duplicate. It is re-acked and not written.
    • seq = appliedSeq + 1: it is written. If the write is confirmed, appliedSeq advances and the host acks it.
    • Write refused, or seq beyond the next number (a gap): nothing is written, appliedSeq stays put, and the host sends a resend request carrying appliedSeq on that stream.
  • No state blocks later input. Every stream of a session is treated the same.
  • A settlement that proves no byte left the host counts as a refusal and is resent. A write that may have reached the terminal (the handoff was lost or the provider threw) is never resent, because a resent command could run twice. The host advances past it and acks it as "delivery unknown", and the pane reports that write as failed.
  • The ledger has an id. A runtime restart gets a new ledger and a new id, so the pane never replays into a ledger that has no record of what it applied.

Pane (remote-runtime-input-journal.ts, which replaces the old journal and the resend scheduler):

  • It keeps every unacked input in order, and every host ack is cumulative.
  • It resends everything after appliedSeq, in order, in three cases: a resend request (backoff from 100 ms up to 8 s), a new stream, or no ack progress for 5 s.
  • A refusal never remounts the pane. Remounts happen only when the endpoint is really lost.
  • Input that must not run is resent as an empty slot, so the host can move past it. That covers a withdrawn paste or drop, a stale query reply, and bytes past the 1 MiB retention budget (after a budget gap nothing later is replayed).
  • Cancelling a paste or drop withdraws only that operation's own sequences. Typing still in the 8 ms debounce goes out first as its own sequences, so it cannot be cancelled with the paste.
  • Accepted writes (Ctrl+C, Escape, pastes) resolve from the host ack.
  • Recovery hold: a release cut short by another outage now pauses and keeps the rest for the next release. Before, it dropped the rest. After an accepted write that a sequenced stream withdrew or could not confirm, the hold keeps delivering the typing queued behind it.

Kept from earlier rounds: capability negotiation, the ledger id, holding input under "disconnected" past the auto-recovery window, merging held keystrokes, and withdrawing a held or journaled paste when its caller's timeout (120 s per chunk) or a file drop's (30 s) fires.

The invariant, and how it is proven

The PTY receives exactly the input the pane did not withdraw, each byte once and in order. A withdrawn paste contributes nothing unless its bytes had already reached the host, and nothing typed before it is lost. Once the link is healthy everything settles, and no resends continue.

tests/e2e/remote-terminal-input-delivery-model.unit.test.ts is a seeded, deterministic, model-based test. It drives the real pane transport, multiplexer and journal against the real host RPC dispatcher and ledger, over an in-process link that injects faults. It runs 2,000 random schedules of 60 steps in about 12 s. The schedules mix the following:

  • typing, Ctrl+C, small and chunked (16–40 KiB) pastes, and withdrawn pastes
  • lost or buffered frames in either direction, and lost acks on a healthy connection
  • dead connections whose buffered input reaches the host late
  • connection replacement, an unreachable host, and host runtime restarts with the PTY surviving
  • refused writes, settlements that prove no byte left, and lost settlements whose bytes either landed or did not; thrown writes

One run covered 66,809 inputs, 1,745 withdrawals (1,348 of them before any byte reached the host), 1,589 runtime restarts, 10,318 disconnects, 2,117 late deliveries from dead connections, and 6,477 refused plus 3,353 unhanded writes. The test was also run against 20,000 schedules (1.2 M steps) during development.

A rerun with each fix reverted fails, for these fixes:

  • typing batched into the paste's sequence
  • the host advancing past a refusal
  • no stall resend
  • the hold dropping input after a cut-short release

Wire compatibility (docs: remote wire compatibility)

  • inputAck and inputSessionId are optional subscribe fields. The sequence number travels in the existing frame header.
  • InputAck (opcode 18) is sent only to clients that negotiated it. Its seq is the host's cumulative appliedSeq. An optional flag byte means "delivery unknown" (1) or "resend everything after seq" (2).
  • The opcode and the flag are new in this PR, so no released client or host uses a different meaning.
  • Old host with a new pane: unsequenced input, and no resend. New host with an old pane: no change.

Why

  • Holding keys only after detection cannot cover the roughly 20 s before it. Those bytes sit in the dead socket and the SSH buffers, and only the host knows whether they arrived. A cumulative ack plus host-side dedup is the only way to resend them without running a command twice.
  • Why go-back-N. Three review rounds kept finding new P1s in a hand-built "block after a refusal" design. Each fix added carrier, epoch and blocked-state bookkeeping, and each addition created a new way to strand input. Two examples: a replacement stream stayed blocked behind an old stream's refusal, and one transient refusal silently dropped everything typed after it. Go-back-N is the textbook reliable-delivery protocol. The receiver keeps one number and the sender keeps one ordered buffer, and there is nothing to unblock: any lost frame, lost ack, refusal or stream swap ends in "resend from N". That is why it can be proven by exhaustive random testing. It also deletes code: this round removes 122 net production lines.
  • Alternatives considered:
    • Selective repeat: more state for no benefit, since terminal input is small and ordered.
    • Shorter detection: it only narrows the window.
    • Replay without dedup: it types commands twice when the old SSH channel survives.
    • Resending writes whose delivery is unknown: it runs commands twice.

Linked Issue

Phase 3.7 network findings P1-1, P1-2 and P1-3 (adversarial real-host test), plus review-round findings 1–3. There is no separate GitHub issue.

Visual Proof

N/A. This is a behavior fix with no visual change except the banner text. The real-host evidence is below.

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

Real host on this head's production code. Setup:

  • Docker SSH fixture with iptables, a managed orcad host, and a packaged arm64 build.
  • An isolated HOME and profile, ORCA_BACKGROUND_LAUNCH=1, with tokens unset.
  • Typing through CDP into a remote pane running a timestamped read loop.
Run Base This PR
65 s black hole, 200 tokens every 0.5 s (the SSH connection was replaced) lost 42 200/200: 0 lost, 0 dup, 0 reordered, 0 mangled
200 s black hole, past the 181 s window ("Remote runtime disconnected" shown), 120 tokens every 2 s lost 103 120/120: 0 lost, 0 dup, 0 reordered, 0 mangled
Forced orcad update applied 1 s before a 40 s drop, 300 tokens every 0.5 s UD: lost 50, 1 mangled line 300/300: 0 lost, 0 dup, 0 reordered, 0 mangled
Forced orcad update started 1 s into a 40 s drop; the update applied during the outage, 300 tokens every 0.5 s — 263/300: lost 37 (#33–69, typed into the dead socket before detection), 0 dup, 0 reordered, 0 mangled

The last row is the documented limit. The runtime restarted while those 37 keys were unconfirmed, so the pane cannot tell whether the old runtime wrote them, and it drops them rather than risk running them twice. Keys typed after detection were held and all arrived.

Unit and integration tests. Each one ports a finding from rounds 1–3 or covers the new design:

  • terminal-input-sequence-ledger.test.ts:
    • in-order serial writes, with duplicates settled after the original
    • a refusal resent on the same stream while later typing keeps flowing
    • a replacement stream whose replay raced a refusal is written, not stranded
    • a late dead-connection frame after a gap is never written early
    • delivery-unknown advances and is never retried
    • sessions scoped per PTY, LRU eviction, and a distinct ledger id per runtime
  • terminal-multiplex-input-sequence-replay.test.ts:
    • exactly-once across a dead connection and its replacement
    • a refusal sends a resend request, not WriteUnavailable
    • writes are settled, and an unverifiable handoff is acked as delivery-unknown
    • an unhanded settlement is resent
    • legacy clients stay unsequenced
  • remote-runtime-input-journal.test.ts:
    • resend fills withdrawn slots and query-reply slots
    • backoff, the stall resend, and delivery-unknown handling
    • no replay across a ledger or endpoint change, or past a budget gap
    • a failed send is resent on the next stream
  • remote-runtime-pty-transport-input-replay.test.ts:
    • P1-1, P1-2, P1-3, Ctrl+C order, and the validating paste
    • no replay into a restarted runtime
    • a held or journaled paste is withdrawn on timeout
    • typing before a timed-out paste is kept
    • a refusal is resent without a remount, even after many refusals
    • chunk 1 and chunk 2 send failures keep earlier typing
  • remote-runtime-recovery-input-hold.test.ts: a release cut short by an outage resumes, and typing continues after a withdrawn or unconfirmed accepted write.
  • paired-runtime-rejected-input-remount.unit.test.ts: the end-to-end remount on a refusal now runs on a stream that did not negotiate inputAck, which is the only kind that still remounts.

Checks:

  • pnpm tc, oxlint, pnpm run check:code-quality:changed and pnpm run audit:anti-slop are clean.
  • These pass: src/renderer/src/components/terminal-pane, src/renderer/src/runtime, src/main/runtime/rpc, the tests/e2e unit tests, and the cross-version terminal wire suite.

Platforms: macOS desktop against a Linux SSH host. No platform-specific code.

Review

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • SSH: this is the SSH and remote path. The execution boundary is unchanged, and no live/unverifiable/exited verdict changes. A settlement that may have written is treated as unverifiable, never as a refusal.
  • Mobile: mobile clients never advertise inputAck.
  • Folder workspaces: not affected.
  • Known limits:
    • A host runtime restart during an outage drops unconfirmed input instead of replaying it (see the last real-host row).
    • More than 1 MiB of unconfirmed input in one outage replays nothing past the gap.
    • A write whose delivery is unknown is reported as failed and never resent.
    • A pane remounted mid-outage starts a new input session.
  • Only the retryingBody text changed in the copy (French fixed too).

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@OrcaWin
OrcaWin requested a review from brennanb2025 as a code owner October 8, 2026 17:17
@OrcaWin
OrcaWin force-pushed the OrcaWin/p37-reliable-remote-input branch 2 times, most recently from 3efd214 to 9212b6c Compare October 9, 2026 06:15
m4air and others added 7 commits October 9, 2026 00:35
… silent outage

Remote pane input was fire-and-forget: keys handed to a socket that had
silently died were gone, keys still in the 8 ms debounce at detection were
cleared, and held keys were discarded when the auto-recovery window ran out.

- New negotiated `inputAck` capability: the client names an input session
  and sequences Input frames (existing frame header `seq`); the host records
  the last applied sequence per (PTY, session) across connections, writes
  each sequence once and acks it with new opcode InputAck (18), sent only
  to clients that advertised the capability.
- The pane keeps sent-but-unacked input and replays it to the same
  terminal on reattach; the host dedupes. Old hosts keep current behavior.
- Debounced and claim-queued input at detection is held, not cleared.
- Held input survives the 'disconnected' phase; the hold coalesces keys so
  minutes of typing do not hit the per-entry cap.
- Banner copy no longer claims a one-minute retry window.

Fixes P1-1, P1-2, P1-3 (phase 3.7 network findings).
…l+C and validating paste in order

- Host publishes inputLedgerId with inputAck; the client drops unacknowledged input sent to a
  different ledger (runtime restart with the same PTY) instead of running it twice.
- A replayed duplicate is acked only after the original write settles.
- Accepted input (Ctrl+C, Escape, paste) rides the sequenced stream and resolves on the host ack.
- Keys typed while held queue behind a paste still in size validation.
…aller gave up on

- Host ledger records each write's outcome: a refused write is rolled back and
  never acked, so the client's replay writes it; nothing queued behind it runs or
  is acked. A write that threw is acked as delivery-unknown, so the client
  reports it failed and never replays it.
- Paste and file-drop timeouts abort their accepted write: a copy still held for
  an outage is withdrawn, and a journaled copy is left out of the replay.
- A batch of sequenced input keeps one endpoint and ledger, so a send that
  retires the stream mid-batch no longer discards earlier unacked input.
…nd asks the live stream to resend after a refusal

- The ledger admits only the next sequence; a refusal or gap answers with an InputAck resend request instead of WriteUnavailable, so the pane keeps its journal and resends on the same stream (no remount, no carrier bookkeeping).
- Sequenced input uses the provider's settled write; an unverifiable handoff is delivery-unknown, not refused.
- Replays fill given-up slots with empty input so the host can continue; the client remounts only after every resend backoff is refused.
- Typing batched ahead of a paste goes out as its own sequences, so cancelling the paste keeps it.
…ack-N

Replace the hand-built "block on refusal" bookkeeping with go-back-N:

- Host: per (PTY, input session) the ledger keeps only appliedSeq, the
  highest contiguous confirmed write. Frames run one at a time in arrival
  order: a duplicate is re-acked, the next sequence is written and acked
  on confirmed success, and a refusal or gap is answered with a resend
  request carrying appliedSeq. No blocked state; every stream is equal.
  A settlement that proves no byte left is a refusal; one that may have
  written advances as delivery-unknown and is never retried.
- Client: one journal keeps unacked input in order and resends from
  appliedSeq + 1 on a resend request (with backoff), on a new stream, or
  when acks stall. Refusals never remount the pane. Withdrawn pastes,
  stale query replies and over-budget bytes resend as empty slots.
- The recovery hold pauses (keeps the rest) when a release is cut short
  by another outage, and keeps delivering typing after an accepted write
  a sequenced stream withdrew or could not confirm.
- Add a seeded model-based test that drives the real pane transport,
  multiplexer and journal against the real host dispatcher and ledger
  through 2,000 random fault schedules.
…sequenced input

A sequenced stream now resends refused input on the same stream instead of remounting, so the end-to-end remount check negotiates no inputAck, as an older peer does.
@OrcaWin
OrcaWin force-pushed the OrcaWin/p37-reliable-remote-input branch from 8b8614b to 864ae37 Compare October 9, 2026 07:36
…once recovery gives up, and never report a lost unknown ack as applied

- The pane falls back to its remount path when the host keeps refusing input past the resend backoff ladder.
- Held and journaled input is discarded when auto-recovery gives up, and input typed under the disconnected banner is not held.
- The host ledger answers a duplicate for its own sequence and remembers delivery-unknown outcomes; the client settles a write as applied only from its own ack.
- The input model now requires a write reported applied to have reached the PTY whole, and covers a refusal that never clears.

Co-Authored-By: Claude <noreply@anthropic.com>
@OrcaWin
OrcaWin merged commit 64d3f55 into OrcaWin/phase37 Oct 9, 2026
86 of 89 checks passed
OrcaWin added a commit that referenced this pull request Oct 9, 2026
…for the same terminal, within a bounded grace (P1-3) (#26832)

The last round of #26630 discarded held and journaled input as soon as auto-recovery gave up,
and refused input under the disconnected banner. On a real host a 200 s outage lost 102 of
120 keystrokes, although the pane reattached the same terminal on its own seconds later.

Input now stays held for the same handle and incarnation while the pane is disconnected, for
up to 5 minutes after it gave up. Past that grace it is discarded, and typing into the dead
pane is refused, so stale keys never run at an arbitrary later reconnect. The grace is a
timestamp checked when input moves, so a latched pane stays free of timers.

Co-authored-by: m4air <m4air@Mac.localdomain>
Co-authored-by: Claude <noreply@anthropic.com>
OrcaWin added a commit that referenced this pull request Oct 9, 2026
…ting (#26847)

* fix(remote-terminal): keep a reconnected pane's size after an SSH outage (P1-4) (#26625)

* fix(remote-terminal): keep a reconnected pane's grid when its stale stream is reaped (P1-4)

The host's width floor only handed ownership to viewers that had claimed
since subscribing. A reconnecting desktop pane re-subscribes without
claiming, so when the heartbeat later reaped the dead socket that owned the
floor, the host reclaimed the PTY to its spawn size (120x40) and held the
pane there. The owner's same-client replacement stream now inherits the
floor, and a pane whose stream was reaped before it reconnected resumes
ownership on re-register unless the host or another viewer claimed since.

* fix(remote-terminal): host typing during an outage revokes the reaped owner's resume

Host input reaches the PTY without a renderer viewport claim once the host has
reclaimed its grid, so the orphaned-owner entitlement survived and a passive
reconnect resized the host pane back to the remote grid. The host write path
now clears that entitlement on driving input (query replies, focus reports and
launch writes excluded).

* test(pty): stub the runtime's host-input note in write-path handler tests

---------

Co-authored-by: m4air <m4air@Mac.localdomain>

* fix(remote): an oversized RPC reply fails that request instead of closing the host connection (#26624)

Expanding a folder with ~80k entries on a managed SSH host produced a
files.readDir reply over the 4 MiB encrypted-reply cap. The channel treated
that as a transport fault and closed the whole control socket (1013), and the
explorer rendered the failed folder as empty.

- The WebSocket RPC transport now answers an over-cap reply with a
  reply_too_large error for that request id, so the channel never sees it.
- files.readDir checks remote listings against the request's content budget
  and names the entry count.
- The explorer shows a subfolder's read error on its expanded row.

Finding: HH-2 (Phase 3.7 hostile-host).

Co-authored-by: m4air <m4air@Mac.localdomain>

* fix(ssh): let a slow host finish installing the pinned Node runtime (HH-3) (#26631)

* fix(ssh): let a slow host finish installing the pinned Node runtime

The POSIX promote (extract, hash, self-test and publish the ~110 MiB node
binary) ran under the 30 s default exec timeout. On slow home storage it
timed out, the remote work kept running, and the runtime store lock it held
stayed until the 20-minute stale rule, so relay rung A queued behind it past
its own deploy bound.

Give both platforms the 300 s promote bound and have the host release the
store lock itself when the promote exits, with owner-checked releases so a
late release never removes a lock someone else took. (HH-3)

* fix(ssh): let the host release the store lock after a slow under-lock re-hash

The under-lock re-check of a sibling-published runtime hashed the ~110 MiB
executable as its own command under the 30 s exec default and outside the
host-side lock release. On slow storage it timed out, the client correctly
kept the lock, and nothing on the host freed it until the 20-minute stale
rule, so later installers ran out their deploy bound.

Run the re-hash and the conditional promote as one host command wrapped in
the host release, and give every full-runtime hash, including the initial
probe, the slow-storage bound. (HH-3)

* test(ssh): count the combined under-lock re-probe and promote as one host command

---------

Co-authored-by: m4air <m4air@Mac.localdomain>

* fix(ssh): shell startup output on stdout no longer breaks SSH connect (HH-1) (#26617)

* fix(ssh): fence captured exec stdout so shell rc output cannot break connect

sshd runs the user's login shell before Orca's /bin/sh wrapper, so any
startup-file stdout (fish/tcsh/zsh/bash echo, or a bare terminal-title escape)
was glued onto every captured answer. The home probe read "banner\n/home/u"
and connect failed with "Remote home is not a valid path".

execCommand now wraps wrapped POSIX commands in a per-call nonce fence and
returns only the payload between the markers; the SSH folder browser gets the
same fence. The fence is the existing WSL captured-login-shell fence, moved to
src/shared/posix-stdout-fence.ts so both transports share it.

Finding: HH-1 (phase 3.7 hostile-host). Refs #8324.

* fix(ssh): fence the login-shell Node probe and fall back from a noisy SFTP handshake

The login-shell 'command -v node' probe ran unwrapped, so output from sshd's
shell and the nested login profile became the Node path. It now prints a
one-line fence every login shell parses, inside that shell.

An external sftp-server is started through the user's shell, so startup output
corrupts the SFTP handshake. ssh2 reports that parse failure only before the
session is ready, so SshConnection.sftp tags it, and relay install transfers
treat it as SFTP unavailable and stream over exec stdin.

Finding: HH-1 follow-up (phase 3.7 hostile-host). Refs #8324.

* fix(ssh): keep the stdout fence marker out of the command text

The runtime-store inventory lists processes with ps, which prints its own
script, so a literal marker in the script was read as the fence and the
store GC skipped every pass. printf now joins the marker from two halves.

---------

Co-authored-by: m4air <m4air@Mac.localdomain>

* fix(orcad): finish an abandoned update on connect, and refresh renderers after a main-side re-pair (P1-A, P1-C) (#26635)

* fix(orcad): finish an update or rollback its client abandoned, and tell renderers about main-side re-pairs

P1-A: a wake that finds the activation fence now runs crash recovery, which takes
only a stale, previous-boot or exited-own fence. Recovery of an activation
interrupted after the candidate launched resumes it: the candidate commits if it
passes the readiness gate, else the activation is undone as before.

P1-C: invalidating a still-linked environment's transport restarts its status
owner, and a renderer that sees status under a newer pairing revision re-reads
the catalog before applying it.

* fix(orcad): a resumed update keeps the app version that started it

Recovery that commits an abandoned candidate stamped no activeAppVersion, so an
older desktop read the host as pre-tracking and downgraded it over state the
newer build had migrated. The activate journal now records the initiating app
version; recovery stamps it, and a journal too old to carry it is undone instead
of committed.

* test(runtime-env): answer nothing for the status restart a re-pair now triggers

* fix(orcad): recovery leaves running an update server a too-old journal cannot commit

A journal without candidateAppVersion was sent to undo, which stopped a
healthy candidate that had already migrated state and then refused to
restart the incumbent, leaving the host serving nothing. Refuse instead,
keeping the fence and the candidate, until the operator accepts Restore.

---------

Co-authored-by: m4air <m4air@Mac.localdomain>

* fix(terminal): a remote recovery never splices stale history above the new screen (P2-5, P2-7) (#26647)

* fix(terminal): a remote recovery never splices stale history above the new screen

A pushed remote snapshot (overflow recovery, seq-gap resync, first attach) is
sent because the client's stream broke, so the pane's own history ends before
that image. Since #26319 a screen-only image kept that history, splicing a
stale block directly above the final screen with a silent gap of up to ~270k
lines (P2-5), and a first attach to an older host left silent holes (P2-7).

- Host: the ACK-overflow recovery serializes up to 1000 history rows.
- Client: the seq-gap resync asks for the same 1000 rows.
- Client: a pushed snapshot always replaces the pane's scrollback; the
  keep-local-scrollback path is removed. A screen-only image from an older host
  now shows only its screen, which is lossy but never misleading.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix(terminal): a pushed image replaces the normal buffer over a live alt screen too

Over a pane already on the alternate screen, an image that also ended on alt
repainted only its alt frame and kept the pane's normal buffer, inferring the two
had frozen together. Inside the gap the TUI can exit, the shell print and a second
TUI start, so once that TUI exited the pane showed its stale history where the host
had the missed output. A pushed image now always rebuilds the normal buffer and
history from the host before entering alt itself.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix(terminal): bound recovery history by link slack and keep pre-TUI scrollback under screen-only images

A recovery that carries history now goes out only when the stream's ACK
window has drained; under a sustained flood recoveries stay screen-only and
the owed history follows once the client catches up, so snapshot bytes no
longer outgrow the client's intake.

A pushed image without history (scrollbackRows absent or 0) over a live alt
screen repaints only the alt frame again, so a reconnect to an older host
no longer wipes the pane's pre-TUI scrollback.

---------

Co-authored-by: m4air <m4air@Mac.localdomain>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix(source-control): Stage All stages every change when the listing hit the 1,000 cap (HH-4) (#26618)

* fix(source-control): Stage All stages every change when the listing hit the 1,000 cap

The status listing stops at 1,000 rows, but Stage All built its path list
from those rows, so it staged 1,000 of 20,000 changes and the next commit
was silently partial. When the listing is capped, Stage All (and the
Changes header Stage all) now asks the host to stage the whole worktree
via an optional scope on git.bulkStage; unresolved conflicts stay
unstaged. Older hosts ignore the field and stage the listed paths.

Fixes HH-4.

* fix(source-control): whole-worktree Stage All needs a host receipt, skips shared links, and reaches mobile

- Scoped stage sends no paths and requires a stagedScope receipt, so an older
  runtime or relay stages nothing and the client reports it instead of a
  silent partial stage.
- Scoped 'all' skips Orca's shared symlinks (configured and really a link),
  matching the status listing.
- The capped-listing banner offers Stage All, reachable when the visible
  prefix is entirely staged.
- Mobile reads didHitLimit and uses the same scoped stage and receipt.

* test(source-control): type the Stage All test stubs so lint and the mobile test typecheck pass

* fix(source-control): match Shared Paths saved as ./name or name/ against git's spelling

The Shared Paths setting keeps entries as typed, but git prints worktree paths
without a leading ./ or trailing /. Stage All's conflict path compared the raw
spelling to git's untracked list and staged the shared node_modules link, and
an exclude pathspec ending in / made git refuse the add after tracked changes
were already staged. Status listing had the same mismatch. getSafeRelativePath
now returns git's spelling, so every caller gets it, including saved settings.

---------

Co-authored-by: m4air <m4air@Mac.localdomain>

* fix(ssh): redeploy a managed server another desktop stopped; forget one whose host is gone (P1-D, P1-E) (#26628)

* fix(ssh): redeploy a server another desktop stopped; let a dead managed host be forgotten

P1-D: a connect whose linked server the host reports as not activated (another desktop
stopped it) now goes on to the update check, which redeploys it in place.
P1-E: add Forget (managedServer.forget, orca environment forget, Settings row) that runs
Stop's local unlink without contacting the host; the verdict stays unverifiable.

* test(ssh): type the forget test's hoisted store without an assertion

* fix(ssh): never downgrade a stopped host; redeploy it mid-session and retry after a failure

A stop now keeps the stopped build's Orca version, so an older desktop's
reconnect skips as host-newer instead of starting an older server on a
store a newer build migrated. A stop recorded without that version is not
guessed at. A stopped host retries the redeploy on each connect instead of
the once-per-version failure suppression, and a runtime call that finds
the server stopped mid-session redeploys it before the call.

* fix(ssh): rebuild the managed forward after redeploying a stopped host

A redeploy can bind a different port than the reused forward targets.

* fix(ssh): keep stop journals readable by older desktops and recheck version policy under the fence

- The stop journal's recordAfter is the core deactivated record older peers compute; the
  committed record keeps activeAppVersion (which released planners already honour) and
  rolledBackFrom, rebuilt from recordBefore on recovery.
- Auto-update re-applies its version policy to the record read under the host fence, and a
  census counted against another incumbent is treated as unverifiable.

* fix(ssh): file a dispatched stop where older desktops cannot commit it, so their recovery never drops the version guard

* fix(ssh): refuse a fresh deploy of an older orcad onto a host a newer desktop stopped

The unlinked deploy path never consulted the stopped record's activeAppVersion, so a desktop
without a link to the host could activate its older build over state a newer build migrated.
Both the auto-update planner and the fresh deploy now apply one downgrade rule under the fence.

---------

Co-authored-by: m4air <m4air@Mac.localdomain>

* fix(ssh): redeploy a managed server a pre-version Stop left; let a forced deploy run over a newer one (#26766)

A stopped activation record without activeAppVersion is what every Stop on
main writes, so refusing it stranded those hosts behind an unforceable
policy refusal. Only a provably newer host is now refused; a forced fresh
deploy runs this version anyway, and the refusal names both versions.

Co-authored-by: m4air <m4air@m4airs-MacBook-Air.local>

* fix(remote-terminal): no keystroke lost, duplicated or split across a silent outage (P1-1, P1-2, P1-3) (#26630)

* fix(remote-terminal): no keystroke lost, duplicated or split across a silent outage

Remote pane input was fire-and-forget: keys handed to a socket that had
silently died were gone, keys still in the 8 ms debounce at detection were
cleared, and held keys were discarded when the auto-recovery window ran out.

- New negotiated `inputAck` capability: the client names an input session
  and sequences Input frames (existing frame header `seq`); the host records
  the last applied sequence per (PTY, session) across connections, writes
  each sequence once and acks it with new opcode InputAck (18), sent only
  to clients that advertised the capability.
- The pane keeps sent-but-unacked input and replays it to the same
  terminal on reattach; the host dedupes. Old hosts keep current behavior.
- Debounced and claim-queued input at detection is held, not cleared.
- Held input survives the 'disconnected' phase; the hold coalesces keys so
  minutes of typing do not hit the per-entry cap.
- Banner copy no longer claims a one-minute retry window.

Fixes P1-1, P1-2, P1-3 (phase 3.7 network findings).

* fix(remote-terminal): never replay into a restarted runtime; keep Ctrl+C and validating paste in order

- Host publishes inputLedgerId with inputAck; the client drops unacknowledged input sent to a
  different ledger (runtime restart with the same PTY) instead of running it twice.
- A replayed duplicate is acked only after the original write settles.
- Accepted input (Ctrl+C, Escape, paste) rides the sequenced stream and resolves on the host ack.
- Keys typed while held queue behind a paste still in size validation.

* fix(remote-terminal): parse subscribed capabilities into a typed shape instead of Reflect.get

* fix(remote-terminal): ack only applied input; withdraw writes their caller gave up on

- Host ledger records each write's outcome: a refused write is rolled back and
  never acked, so the client's replay writes it; nothing queued behind it runs or
  is acked. A write that threw is acked as delivery-unknown, so the client
  reports it failed and never replays it.
- Paste and file-drop timeouts abort their accepted write: a copy still held for
  an outage is withdrawn, and a journaled copy is left out of the replay.
- A batch of sequenced input keeps one endpoint and ledger, so a send that
  retires the stream mid-batch no longer discards earlier unacked input.

* fix(remote-terminal): host writes sequenced input strictly in order and asks the live stream to resend after a refusal

- The ledger admits only the next sequence; a refusal or gap answers with an InputAck resend request instead of WriteUnavailable, so the pane keeps its journal and resends on the same stream (no remount, no carrier bookkeeping).
- Sequenced input uses the provider's settled write; an unverifiable handoff is delivery-unknown, not refused.
- Replays fill given-up slots with empty input so the host can continue; the client remounts only after every resend backoff is refused.
- Typing batched ahead of a paste goes out as its own sequences, so cancelling the paste keeps it.

* refactor(remote-terminal): deliver sequenced input with standard go-back-N

Replace the hand-built "block on refusal" bookkeeping with go-back-N:

- Host: per (PTY, input session) the ledger keeps only appliedSeq, the
  highest contiguous confirmed write. Frames run one at a time in arrival
  order: a duplicate is re-acked, the next sequence is written and acked
  on confirmed success, and a refusal or gap is answered with a resend
  request carrying appliedSeq. No blocked state; every stream is equal.
  A settlement that proves no byte left is a refusal; one that may have
  written advances as delivery-unknown and is never retried.
- Client: one journal keeps unacked input in order and resends from
  appliedSeq + 1 on a resend request (with backoff), on a new stream, or
  when acks stall. Refusals never remount the pane. Withdrawn pastes,
  stale query replies and over-budget bytes resend as empty slots.
- The recovery hold pauses (keeps the rest) when a release is cut short
  by another outage, and keeps delivering typing after an accepted write
  a sequenced stream withdrew or could not confirm.
- Add a seeded model-based test that drives the real pane transport,
  multiplexer and journal against the real host dispatcher and ledger
  through 2,000 random fault schedules.

* test(remote-terminal): cover the refusal remount on a stream without sequenced input

A sequenced stream now resends refused input on the same stream instead of remounting, so the end-to-end remount check negotiates no inputAck, as an older peer does.

* fix(remote-terminal): escalate persistent input refusals, drop input once recovery gives up, and never report a lost unknown ack as applied

- The pane falls back to its remount path when the host keeps refusing input past the resend backoff ladder.
- Held and journaled input is discarded when auto-recovery gives up, and input typed under the disconnected banner is not held.
- The host ledger answers a duplicate for its own sequence and remembers delivery-unknown outcomes; the client settles a write as applied only from its own ack.
- The input model now requires a write reported applied to have reached the PTY whole, and covers a refusal that never clears.

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: m4air <m4air@Mac.localdomain>
Co-authored-by: m4air <m4air@m4airs-MacBook-Air.local>
Co-authored-by: Claude <noreply@anthropic.com>

* fix(remote-terminal): keep input typed past the auto-recovery window for the same terminal, within a bounded grace (P1-3) (#26832)

The last round of #26630 discarded held and journaled input as soon as auto-recovery gave up,
and refused input under the disconnected banner. On a real host a 200 s outage lost 102 of
120 keystrokes, although the pane reattached the same terminal on its own seconds later.

Input now stays held for the same handle and incarnation while the pane is disconnected, for
up to 5 minutes after it gave up. Past that grace it is discarded, and typing into the dead
pane is refused, so stale keys never run at an arbitrary later reconnect. The grace is a
timestamp checked when input moves, so a latched pane stays free of timers.

Co-authored-by: m4air <m4air@Mac.localdomain>
Co-authored-by: Claude <noreply@anthropic.com>

---------

Co-authored-by: m4air <m4air@Mac.localdomain>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-authored-by: m4air <m4air@m4airs-MacBook-Air.local>
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