Skip to content

fix: route server project adds to selected runtime - #11346

Merged
Jinwoo-H merged 28 commits into
stablyai:mainfrom
hilaily:fix/runtime-project-host-routing
Jul 31, 2026
Merged

Jinwoo-H merged 28 commits into
stablyai:mainfrom
hilaily:fix/runtime-project-host-routing

Conversation

@hilaily

@hilaily hilaily commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Fix adding a server-hosted project or folder from the Add Project dialog when a non-default runtime environment is selected.

Previously, the selected runtime environment ID was not passed to addRepoPath. As a result, a path selected from a remote environment such as box1 could be registered
against the global/default environment instead.

The server-path flow now explicitly passes the selected runtime environment ID, ensuring the project is created in the environment from which it was selected.

Screenshots

No visual change.

Testing

  • pnpm lint
  • pnpm typecheck
  • pnpm test
  • pnpm build
  • Added or updated high-quality tests that would catch regressions, or explained why tests were not needed

Additional verification:

  • Targeted useAddRepoServerPathFlow Vitest test passed.
  • Updated the regression test to verify that addRepoPath receives the selected runtimeEnvironmentId.
  • Targeted formatting and lint checks passed with no warnings.
  • Full Linux build completed successfully.
  • Intel macOS build completed successfully using Swift 6.0.3 and the Xcode Command Line Tools.
  • Manually verified that adding /home/ace/workrepo/zeal_platform from box1 now registers the project in the correct environment.

The unchecked commands were not run as complete repository-wide suites. Their relevant targeted checks were run successfully.

AI Review Report

An AI-assisted review was performed over the complete diff.

The review checked:

  • Whether the selected runtime environment is propagated through the Add Project server-path flow.
  • Whether both Git repository and plain-folder additions use the same corrected routing.
  • Whether React hook dependencies include the new environment input and avoid stale runtime selection.
  • Whether the change affects modal lifecycle, nested repository scanning, worktree loading, or project activation.
  • Whether existing callers remain type-safe with the optional addRepoPath options argument.
  • Whether the regression test would fail if the runtime environment ID were omitted again.

No blocking issues were found. The main risk identified was accidentally falling back to the global runtime configuration when adding a server path. This was addressed by
passing:

{ runtimeEnvironmentId: activeRuntimeEnvironmentId }

directly to addRepoPath and asserting it in the test.

Cross-platform compatibility was explicitly reviewed for macOS, Linux, and Windows:

  • No shortcuts or keyboard handling changed.
  • No labels or visible UI text changed.
  • No shell commands or shell-specific behavior changed.
  • Paths remain opaque strings; no platform-specific path separators or normalization were introduced.
  • No Electron main-process, preload, IPC, packaging, or native-platform behavior was changed.
  • Linux and Intel macOS builds were completed successfully.
  • Windows compatibility was reviewed statically; a Windows build was not run.

Security Audit

An AI-assisted basic security audit was performed.

Reviewed areas:

  • Input handling: the user-selected path continues through the existing validated project-add flow.
  • Path handling: the change does not concatenate, normalize, rewrite, or execute the supplied path.
  • Command execution: no new commands, shell interpolation, or subprocess behavior were introduced.
  • Authentication and authorization: no credentials, tokens, or permission checks were changed.
  • Secrets: no secrets or sensitive values were added to source code or tests.
  • Dependencies: no dependencies or lockfiles were changed.
  • IPC: no Electron IPC channels, payload formats, or trust boundaries were added or modified.
  • Runtime routing: the supplied runtime environment ID comes from the existing selected-environment state and is passed through the existing addRepoPath API.

No new security issues or follow-up work were identified.

Notes

  • This is a routing fix only and has no visual UI changes.
  • The behavior applies to both Git repositories and plain folders selected from a server environment.
  • The change does not alter local project additions.
  • Linux and Intel macOS builds were verified.
  • Windows received static cross-platform review but was not built or manually tested.

@greptile-apps

greptile-apps Bot commented Jul 29, 2026 •

Copy link
Copy Markdown

Greptile Summary

This PR fixes a bug where adding a server-hosted project from the Add Project dialog while a non-default runtime environment is selected would silently register the project against the global/local environment instead of the selected one. The fix propagates activeRuntimeEnvironmentId through the entire server-path add flow — to addRepoPath, scanNestedRepos, setActiveNestedScanId, showNestedRepoReview, fetchWorktrees, and onGitRepoReady.

  • Core fix (useAddRepoServerPathFlow): runtimeEnvironmentId is now passed to every step of both the git and folder server-path flows; the new worktreeRefreshOptions helper centralises the mapping from a captured runtime owner to WorktreeFetchOptions.
  • Refactoring (useAddRepoNestedReviewController, complete-nested-folder-open, track-nested-folder-open): nested review state, remote scan, and import flow are composed into a single controller; the "open as folder" branch is extracted into a shared utility.
  • Test coverage: a new git-path test case in useAddRepoServerPathFlow.test.ts asserts that addRepoPath, scanNestedRepos, and fetchWorktrees all receive the correct runtimeEnvironmentId / executionHostId, addressing the gap flagged in the previous review.

Confidence Score: 5/5

Safe to merge — the change is a tightly scoped routing fix with no UI changes, no IPC changes, and no new dependencies.

The fix correctly threads runtimeEnvironmentId through every affected call site in both the git and folder server-path flows. The new useAddRepoNestedReviewController consolidation is logically equivalent to the three hooks it replaces. Test coverage for the previously uncovered git-path branch has been added. The two observations are both benign in the current call graph and have no impact on correctness at merge time.

Files Needing Attention: The getProjectWorktreesForHost function in project-added-default-checkout.ts constructs a runtime host ID string manually; it is worth keeping in sync with toRuntimeExecutionHostId if that format ever changes.

Important Files Changed

Filename Overview
src/renderer/src/components/sidebar/useAddRepoServerPathFlow.ts Core fix: passes activeRuntimeEnvironmentId to addRepoPath, scanNestedRepos, setActiveNestedScanId, showNestedRepoReview, and fetchWorktrees — propagation is complete and consistent through both git and folder paths
src/renderer/src/components/sidebar/useAddRepoServerPathFlow.test.ts Adds two test cases: folder path asserting runtimeEnvironmentId is passed to addRepoPath, and a new git path test covering the scan → add → fetchWorktrees chain; the previously flagged gap in git-path coverage is now addressed
src/renderer/src/components/sidebar/add-repo-runtime-owner.ts New helper module encapsulating the mapping from `CapturedRuntimeOwner
src/renderer/src/components/sidebar/useAddRepoNestedReviewController.ts New controller hook composing useAddRepoNestedReviewState, useAddRepoRemoteNestedScan, and useAddRepoNestedImportFlow; correctly wires nestedRuntimeEnvironmentId from state to the import flow
src/renderer/src/components/sidebar/useAddRepoNestedReviewState.ts Adds nestedRuntimeEnvironmentId state captured from showNestedRepoReview; cancel calls correctly thread the runtime environment ID; resetNestedRepoReviewState sets this to null rather than the initial undefined, a minor semantic inconsistency with no practical impact
src/renderer/src/components/sidebar/useAddRepoNestedImportFlow.ts Correctly derives completionOwner from nestedRuntimeEnvironmentId (vs SSH connection) and passes it to fetchWorktrees and onGitRepoReady; refactors handleOpenNestedRootFolder to use shared completeNestedFolderOpen
src/renderer/src/components/sidebar/project-added-default-checkout.ts Adds executionHostId filtering to worktree selection for default checkout; getProjectWorktreesForHost manually constructs runtime:${encodeURIComponent(...)} to compare against runtimeOwnerEnvironmentId, which is a coupling risk if the format ever changes
src/renderer/src/components/sidebar/AddRepoDialog.tsx Replaces three separate hook usages with useAddRepoNestedReviewController; passes selectedRuntimeEnvironmentId to useAddRepoServerPathFlow; adds resetLocalFolderFlow to host-scoped reset
src/renderer/src/components/sidebar/use-complete-git-repo-add.ts Filters worktrees by executionHostId before determining existing workspaces and default checkout; uses string literal 'local' which aligns with the known value of LOCAL_EXECUTION_HOST_ID
src/renderer/src/components/sidebar/add-repo-store-upsert.ts Extends upsert to set executionHostId on the repo based on SSH or runtime owner; switches duplicate-detection from repo ID to getRepoHostIdentity, and now returns { alreadyPresent, repo }
src/renderer/src/components/sidebar/AddRepoSteps.tsx SSH path: passes runtimeEnvironmentId: null to scan/cancel calls (correct for SSH), uses worktreeRefreshOptions with sshConnectionId, and propagates executionHostId to onGitRepoReady
src/renderer/src/components/sidebar/complete-nested-folder-open.ts New extracted function for the open-as-folder path in nested review; correctly passes owner to addNonGitFolder and forwards connectionId to the non-git confirm modal
src/renderer/src/components/sidebar/useAddRepoLocalFolderFlow.ts Local folder flow now also passes runtimeEnvironmentId to scans, review state, and addRepoPath; uses worktreeRefreshOptions consistently for fetch calls

Sequence Diagram

sequenceDiagram
    participant D as AddRepoDialog
    participant SPF as useAddRepoServerPathFlow
    participant ANRC as useAddRepoNestedReviewController
    participant ANS as useAddRepoNestedReviewState
    participant Store as Store (addRepoPath)
    participant FW as fetchWorktrees
    participant CGRA as useCompleteGitRepoAdd

    D->>SPF: handleAddServerPath(kind, activeRuntimeEnvironmentId)
    SPF->>Store: "scanNestedRepos(path, undefined, {runtimeEnvironmentId})"
    Store-->>SPF: NestedRepoScanResult
    alt "selectedPathKind === non_git_folder AND nested repos exist"
        SPF->>ANRC: "showNestedRepoReview({runtimeEnvironmentId})"
        ANRC->>ANS: setNestedRuntimeEnvironmentId(runtimeEnvironmentId)
        Note over ANS: nestedRuntimeEnvironmentId stored
        ANRC-->>D: (nested step shown)
    else direct add (git or plain folder)
        SPF->>Store: "addRepoPath(path, kind, {runtimeEnvironmentId}) FIXED"
        Store-->>SPF: repo
        SPF->>FW: "fetchWorktrees(repo.id, {requireAuthoritative, executionHostId})"
        FW-->>SPF: result
        SPF->>CGRA: onGitRepoReady(repo.id, source, executionHostId)
        CGRA->>CGRA: filter worktrees by executionHostId
        CGRA-->>D: default checkout activated
    end
Loading

Reviews (9): Last reviewed commit: "test(runtime): seed isolated Git identit..." | Re-trigger Greptile

@coderabbitai

coderabbitai Bot commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The repository store now routes repository, project-group, folder-workspace, and nested-repository operations by runtime owner. Catalog merging and mutation reconciliation use host-qualified identities and stale-result fences. Worktree refresh and activation preserve the selected execution host. Runtime sessions pass their execution host during worktree selection. The Add Project server-path flow forwards the selected runtime environment to addRepoPath. Tests and reliability gates cover runtime routing, stale results, host collisions, reconnects, and visible or hidden Electron journeys.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes routing server project additions to the selected runtime, which is the primary change.
Description check ✅ Passed The description includes all required sections, explains the change, documents testing, and covers AI review, security, and platform considerations.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

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 coderabbitai 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.

🧹 Nitpick comments (1)
src/renderer/src/components/sidebar/useAddRepoServerPathFlow.test.ts (1)

92-94: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Cover the Git path in the regression test.

This assertion only exercises handleAddServerPath('folder'). Add a Git case whose scan reaches addRepoPath and assert the same runtimeEnvironmentId; separately cover the nested-review path if it creates repositories.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 9e9fd47e-158b-4f1e-bc42-ca84bd47549a

📥 Commits

Reviewing files that changed from the base of the PR and between ef55429 and 10f0cc4842c052836ed6994ed2b66f6a9efcbf9b.

📒 Files selected for processing (3)
  • src/renderer/src/components/sidebar/AddRepoDialog.tsx
  • src/renderer/src/components/sidebar/useAddRepoServerPathFlow.test.ts
  • src/renderer/src/components/sidebar/useAddRepoServerPathFlow.ts

@Jinwoo-H
Jinwoo-H force-pushed the fix/runtime-project-host-routing branch from 10f0cc4 to fcdaa30 Compare July 31, 2026 00:56

@OrcaWin OrcaWin left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Validated and completed the selected-runtime routing fix. Add, Clone, Create, folder, and nested import now preserve host-qualified ownership through refresh and final activation; same-ID local/runtime catalogs, reconnect fencing, and SSH pruning have deterministic coverage. Headed and hidden paired Electron journeys passed on the reviewed candidate.

@coderabbitai coderabbitai 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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
src/renderer/src/hooks/useIpcEvents.ts (2)

764-806: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Forward executionHostId when reactivating a renamed worktree.

handleWorktreesChanged now receives options?.executionHostId, and it forwards this value to fetchWorktrees and fetchWorktreeLineage. But the reactivation call at line 805, setActiveWorktree(renamed.newWorktreeId), omits it.

setActiveWorktree stores exactly the passed executionHostId ?? null into activeWorkspaceExecutionHostId; it does not derive the host from the resolved worktree. So renaming a worktree that is currently active under a runtime or SSH host resets activeWorkspaceExecutionHostId to null, misrepresenting the active workspace as local.

🐛 Proposed fix
       if (renamedWasActive && renamed) {
-        useAppStore.getState().setActiveWorktree(renamed.newWorktreeId)
+        useAppStore.getState().setActiveWorktree(renamed.newWorktreeId, options?.executionHostId)
       }

893-908: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Do not let a partial worktree-refresh failure skip the lineage refresh.

refreshRuntimeProjectWorktrees throws an AggregateError after processing every repo when at least one repo fails. Because this call is await-ed directly before fetchWorktreeLineage, any single repo failure prevents the environment's lineage from refreshing at all, even when the majority of repos succeeded. This is a partial-error-propagation gap that leaves lineage stale until the next scheduled refresh.

🛠️ Proposed fix: refresh lineage regardless of partial worktree-refresh failures
       refresh: async (environmentId) => {
         void hydrateRuntimeEnvironmentSshState(environmentId, { force: true }).catch(() => {})
         const repos = await useAppStore.getState().fetchRuntimeEnvironmentRepos(environmentId)
-        await refreshRuntimeProjectWorktrees(environmentId, repos, (repoId, options) =>
-          useAppStore.getState().fetchWorktrees(repoId, options)
-        )
-        await useAppStore.getState().fetchWorktreeLineage({
-          executionHostId: toRuntimeExecutionHostId(environmentId)
-        })
+        let worktreeRefreshError: unknown
+        try {
+          await refreshRuntimeProjectWorktrees(environmentId, repos, (repoId, options) =>
+            useAppStore.getState().fetchWorktrees(repoId, options)
+          )
+        } catch (error) {
+          worktreeRefreshError = error
+        }
+        await useAppStore.getState().fetchWorktreeLineage({
+          executionHostId: toRuntimeExecutionHostId(environmentId)
+        })
+        if (worktreeRefreshError) {
+          throw worktreeRefreshError
+        }
       },
src/renderer/src/store/slices/worktrees.ts (1)

2974-3058: 🗄️ Data Integrity & Integration | 🟠 Major

Carry the missing-owner repos snapshot through direct-SSH merges.

mergeFetchedWorktrees skips all merging when ownerWasMissingAtStart is true unless the direct-SSH authority is current, and when present it enforces s.repos === args.missingDirectSshOwnerReposSnapshot. acquireDirectSshDetectedWorktreeRefresh builds the direct-SSH refresh but omits missingDirectSshOwnerReposSnapshot, so the reconnect path can miss the intended fence after ownership changes. Capture the snapshot when ownerWasMissingAtStart is true, like fetchWorktrees does, and pass it into mergeFetchedWorktrees.
[低 Effort/High Reward]

🧹 Nitpick comments (2)
tests/e2e/pr11346-selected-runtime-add.spec.ts (1)

193-207: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Extract the duplicated reconnect-and-verify sequence into a shared helper.

The disconnect → clear status → reconnect → set status sequence at Lines 193-207 is duplicated almost verbatim at Lines 510-525. The paired follow-up check at Lines 238-240 (refreshRuntimeEnvironmentStatus failure throw) is also duplicated at Lines 529-531, differing only in the error message. Two independent copies of this simulation logic increase the maintenance surface for a flaky-prone reconnect sequence.

Define a shared async function (e.g., in pr11346-selected-runtime-identity-oracle.ts) that takes page and environmentId, and drives the disconnect/status-clear/reconnect/status-set/refresh-check sequence in its own page.evaluate call. Call it from both places before running the block-specific catalog logic.

♻️ Sketch of the shared helper
export async function reconnectRuntimeEnvironmentAndWaitForRecovery(
  page: Page,
  environmentId: string,
  failureMessage: string
): Promise<void> {
  await page.evaluate(
    async ({ environmentId }) => {
      const store = window.__store
      if (!store) {
        throw new Error('Renderer store unavailable')
      }
      await window.api.runtimeEnvironments.disconnect({ selector: environmentId })
      store.getState().setRuntimeEnvironmentStatus(environmentId, { status: null, checkedAt: Date.now() })
      const response = await window.api.runtimeEnvironments.connect({ selector: environmentId, timeoutMs: 15_000 })
      if (!response.ok) {
        throw new Error(response.error.message)
      }
      store.getState().setRuntimeEnvironmentStatus(environmentId, { status: response.result, checkedAt: Date.now() })
    },
    { environmentId }
  )
  // ... run catalog-specific fetches here, then:
  const recovered = await page.evaluate(
    (environmentId) => window.__store?.getState().refreshRuntimeEnvironmentStatus(environmentId),
    environmentId
  )
  if (!recovered) {
    throw new Error(failureMessage)
  }
}

Also applies to: 238-240, 510-531

src/renderer/src/store/slices/worktree-helpers.ts (1)

80-80: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Document the new activeWorkspaceExecutionHostId field.

Every neighboring state field in WorktreeSlice has a comment explaining when it is set and why (see activeWorktreeId, renamingWorktreeId). activeWorkspaceExecutionHostId has none. Add a short comment stating that callers of setActiveWorktree/setActiveFolderWorkspace must pass the correct host explicitly, because the value is not derived from the resolved worktree record.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: bec897c9-4707-482d-b802-d9afb2afa999

📥 Commits

Reviewing files that changed from the base of the PR and between c889d50 and 3ab178d.

📒 Files selected for processing (12)
  • config/reliability-gates.jsonc
  • src/renderer/src/hooks/runtime-project-refresh-scheduler.test.ts
  • src/renderer/src/hooks/runtime-project-refresh-scheduler.ts
  • src/renderer/src/hooks/useIpcEvents.test.ts
  • src/renderer/src/hooks/useIpcEvents.ts
  • src/renderer/src/hooks/worktree-change-refresh-queue.test.ts
  • src/renderer/src/hooks/worktree-change-refresh-queue.ts
  • src/renderer/src/store/slices/worktree-helpers.ts
  • src/renderer/src/store/slices/worktrees.test.ts
  • src/renderer/src/store/slices/worktrees.ts
  • tests/e2e/pr11346-selected-runtime-add.spec.ts
  • tests/e2e/pr11346-selected-runtime-identity-oracle.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • config/reliability-gates.jsonc

@Jinwoo-H
Jinwoo-H merged commit 60d2493 into stablyai:main Jul 31, 2026
104 of 106 checks passed
nwparker added a commit that referenced this pull request Jul 31, 2026
… selection (#11818)

* [P1] fix(routing): keep the paired-HUB owner for the active workspace selection

#11346 made `activeWorkspaceExecutionHostId` authoritative for the active
workspace, but the short-circuits that read it never see the owner record, so a
project reached through a paired runtime HUB (`hostId: ssh:<target>` plus
`runtimeOwnerEnvironmentId: <hub>`) loses its transport and its repo:

- `resolveWorktreeOperationRouteResult` returned `runtimeEnvironmentId: null`
  for any non-`runtime:` selection, bypassing the HUB recovery in
  `resolveExactWorktreeRoute` — every owner-routed terminal/git/filesystem
  operation on the active workspace lost the HUB that proxies the SSH target.
- `selectRepoByIdForActiveWorkspace` filtered `state.repos` by the selected host
  with no fallback, but `withRepoHostOwnership` deliberately keeps the SSH host
  on the worktree while the repo row stays HUB-owned — so the active repo read
  as `null` and `useGitStatusPolling` stopped polling the whole workspace.

Route resolution now recovers the HUB owner from the owner rows on the selected
host, and drops it only when rival HUBs project the same host. The repo selector
opens exactly one hole in #11346's fail-closed rule — an `ssh:` selection over a
`runtime:` repo row — and every other host mismatch still returns `null`.

`worktree-owner-route.ts` is a pure extraction of the existing owner-route
helpers; no behavior moved with it.

* fix(routing): fail ambiguous paired-HUB repo selection closed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
* fix: route server project adds to selected runtime

* fix: preserve selected runtime for nested project scans

* fix: retain nested review runtime ownership

* fix: preserve nested runtime owner through completion

* fix: preserve captured add repo owners

* refactor: isolate add repo nested review controller

* test: cover selected runtime project adds

* fix: preserve selected project host ownership

* fix: pin SSH nested import completion

* fix: fence missing SSH repo refreshes

* test: cover selected runtime reconnect routing

* test: register selected runtime project routing gate

* fix: preserve selected host across all project adds

* fix: isolate selected-host project catalogs

* fix: preserve host-qualified workspace identity

* test: expect local folder host identity

* test: preserve host-qualified activation assertions

* fix: fence folder refreshes by host identity

* fix: preserve runtime owner across project refresh events

* test: fence selected-runtime reconnect oracle

* fix(runtime): preserve selected host during session activation

* test(runtime): force same-id paired terminal activation

* chore(reliability): register prior selected-runtime evidence

* test(runtime): seed isolated Git identity

---------

Co-authored-by: OrcaWin <[email protected]>
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
… selection (stablyai#11818)

* [P1] fix(routing): keep the paired-HUB owner for the active workspace selection

stablyai#11346 made `activeWorkspaceExecutionHostId` authoritative for the active
workspace, but the short-circuits that read it never see the owner record, so a
project reached through a paired runtime HUB (`hostId: ssh:<target>` plus
`runtimeOwnerEnvironmentId: <hub>`) loses its transport and its repo:

- `resolveWorktreeOperationRouteResult` returned `runtimeEnvironmentId: null`
  for any non-`runtime:` selection, bypassing the HUB recovery in
  `resolveExactWorktreeRoute` — every owner-routed terminal/git/filesystem
  operation on the active workspace lost the HUB that proxies the SSH target.
- `selectRepoByIdForActiveWorkspace` filtered `state.repos` by the selected host
  with no fallback, but `withRepoHostOwnership` deliberately keeps the SSH host
  on the worktree while the repo row stays HUB-owned — so the active repo read
  as `null` and `useGitStatusPolling` stopped polling the whole workspace.

Route resolution now recovers the HUB owner from the owner rows on the selected
host, and drops it only when rival HUBs project the same host. The repo selector
opens exactly one hole in stablyai#11346's fail-closed rule — an `ssh:` selection over a
`runtime:` repo row — and every other host mismatch still returns `null`.

`worktree-owner-route.ts` is a pure extraction of the existing owner-route
helpers; no behavior moved with it.

* fix(routing): fail ambiguous paired-HUB repo selection closed
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.

3 participants