Skip to content

Keep SSH terminals parked after their own workspace updates - #23193

Merged
OrcaWin merged 4 commits into
mainfrom
fix/ssh-snapshot-echo-parking
Sep 26, 2026
Merged

OrcaWin merged 4 commits into
mainfrom
fix/ssh-snapshot-echo-parking

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Sep 26, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​579 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​578
Prod 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​63 $\color{#cf222e}{\Huge{\mathbf{−}}}$​17 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​46

ELI5

When an SSH workspace notification has to be fetched again, Orca can mistake its own accepted update for a change from another device. That reloads background terminals unnecessarily. This change recognizes the accepted update and keeps those panes parked.

What Changed

Compare the fetched workspace with the current cached session before replacing that cache. Previously the comparison captured the cache before waiting, so a local patch acknowledged during the wait was missed.

If another observation arrives while the read or delivery is pending, preserve it and reread any conflicting response. Comparing complete snapshots catches both peer changes and own acknowledgements that retain the same authorization token. A quiet read may still accept a lower revision after a relay reset. The ordinary snapshot reader keeps its existing behavior; stale-notification recovery uses the same reader with a synchronous comparison/cache callback.

The regression crosses the real main-process cache/read path, renderer hydration and parking hook. Four own acknowledgements during pending reads leave both panes parked. A distinct peer edit still applies. With the old production files, the first own echo unparks both panes and fails the test.

Why

This removes a demonstrated producer of unnecessary remounts. Extending parking timers would only reduce how often the reload happens. Comparing after the fetched snapshot had already replaced the cache would hide genuine peer changes, so comparison and cache update happen together in the read continuation. Concurrent changes trigger a fresh read instead of relying on revision numbers that can reset.

Linked Issue

Root-cause follow-up to #20851 and the later direct-SSH crash-scan reports. This proves the race and its parking consequence; the historical bundle lacks the stale-notification records needed to attribute every reported churn episode to it.

Visual Proof

N/A — background pane lifecycle change, with no layout or appearance change. The integration test supplies before/after lifecycle assertions: old code unparks both panes on the first own echo; fixed code preserves parking across four echoes and still applies a peer edit. PTY transport attachment is simulated through the real store action; no fresh live-SSH recording is claimed.

Testing

  • Reproduced and verified locally with background test execution on macOS.
  • Automated regression coverage added.

Final focused run on a780dc4dab: 46 tests passed across 6 suites, including real-multiplexer frame ordering and the cross-layer parking regression. Node typecheck and changed-code quality pass; prior web and targeted integration typechecks pass.

Controls cover peer/own notifications in both decoder orders, later acknowledgements before delivery, same-revision peer changes, legitimate relay resets, queued markers, independent targets and own echoes before/during reads. The three same-token regressions fail on the preceding revision (two cache rewinds and one stale delivery), then pass with the fix. Final independent review found no remaining blocker. Head CI unit shards, static analysis, typechecks and packaging pass. Live Docker SSH watcher isolation and terminal parking/startup stages also pass; the broader remaining Docker SSH suite is still running.

Review

Merge risk: low, pending head CI. Three production files change; no new protocol fields, timers, listeners or retained state. The main risks are stale delivery or suppressing a genuine remote change, covered by ordering, peer and target-isolation cases. Conflicting concurrent changes can add a serialized reread. Full PR CI remains a required check before a merge is proposed as ready.

Agent skill upstream boundary

  • Not applicable; no upstream skill source copied.

Notes

The execution host remains authoritative. Mixed-version messages and provider error behavior are unchanged. The fix operates on target-scoped session content and does not assume a Git worktree. Local and paired-runtime terminal paths are unchanged.

This does not claim to resolve all historical crashes, eliminate every reason for remote hydration, or remove #20851's existing mitigation.

Checklist

  • Small production change with a failing-before regression
  • Explained user behavior, mechanism and alternatives
  • Self-reviewed; independent review identified and drove the ordering regressions
  • Final independent review passes
  • Cross-platform, SSH, folder workspace and wire compatibility considered
  • Focused tests, types and changed-code quality pass
  • Full PR CI passes

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

The stale-resync reordering fixes the own-echo case but introduces a new way to deliver (and cache) an older snapshot over a newer one. Details inline.

Reviewed changes

  • Compare at receipt — resyncStaleRemoteWorkspace no longer captures the cached session before awaiting; the new readRemoteSnapshot receive callback captures previous and caches the fetched snapshot in one synchronous step, so a local patch reply that lands during the pending read is recognized as the same session.
  • Thin wrapper preserved — getRemoteSnapshot now delegates to readRemoteSnapshot with the same rememberRemoteWorkspaceSnapshot behavior, so ordinary readers are unchanged.
  • Regression coverage — new unit cases (own vs peer during pending read, pre-marker ack, queued peer after suppressed echo, cross-target isolation, read-before-later-own-reply) plus a new happy-dom cross-layer parking test that keeps panes parked through four own echoes while still applying a peer edit.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@coderabbitai

coderabbitai Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Warning

Review limit reached

Next included review available in 16 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: f2ec17fd-d7a4-4858-97e6-a5ef5123c799

📥 Commits

Reviewing files that changed from the base of the PR and between a780dc4 and a4fed63.

📒 Files selected for processing (2)
  • src/main/ipc/remote-workspace-stale-resync.test.ts
  • src/main/ipc/remote-workspace-stale-resync.ts

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 85be03bf-e985-43fa-84ca-4af9d073f6a8

📥 Commits

Reviewing files that changed from the base of the PR and between 2197dcd and a780dc4.

📒 Files selected for processing (4)
  • src/main/ipc/remote-workspace-relay-sync.ts
  • src/main/ipc/remote-workspace-stale-resync.test.ts
  • src/main/ipc/remote-workspace-stale-resync.ts
  • tests/e2e/direct-ssh-snapshot-parking.unit.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/ipc/remote-workspace-relay-sync.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.


📝 Walkthrough

Walkthrough

The change exports snapshot identity comparison and updates stale resync to read snapshots, check for cache changes during reads, and requeue conflicting observations. Tests cover own and peer notifications, queued reads, target isolation, cache updates, and relay resets. A direct SSH test checks snapshot delivery while terminal panes are cold-parked, including pane mounting and parking after PTY attachment.

Priority: ⬇️ Low

Merge Risk: 🔵 Low · up to a780d

A peer edit may briefly revert when an older read response arrives in the same batch. Confirm the revision-ordering safeguard before merging.

Security Architecture Review

Security architecture risk: 🔵 Low · up to a780d

The new checks help prevent an older read from displacing an acknowledged update. A sustained sequence of conflicting updates could delay recovery of a workspace notification, but the effect is scoped to one SSH target and no new externally reachable entrypoint was found.

Retained concerns

  • Low · reliability · inferred: Repeated cache changes during successive reads can keep stale-notification recovery pending and defer delivery of a peer snapshot for that SSH target. The new full-snapshot check extends this retry path to same-token local acknowledgements; sustained production reachability is unverified.
Security review details

Security Blast Radius

  • inferred — The identified retry exposure is confined to recovery for a single target: pending state and cache lookups use the target ID. The supplied evidence does not establish that an unauthenticated party can drive the required sustained conflicts.

Trust Boundaries and Controls

  • observed — The workspace read uses the active SSH multiplexer and target-derived namespace, then normalizes the response before the resync callback can cache or deliver it. No new externally reachable route or bypass was identified in the changed test helper.

Resilience and Maintainability Implications

  • inferred — Continuous conflicts can postpone stale-notification delivery even though each individual read eventually settles; the resync loop itself has no retry or cancellation bound. Direct changed notifications use a separate delivery path, limiting what can be inferred about overall workspace availability.

Hardening Proposals

  • proposed — Consider an overall per-target retry or cancellation policy that preserves the rule against delivering an obsolete snapshot while allowing recovery to terminate under sustained churn.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 15.38% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 13 functions across 5 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The description references the related issue #20851 and identifies this pull request as a root-cause follow-up.
Out of Scope Changes check ✅ Passed The production changes and regression tests are focused on stale SSH workspace notification recovery and terminal parking, matching the stated objectives.
Title check ✅ Passed The title clearly identifies the primary change: keeping SSH terminals parked after their own workspace updates.
Description check ✅ Passed The description is detailed and covers the user impact, mechanism, rationale, testing, risks, compatibility, and checklist. The Linked Issue section references #20851 but does not use the requested Fi…
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

Reviewed the delta since the prior pullfrog review (commit 2197dcd), which resolves the earlier [!IMPORTANT] finding.

  • Token-guarded resync — resyncStaleRemoteWorkspace now captures the cache's hostObservationToken before the read and, inside the receive callback, discards and requeues the read when the token changed mid-flight, so a newer peer observation can no longer be overwritten by the older read. A second guard re-checks the token between receipt and delivery to cover the microtask window. The token is minted only for genuinely new, differing host observations and preserved across local patches, which is why it distinguishes an own echo from a peer change without rejecting valid relay resets.
  • Undefined-safe identity — snapshotsAreIdentical is exported as remoteWorkspaceSnapshotsAreIdentical and now handles an undefined previous.
  • Regression coverage — new cases for the peer race in one decode turn (real SshChannelMultiplexer), a captured read replaced by a peer revision, and a relay reset raced by a host change, plus a cross-layer parking test.

Verification: the focused suites pass at head (16 + 24 tests), the new cases fail against 2f745a8, and the parking test fails against the base (d9d5993).

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

Reviewed the delta since the prior pullfrog review (commit a780dc4), which closes the remaining stale-delivery path.

  • Content-identity guards — resyncStaleRemoteWorkspace now compares the cache at receipt against the pre-read snapshot by full content (remoteWorkspaceSnapshotsAreIdentical) rather than by hostObservationToken. A same-token own acknowledgement that lands during the pending read is therefore discarded and reread instead of delivered, and the post-receipt guard requeues when the cache is no longer content-identical to the observation. Because the comparison is content-based, legitimate relay resets (lower revision, different content) are still accepted on the reread.
  • Regression coverage — new cases for a same-token own acknowledgement after receipt and for own/peer notifications in both decoder orders using the real SshChannelMultiplexer, plus a parking-test adjustment that resolves follow-up reads.

Verification: focused suites pass at head (18 + 24 tests); the three new cases fail against 2197dcd (two cache rewinds, one stale delivery), and the parking test still fails against base d9d5993.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

…ale reads

A stale-revision patch reply caches the peer snapshot under a new host
observation token, but the renderer only records a conflict and blocks
uploads. Suppressing an identical stale read then left the peer change
unapplied. Only suppress when the intervening write kept the pre-read
token, which is what a contiguous own acknowledgement does.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

Reviewed the delta since the prior pullfrog review (commit a780dc4), which closes the last way a peer observation could be dropped during a stale read.

  • Peer state cached by a rejected patch is delivered — in the stale-resync receive callback, when the cache changed during the read but is content-identical to the fetched snapshot, the callback now distinguishes an own acknowledgement (token preserved by the local-patch path) from a peer/rejected-patch observation (token minted by rememberRemoteWorkspaceSnapshot) and delivers the latter instead of dropping it. A rejected workspace.patch reply caches the peer's newer session without hydrating the renderer, so suppressing the read left the renderer without the peer change.
  • unchanged narrowed — the flag is forced false whenever the cache changed during the read, so the fall-through path always delivers rather than being mistaken for an own echo.
  • Regression coverage — a new unit case places a peer snapshot in the cache during the pending read (the rejected-patch shape) and asserts it is delivered exactly once, alongside the existing own-echo suppression cases.

Verification: src/main/ipc/remote-workspace-stale-resync.test.ts passes (18 tests).

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@OrcaWin
OrcaWin merged commit 408499e into main Sep 26, 2026
37 of 39 checks passed
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