mirror of
https://github.com/stablyai/orca.git
synced 2026-10-31 00:57:45 +00:00
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user