Skip to content

Move shared file watches when the selected remote host changes - #26632

Merged
OrcaWin merged 3 commits into
mainfrom
nwparker/remote-watcher-selected-host
Oct 9, 2026
Merged

OrcaWin merged 3 commits into
mainfrom
nwparker/remote-watcher-selected-host

Conversation

@nwparker

@nwparker nwparker commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​295 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​295
Prod 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​175 $\color{#cf222e}{\Huge{\mathbf{−}}}$​64 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​111

ELI5

Switching between two remote machines with the same folder or worktree ID must move the shared file watcher to the newly selected machine. It now does.

What Changed

Before, the active workspace ID could stay unchanged while its selected host changed. The watcher target cache did not include that host, so it returned the previous host's targets and kept listening there. The new host could read and display a newly created file through the explorer's separate subscription while the shared app event never arrived.

The selector now includes the canonical selected execution host in its existing cache inputs. Its existing owner resolver and subscription diff replace the old target; unchanged target sets still retain the same snapshot.

Why

The missing host is an input to the existing ownership resolver. Tracking it fixes the stale cache without polling, reconnecting unchanged watches, or introducing another ownership algorithm.

Linked Issue

Found during SSH → Remote consolidation testing; no existing issue.

Visual Proof

The direct explorer control reads and displays SWITCHED_HOST_A/B in both baseline directions, while the shared event times out. Corrected runs receive the real matching host-qualified event. The additional rendered comparison applies #26612's proposed shared-watcher explorer consumer identically to baseline and corrected clients: the baseline omits the newly created file, and the correction displays it.

watcher-host-switch-integration-a-to-b-before.png
watcher-host-switch-integration-a-to-b-after.png
watcher-host-switch-integration-b-to-a-before.png
watcher-host-switch-integration-b-to-a-after.png
watcher-host-switch-runtime-probe.log
watcher-host-switch-integration-runtime-red.log
watcher-host-switch-integration-runtime-green.log

watcher-host-switch-runtime-green-final.log

Testing

  • Hidden macOS Electron client, two owned Linux Docker SSH hosts and the installed production server template.
  • Checked folder/worktree selection-only regressions and stable-snapshot controls; real creation-event journey and dedicated Docker CI routing updated.

The original direct-explorer baseline fails for both selected hosts in 35.6 s after the new file is already visible, because its shared event never arrives. With #26612's same consumer applied to both sides, the identical rendered baseline fails in 35.2 / 35.4 s and corrected cases pass in 20.9 / 20.7 s (43.5 s total). After removing that temporary consumer, the exact proposed branch was rebuilt and both final broker/creation/deletion/switch/return journeys pass in 20.9 / 20.7 s (42.9 s total).

Two new selected-host regressions fail before the fix; two stable-snapshot controls pass. All 250 tests / 16 files pass afterward, covering watcher targets, subscription retirement, move reconciliation, WSL aliases, owner routing and CI contracts. Full typecheck/lint, changed quality, standalone React Doctor, fresh E2E build and commit hooks pass.

Combined stack verification: C18–C21 rebased on #26637/#26645 preserves their renderer changes exactly. 547 tests / 49 files, full typecheck/lint, changed quality (including React Doctor/design-system checks), a fresh E2E build and both real-host switch directions pass. CI reruns on the new head; prior green results are not claimed for it.

Review

Stacked on #26627; merge #26637 → #26645 → #26616 → #26627 first. Only the watcher target selector changes in production. #26612's consumer was applied temporarily for the extra visual comparison and is not copied into this PR.

Agent skill upstream boundary

  • Not applicable; no upstream skill-installer source or resources copied.

Notes

No server or wire change. Runtime coverage is macOS client / Linux SSH hosts; Windows was not exercised. All host writes target disposable fixtures. The original CI passed both new host-switch cases but failed the unchanged idle-restart control: first an inherited canceled startup, then on its one retry an idle-stop record read before startup completed. The new head includes the separately exercised fixes #26637/#26645 and verifies current connection authority plus real RPC readiness before reading the record. Original failure receipts are retained; CI will rerun on the rebased head. The visual comparison also verifies compatibility with #26612, which itself depends on #26606.

Checklist

  • Small, focused change
  • ELI5, user-facing before/after, mechanism and approach explained
  • Before/after screenshots and actual runtime logs attached
  • Self-reviewed for correctness, security and performance
  • SSH ownership, folder workspaces, paths and compatibility considered
  • Local lint, typechecks, affected tests and fresh build pass

@nwparker
nwparker force-pushed the nwparker/remote-watcher-selected-host branch from 70bf530 to 61f4d6c Compare October 8, 2026 18:56
@nwparker
nwparker force-pushed the nwparker/remote-explorer-host-cache branch from e4d139a to a4d4c9f Compare October 8, 2026 18:56
@OrcaWin
OrcaWin force-pushed the nwparker/remote-explorer-host-cache branch from a4d4c9f to 40378b3 Compare October 9, 2026 02:27
@OrcaWin
OrcaWin requested a review from brennanb2025 as a code owner October 9, 2026 02:27
@OrcaWin
OrcaWin force-pushed the nwparker/remote-watcher-selected-host branch from 61f4d6c to 5d183f4 Compare October 9, 2026 02:27
@OrcaWin
OrcaWin force-pushed the nwparker/remote-explorer-host-cache branch from 40378b3 to 804f466 Compare October 9, 2026 06:03
@OrcaWin
OrcaWin force-pushed the nwparker/remote-watcher-selected-host branch from 5d183f4 to 4e3f196 Compare October 9, 2026 06:04
@OrcaWin

OrcaWin commented Oct 9, 2026

Copy link
Copy Markdown
Collaborator

Review fix: the watch-target selector took the watched root from the first worktree or folder row with a matching ID. When two hosts publish the same ID at different roots, the selected host's watch used the other host's root, and the Explorer rejected every batch. Each target now resolves its worktree, repo, folder and project-group rows on the owner's execution host (new editor-external-watch-target-rows.ts), and falls back to the first row only when no row matches that host. Tests cover worktrees and folders with different roots, per-owner open files, and an adapter-to-Explorer refresh (useFileExplorerWatch.host-root.test.tsx).

@OrcaWin
OrcaWin force-pushed the nwparker/remote-watcher-selected-host branch from 4e3f196 to c366458 Compare October 9, 2026 06:10
@OrcaWin
OrcaWin force-pushed the nwparker/remote-explorer-host-cache branch 2 times, most recently from 3d577f3 to 4b49611 Compare October 9, 2026 09:18
@OrcaWin
OrcaWin force-pushed the nwparker/remote-watcher-selected-host branch from c366458 to 8f3d6a1 Compare October 9, 2026 09:18
@OrcaWin

OrcaWin commented Oct 9, 2026

Copy link
Copy Markdown
Collaborator

Round 2 fix (8f3d6a1): the selected folder host was being applied to every open editor without a runtime owner, so a local editor could have its watch moved onto a same-id direct-SSH folder. Watch consumers now carry their own execution host: each open file uses the host captured when it was opened (or its SSH target / runtime owner), and only the sidebar consumer follows the selected host. Targets are deduplicated by their full key. Added a regression test (local file + selected SSH folder sharing one folder id) that fails on the previous head and passes now; the differing-root runtime tests still pass. Stack rebased onto main.

@OrcaWin
OrcaWin force-pushed the nwparker/remote-explorer-host-cache branch from 27abb81 to 8085a9e Compare October 9, 2026 12:06
@OrcaWin
OrcaWin changed the base branch from nwparker/remote-explorer-host-cache to main October 9, 2026 12:25
@OrcaWin
OrcaWin force-pushed the nwparker/remote-watcher-selected-host branch from 8f3d6a1 to 828e993 Compare October 9, 2026 12:25
@coderabbitai

coderabbitai Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

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: e4c27e67-7955-4b89-abbb-9a05a227ac00

📥 Commits

Reviewing files that changed from the base of the PR and between 941c8d8 and 828e993.


📒 Files selected for processing (7)
  • config/scripts/ci-e2e-job-selection.test.mjs
  • config/scripts/pr-e2e-source-routing.mjs
  • src/renderer/src/components/right-sidebar/useFileExplorerWatch.host-root.test.tsx
  • src/renderer/src/hooks/editor-external-watch-selected-host.test.ts
  • src/renderer/src/hooks/editor-external-watch-target-rows.ts
  • src/renderer/src/hooks/editor-external-watch-targets.ts
  • tests/e2e/ssh-orcad-explorer-selected-host.spec.ts

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



📝 Walkthrough

Walkthrough

The watch-target selector now resolves worktree and folder-workspace rows for each consumer’s execution host. It accounts for host selection in its cache and returns deduplicated, sorted targets. Added tests cover selected-host roots, open files on multiple hosts, and Explorer refreshes. The selected-host E2E test checks that the Explorer displays a file created on the newly selected host. CI routing includes changes to the selector in that E2E lane.


Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to 828e9

The selected-host watch change is mergeable after normal checks; no actionable failure was established.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 22.22% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 7 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check Passed The title clearly summarizes the primary change: shared file watches move when the selected remote host changes.
Description check Passed The description is detailed and covers the user impact, implementation, rationale, testing, visual proof, compatibility notes, and checklist items. It states that no existing issue is linked, which do…
Linked Issues check Passed Directly linked issue #26637 is closed. It supplies historical context only. No active directly linked issue provides coding requirements for this pull request.
Out of Scope Changes check Passed The changes stay within the stated watcher objective. The selector tracks the active execution host, resolves rows on the consumer host, preserves stable snapshots, and deduplicates targets. The added…


  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR


  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@OrcaWin
OrcaWin merged commit 05ab94b into main Oct 9, 2026
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.

2 participants