mirror of
https://github.com/stablyai/orca.git
synced 2026-10-20 16:03:20 +00:00
fix(routing): fail ambiguous paired-HUB repo selection closed
This commit is contained in:
@@ -297,27 +297,47 @@ describe('store selectors', () => {
|
||||
displayName: 'hub',
|
||||
executionHostId: toRuntimeExecutionHostId('hub-a')
|
||||
})
|
||||
const local = makeRepo({
|
||||
id: 'hub-repo',
|
||||
path: '/local/repo',
|
||||
displayName: 'local',
|
||||
executionHostId: 'local'
|
||||
})
|
||||
const activeState = {
|
||||
activeRepoId: 'hub-repo',
|
||||
activeWorkspaceExecutionHostId: toSshExecutionHostId('hub-private-target')
|
||||
}
|
||||
|
||||
for (const repos of [[repo], [local, repo], [repo, local]]) {
|
||||
expect(selectRepoByIdForActiveWorkspace({ ...activeState, repos }, 'hub-repo')).toBe(repo)
|
||||
}
|
||||
// Why: useGitStatusPolling gates every lane on this exact expression, so a null repo silently stops polling.
|
||||
const activeRepo = selectRepoByIdForActiveWorkspace(
|
||||
{ ...activeState, repos: [repo] },
|
||||
'hub-repo'
|
||||
)
|
||||
expect(activeRepo ? isGitRepoKind(activeRepo) : false).toBe(true)
|
||||
})
|
||||
|
||||
it('fails a paired-hub repo fallback closed when rival HUB rows share the repo ID', () => {
|
||||
const repoForHub = (environmentId: string) =>
|
||||
makeRepo({
|
||||
id: 'hub-repo',
|
||||
path: `/hub/${environmentId}/repo`,
|
||||
displayName: environmentId,
|
||||
executionHostId: toRuntimeExecutionHostId(environmentId)
|
||||
})
|
||||
|
||||
expect(
|
||||
selectRepoByIdForActiveWorkspace(
|
||||
{
|
||||
repos: [repo],
|
||||
repos: [repoForHub('hub-a'), repoForHub('hub-b')],
|
||||
activeRepoId: 'hub-repo',
|
||||
activeWorkspaceExecutionHostId: toSshExecutionHostId('hub-private-target')
|
||||
activeWorkspaceExecutionHostId: toSshExecutionHostId('shared-private-target')
|
||||
},
|
||||
'hub-repo'
|
||||
)
|
||||
).toBe(repo)
|
||||
// Why: useGitStatusPolling gates every lane on this exact expression, so a null repo silently stops polling.
|
||||
const activeRepo = selectRepoByIdForActiveWorkspace(
|
||||
{
|
||||
repos: [repo],
|
||||
activeRepoId: 'hub-repo',
|
||||
activeWorkspaceExecutionHostId: toSshExecutionHostId('hub-private-target')
|
||||
},
|
||||
'hub-repo'
|
||||
)
|
||||
expect(activeRepo ? isGitRepoKind(activeRepo) : false).toBe(true)
|
||||
).toBeNull()
|
||||
})
|
||||
|
||||
it('still prefers the host-matching row when one repo ID spans hosts', () => {
|
||||
|
||||
@@ -183,22 +183,22 @@ export function selectRepoByIdForActiveWorkspace(
|
||||
}
|
||||
const repo = getCachedRepoMap(state.repos).get(repoId) ?? null
|
||||
if (repoId === state.activeRepoId && state.activeWorkspaceExecutionHostId) {
|
||||
const hostMatch = state.repos.find(
|
||||
(candidate) =>
|
||||
candidate.id === repoId &&
|
||||
getRepoExecutionHostId(candidate) === state.activeWorkspaceExecutionHostId
|
||||
const repoCandidates = state.repos.filter((candidate) => candidate.id === repoId)
|
||||
const hostMatch = repoCandidates.find(
|
||||
(candidate) => getRepoExecutionHostId(candidate) === state.activeWorkspaceExecutionHostId
|
||||
)
|
||||
if (hostMatch) {
|
||||
return hostMatch
|
||||
}
|
||||
// Why: withRepoHostOwnership keeps a paired-hub worktree on its own SSH host while the repo
|
||||
// stays hub-owned, so that one mismatch still names the right repo; every other stays closed.
|
||||
const isPairedHubRepo =
|
||||
parseExecutionHostId(state.activeWorkspaceExecutionHostId)?.kind === 'ssh' &&
|
||||
parseExecutionHostId(repo ? getRepoExecutionHostId(repo) : undefined)?.kind === 'runtime'
|
||||
if (!isPairedHubRepo) {
|
||||
if (parseExecutionHostId(state.activeWorkspaceExecutionHostId)?.kind !== 'ssh') {
|
||||
return null
|
||||
}
|
||||
const pairedHubRepos = repoCandidates.filter(
|
||||
(candidate) => parseExecutionHostId(getRepoExecutionHostId(candidate))?.kind === 'runtime'
|
||||
)
|
||||
return pairedHubRepos.length === 1 ? pairedHubRepos[0] : null
|
||||
}
|
||||
return repo
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user