refactor(runtime): resolve a watched repo's host through the canonical routing API (#31866)

* refactor(runtime): resolve a watched repo's host through the canonical routing API

* test(runtime): drop an unused mock reset
This commit is contained in:
Neil
2026-10-21 23:44:49 -07:00
committed by GitHub
parent 01db1b89af
commit 70e997f4e5
2 changed files with 32 additions and 1 deletions
@@ -0,0 +1,31 @@
import { describe, expect, it } from 'vitest'
import type { Repo } from '../../../shared/repo-types'
import type { RuntimeClientEvent } from '../../../shared/runtime-client-events'
import { OrcaRuntimeService } from '../orca-runtime'
import type { RuntimeStore } from '../runtime-store-contract'
function catalogEventsFor(repo: Repo): RuntimeClientEvent[] {
const store: Pick<RuntimeStore, 'getRepos'> = { getRepos: () => [repo] }
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: the catalog notification reads only repos.
const runtime = new OrcaRuntimeService(store as RuntimeStore)
const events: RuntimeClientEvent[] = []
runtime.onClientEvent((event) => events.push(event))
runtime.notifyWorktreeCatalogChangedForRemoteClients(repo.id)
return events.filter((event) => event.type === 'worktreesChanged')
}
const baseRepo: Repo = { id: 'r', path: '/r', displayName: 'r', badgeColor: 'blue', addedAt: 1 }
describe('notifyWorktreeCatalogChangedForRemoteClients', () => {
it('tells remote clients about a local repo', () => {
expect(catalogEventsFor(baseRepo)).toHaveLength(1)
})
it('skips an SSH repo named only by its execution host', () => {
expect(catalogEventsFor({ ...baseRepo, executionHostId: 'ssh:target-1' })).toHaveLength(0)
})
it('skips an SSH repo named by its legacy connection id', () => {
expect(catalogEventsFor({ ...baseRepo, connectionId: 'target-1' })).toHaveLength(0)
})
})
@@ -176,7 +176,7 @@ export abstract class OrcaRuntimeWithNotifySshStateChanged extends OrcaRuntimeWi
notifyWorktreeCatalogChangedForRemoteClients(repoId: string): void {
this.invalidateWorktreeScanCacheForRepo(repoId)
const matchingRepos = this.store?.getRepos().filter((repo) => repo.id === repoId) ?? []
if (matchingRepos.length !== 1 || matchingRepos[0]?.connectionId) {
if (matchingRepos.length !== 1 || getRepoRoutingConnectionId(matchingRepos[0])) {
return
}
this.notifyWorktreesChangedForRemoteClients(repoId)