orca icon indicating copy to clipboard operation
orca copied to clipboard

Remove host-blind lookups in SSH snapshot scoping, runtime events, and setup resolution

Open brennanb2025 opened this issue 4 months ago • 1 comments

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: fetchWorktrees accepts 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-ratchet
  • git 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.

brennanb2025 avatar Jul 21 '26 21:07 brennanb2025

Review Change 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.

❤️ Share

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

coderabbitai[bot] avatar Jul 21 '26 21:07 coderabbitai[bot]

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.

OrcaWin avatar Oct 27 '26 09:10 OrcaWin

Superseded by #33818.

brennanb2025 avatar Nov 16 '26 09:11 brennanb2025