Remove host-blind lookups in SSH snapshot scoping, runtime events, and setup resolution
Context
Part of #9783 (follow-up from the #6030/#6031 supersession review; core multi-host state model landed in #6136). Same-id repos can legitimately exist on several execution hosts, and legacy projected setups reuse repo ids. Bare repoId or setupId lookups can therefore refresh, merge, or create on the wrong host.
This PR covers the renderer-side gaps (2–4). Gap 1 (projectHostSetup update/delete routing) still needs client/server host-perspective work and remains separate.
Changed
- Host-qualified refreshes:
fetchWorktreesaccepts an explicit owner host and preserves it through runtime project refreshes, runtime change/activation events, SSH snapshot preparation, and SSH reconnects. Explicit owners remain authoritative if the repo catalog changes during an in-flight refresh. - Cross-host event isolation: the worktree refresh queue keys by host and repo, so same-id events from two runtimes neither coalesce nor block each other.
- SSH snapshot scoping: snapshot merge, disconnect cleanup, and reconnect retry include only rows owned by the target SSH host. Legacy hostless rows are accepted only when the repo has one unambiguous owner.
- Workspace creation: target resolution pairs setups with repos by host plus repo id, preserves the resolved setup identity through composer state, and makes colliding legacy setup ids independently selectable in the Run on picker.
- Option integrity: host setup options require a matching repo on the same host; a same-id sibling repo can no longer make a stale setup appear runnable.
- Performance: refresh concurrency and per-host request coalescing remain bounded. Added host qualification is linear over already-enumerated repo/setup collections and constant-time on event queue operations.
Review fixes added
The deeper review caught cases the first commit did not cover:
- runtime events fetched the correct repo catalog but then refreshed whichever host was focused;
- same-id runtime events were deduplicated across hosts;
- SSH snapshot preparation and reconnect refreshes were still host-blind;
- workspace resolution selected the correct setup but paired it with the wrong repo object;
- the composer discarded host identity after reducing the selection to a bare repo id;
- duplicate legacy setup ids produced duplicate UI keys/values and could not select the second host;
- explicit owner refreshes could fall back to local after an owner disappeared.
Validation
Post-merge with current main:
- 7 affected Vitest files, 380/380 tests passing
pnpm run typecheck:web- Oxlint on all 15 changed files
pnpm run check:max-lines-ratchetgit diff --check
A full-suite run during review completed 33,495 passing tests; its failures were unrelated local Node 26 / optional-native-package environment failures. The repository targets Node 24.
Credit: this lookup class was identified by @prateek in the #6030/#6031 stack.
📝 Walkthrough
Walkthrough
IPC event handling now selects SSH worktrees and runtime repositories using host identity, including updates to PTY cleanup and terminal remount decisions. New exported helpers and unit tests cover host-aware selection and runtime repository recognition. Workspace creation target resolution now filters explicitly requested project host setups by the requested host when setup IDs collide across hosts, with a regression test for runtime-host selection.
🚥 Pre-merge checks | ✅ 3 | ❌ 2
❌ Failed checks (2 warnings)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | ⚠️ Warning | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. | Write docstrings for the functions missing them to satisfy the coverage threshold. |
| Description check | ⚠️ Warning | No description was provided, so none of the required template sections are filled in. | Add the required Summary, Screenshots, Testing, AI Review Report, Security Audit, and Notes sections per the template. |
✅ Passed checks (3 passed)
| Check name | Status | Explanation |
|---|---|---|
| Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
| Title check | ✅ Passed | The title accurately summarizes the host-aware lookup changes across SSH snapshots, runtime events, and setup resolution. |
✨ Finishing Touches
📝 Generate docstrings
- [ ] Create stacked PR
- [ ] Commit on current branch
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.
Comment @coderabbitai help to get the list of available commands.
Moving this PR to draft because it has been untouched for more than 80 days (latest recorded PR activity or commit timestamp: 2026-07-21T22:50:06Z; checked on 2026-10-27). This keeps the review queue focused on active work while preserving the proposal. Please mark it ready for review when work resumes.
Superseded by #33818.