mirror of
https://github.com/stablyai/orca.git
synced 2026-11-01 09:37:33 +00:00
fix(persistence): worktree meta and lineage writes take the row's host, not the id (R4-2b) (#30811)
* fix(persistence): worktree meta and lineage writes take the row's host, not the id (R4-2b) * fix(persistence): review fixes for host-targeted worktree writes * test: SAFETY notes on partial runtime store mocks * test: drop imports duplicated by the rebase onto #30797
This commit is contained in:
@@ -31,6 +31,7 @@ import {
|
||||
resetBrowserIdentityModeStoreForTests
|
||||
} from '../../browser/browser-identity-mode-store'
|
||||
import { runtimeAdvertisesBrowserClientHosting } from '../../../shared/browser-client-hosting-eligibility'
|
||||
import { hostWorktreeTarget } from '../../../shared/worktree/host-qualified-identity'
|
||||
|
||||
describe('OrcaRuntimeService', () => {
|
||||
it('advertises client hosting when its factory implements client page creation', () => {
|
||||
@@ -688,7 +689,9 @@ describe('OrcaRuntimeService', () => {
|
||||
'runtime:env-b'
|
||||
)
|
||||
|
||||
expect(removeWorktreeMeta).toHaveBeenCalledWith(TEST_WORKTREE_ID, 'runtime:env-b')
|
||||
expect(removeWorktreeMeta).toHaveBeenCalledWith(
|
||||
hostWorktreeTarget({ id: TEST_WORKTREE_ID, hostId: 'runtime:env-b' })
|
||||
)
|
||||
expect(internals.mobileSessionTabsByWorktree.get(TEST_WORKTREE_ID)).toBe(localSession)
|
||||
})
|
||||
|
||||
@@ -721,7 +724,9 @@ describe('OrcaRuntimeService', () => {
|
||||
'ssh:ssh-1'
|
||||
)
|
||||
|
||||
expect(removeWorktreeMeta).toHaveBeenCalledWith(TEST_WORKTREE_ID, 'ssh:ssh-1')
|
||||
expect(removeWorktreeMeta).toHaveBeenCalledWith(
|
||||
hostWorktreeTarget({ id: TEST_WORKTREE_ID, hostId: 'ssh:ssh-1' })
|
||||
)
|
||||
expect(internals.mobileSessionTabsByWorktree.get(TEST_WORKTREE_ID)).toBe(survivingSession)
|
||||
expect(deleteWorktreeHistoryDirMock).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
@@ -8,6 +8,10 @@ import {
|
||||
makeWorktreeMeta,
|
||||
store
|
||||
} from '../orca-runtime-test-fixtures.spec'
|
||||
import {
|
||||
hostWorktreeTarget,
|
||||
type HostWorktreeTarget
|
||||
} from '../../../shared/worktree/host-qualified-identity'
|
||||
|
||||
const anyCatalogVersion = { epoch: expect.any(String), sequence: expect.any(Number) }
|
||||
|
||||
@@ -16,10 +20,12 @@ describe('OrcaRuntimeService', () => {
|
||||
const metaById: Record<string, WorktreeMeta> = {
|
||||
[TEST_WORKTREE_ID]: makeWorktreeMeta({ instanceId: 'child-instance' })
|
||||
}
|
||||
const setWorktreeMeta = vi.fn((worktreeId: string, meta: Partial<WorktreeMeta>) => {
|
||||
metaById[worktreeId] = { ...metaById[worktreeId], ...meta }
|
||||
return metaById[worktreeId]
|
||||
})
|
||||
const setWorktreeMeta = vi.fn(
|
||||
({ id: worktreeId }: HostWorktreeTarget, meta: Partial<WorktreeMeta>) => {
|
||||
metaById[worktreeId] = { ...metaById[worktreeId], ...meta }
|
||||
return metaById[worktreeId]
|
||||
}
|
||||
)
|
||||
const runtimeStore = {
|
||||
...store,
|
||||
getAllWorktreeMeta: () => metaById,
|
||||
@@ -35,7 +41,10 @@ describe('OrcaRuntimeService', () => {
|
||||
orcaCreationWorkspaceLayout: { path: '/tmp', nestWorkspaces: false }
|
||||
})
|
||||
|
||||
expect(setWorktreeMeta).toHaveBeenCalledWith(TEST_WORKTREE_ID, { comment: 'keep me' })
|
||||
expect(setWorktreeMeta).toHaveBeenCalledWith(
|
||||
hostWorktreeTarget({ id: TEST_WORKTREE_ID, hostId: 'local' }),
|
||||
{ comment: 'keep me' }
|
||||
)
|
||||
})
|
||||
|
||||
it('ignores stale instance-mismatched lineage when validating manual cycle repairs', async () => {
|
||||
@@ -47,12 +56,12 @@ describe('OrcaRuntimeService', () => {
|
||||
[parentId]: makeWorktreeMeta({ instanceId: 'new-parent-instance' }),
|
||||
[childId]: makeWorktreeMeta({ instanceId: 'child-instance' })
|
||||
}
|
||||
const setWorktreeLineage = vi.fn((_worktreeId, lineage) => lineage)
|
||||
const setWorktreeLineage = vi.fn((_target: HostWorktreeTarget, lineage) => lineage)
|
||||
const runtimeStore = {
|
||||
...store,
|
||||
getAllWorktreeMeta: () => metaById,
|
||||
getWorktreeMeta: (worktreeId: string) => metaById[worktreeId],
|
||||
setWorktreeMeta: (worktreeId: string, meta: Partial<WorktreeMeta>) => {
|
||||
setWorktreeMeta: ({ id: worktreeId }: HostWorktreeTarget, meta: Partial<WorktreeMeta>) => {
|
||||
metaById[worktreeId] = { ...metaById[worktreeId], ...meta }
|
||||
return metaById[worktreeId]
|
||||
},
|
||||
@@ -93,7 +102,7 @@ describe('OrcaRuntimeService', () => {
|
||||
})
|
||||
|
||||
expect(setWorktreeLineage).toHaveBeenCalledWith(
|
||||
childId,
|
||||
hostWorktreeTarget({ id: childId, hostId: 'local' }),
|
||||
expect.objectContaining({
|
||||
worktreeId: childId,
|
||||
worktreeInstanceId: 'child-instance',
|
||||
@@ -116,12 +125,12 @@ describe('OrcaRuntimeService', () => {
|
||||
...store,
|
||||
getAllWorktreeMeta: () => metaById,
|
||||
getWorktreeMeta: (worktreeId: string) => metaById[worktreeId],
|
||||
setWorktreeMeta: (worktreeId: string, meta: Partial<WorktreeMeta>) => {
|
||||
setWorktreeMeta: ({ id: worktreeId }: HostWorktreeTarget, meta: Partial<WorktreeMeta>) => {
|
||||
metaById[worktreeId] = { ...metaById[worktreeId], ...meta }
|
||||
return metaById[worktreeId]
|
||||
},
|
||||
getWorktreeLineage: () => undefined,
|
||||
setWorktreeLineage: vi.fn((_worktreeId: string, lineage) => lineage)
|
||||
setWorktreeLineage: vi.fn((_target: HostWorktreeTarget, lineage) => lineage)
|
||||
}
|
||||
vi.mocked(listWorktrees).mockResolvedValue([
|
||||
{
|
||||
@@ -170,18 +179,18 @@ describe('OrcaRuntimeService', () => {
|
||||
createdAt: 1
|
||||
}
|
||||
}
|
||||
const setWorktreeLineage = vi.fn((_worktreeId: string, lineage) => lineage)
|
||||
const setWorktreeLineage = vi.fn((_target: HostWorktreeTarget, lineage) => lineage)
|
||||
const runtimeStore = {
|
||||
...store,
|
||||
getAllWorktreeMeta: () => metaById,
|
||||
getWorktreeMeta: (worktreeId: string) => metaById[worktreeId],
|
||||
setWorktreeMeta: (worktreeId: string, meta: Partial<WorktreeMeta>) => {
|
||||
setWorktreeMeta: ({ id: worktreeId }: HostWorktreeTarget, meta: Partial<WorktreeMeta>) => {
|
||||
metaById[worktreeId] = { ...metaById[worktreeId], ...meta }
|
||||
return metaById[worktreeId]
|
||||
},
|
||||
getWorktreeLineage: (worktreeId: string) => lineageById[worktreeId],
|
||||
getAllWorktreeLineage: () => lineageById,
|
||||
removeWorktreeLineage: vi.fn((worktreeId: string) => {
|
||||
removeWorktreeLineage: vi.fn(({ id: worktreeId }: HostWorktreeTarget) => {
|
||||
delete lineageById[worktreeId]
|
||||
}),
|
||||
setWorktreeLineage
|
||||
@@ -227,7 +236,7 @@ describe('OrcaRuntimeService', () => {
|
||||
})
|
||||
|
||||
expect(setWorktreeLineage).toHaveBeenCalledWith(
|
||||
childId,
|
||||
hostWorktreeTarget({ id: childId, hostId: 'local' }),
|
||||
expect.objectContaining({
|
||||
worktreeInstanceId: 'child-instance',
|
||||
parentWorktreeInstanceId: rotatedParentInstance
|
||||
@@ -255,17 +264,19 @@ describe('OrcaRuntimeService', () => {
|
||||
createdAt: 1
|
||||
}
|
||||
}
|
||||
const removeWorktreeLineage = vi.fn((worktreeId: string) => {
|
||||
const removeWorktreeLineage = vi.fn(({ id: worktreeId }: HostWorktreeTarget) => {
|
||||
delete lineageById[worktreeId]
|
||||
})
|
||||
const runtimeStore = {
|
||||
...store,
|
||||
getAllWorktreeMeta: () => metaById,
|
||||
getWorktreeMeta: (worktreeId: string) => metaById[worktreeId],
|
||||
setWorktreeMeta: vi.fn((worktreeId: string, meta: Partial<WorktreeMeta>) => {
|
||||
metaById[worktreeId] = { ...metaById[worktreeId], ...meta }
|
||||
return metaById[worktreeId]
|
||||
}),
|
||||
setWorktreeMeta: vi.fn(
|
||||
({ id: worktreeId }: HostWorktreeTarget, meta: Partial<WorktreeMeta>) => {
|
||||
metaById[worktreeId] = { ...metaById[worktreeId], ...meta }
|
||||
return metaById[worktreeId]
|
||||
}
|
||||
),
|
||||
getAllWorktreeLineage: () => lineageById,
|
||||
removeWorktreeLineage
|
||||
}
|
||||
@@ -549,13 +560,14 @@ describe('OrcaRuntimeService', () => {
|
||||
createdAt: 1
|
||||
}
|
||||
}
|
||||
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: a partial store mock; the code under test reads only the members it defines.
|
||||
const runtime = new OrcaRuntimeService({
|
||||
...store,
|
||||
getRepos: () => [folderRepo],
|
||||
getRepo: (id: string) => (id === folderRepo.id ? folderRepo : undefined),
|
||||
getAllWorktreeMeta: () => metaById,
|
||||
getWorktreeMeta: (worktreeId: string) => metaById[worktreeId],
|
||||
setWorktreeMeta: (worktreeId: string, meta: Partial<WorktreeMeta>) => {
|
||||
setWorktreeMeta: ({ id: worktreeId }: HostWorktreeTarget, meta: Partial<WorktreeMeta>) => {
|
||||
metaById[worktreeId] = { ...(metaById[worktreeId] ?? makeWorktreeMeta()), ...meta }
|
||||
return metaById[worktreeId]
|
||||
},
|
||||
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
store,
|
||||
withPlatform
|
||||
} from '../orca-runtime-test-fixtures.spec'
|
||||
import type { HostWorktreeTarget } from '../../../shared/worktree/host-qualified-identity'
|
||||
|
||||
describe('OrcaRuntimeService', () => {
|
||||
it('hides agent scratch created inside a linked checkout from runtime listings', async () => {
|
||||
@@ -235,7 +236,7 @@ describe('OrcaRuntimeService', () => {
|
||||
[firstId]: { sortOrder: 200 },
|
||||
[secondId]: { sortOrder: 100 }
|
||||
}
|
||||
const setWorktreeMeta = vi.fn((id: string, updates: Partial<WorktreeMeta>) => {
|
||||
const setWorktreeMeta = vi.fn(({ id }: HostWorktreeTarget, updates: Partial<WorktreeMeta>) => {
|
||||
metaById[id] = { ...metaById[id], ...updates }
|
||||
})
|
||||
const runtime = new OrcaRuntimeService({
|
||||
@@ -453,7 +454,7 @@ describe('OrcaRuntimeService', () => {
|
||||
...store,
|
||||
getAllWorktreeMeta: () => metaById,
|
||||
getWorktreeMeta: (worktreeId: string) => metaById[worktreeId],
|
||||
setWorktreeMeta: (worktreeId: string, meta: Partial<WorktreeMeta>) => {
|
||||
setWorktreeMeta: ({ id: worktreeId }: HostWorktreeTarget, meta: Partial<WorktreeMeta>) => {
|
||||
metaById[worktreeId] = { ...metaById[worktreeId], ...meta }
|
||||
return metaById[worktreeId]
|
||||
},
|
||||
@@ -499,7 +500,7 @@ describe('OrcaRuntimeService', () => {
|
||||
createdAt: 1
|
||||
}
|
||||
}
|
||||
const removeWorktreeLineage = vi.fn((worktreeId: string) => {
|
||||
const removeWorktreeLineage = vi.fn(({ id: worktreeId }: HostWorktreeTarget) => {
|
||||
delete lineageById[worktreeId]
|
||||
})
|
||||
const runtimeStore = {
|
||||
@@ -508,10 +509,12 @@ describe('OrcaRuntimeService', () => {
|
||||
getRepos: () => [remoteRepo],
|
||||
getAllWorktreeMeta: () => metaById,
|
||||
getWorktreeMeta: (worktreeId: string) => metaById[worktreeId],
|
||||
setWorktreeMeta: vi.fn((worktreeId: string, meta: Partial<WorktreeMeta>) => {
|
||||
metaById[worktreeId] = { ...metaById[worktreeId], ...meta }
|
||||
return metaById[worktreeId]
|
||||
}),
|
||||
setWorktreeMeta: vi.fn(
|
||||
({ id: worktreeId }: HostWorktreeTarget, meta: Partial<WorktreeMeta>) => {
|
||||
metaById[worktreeId] = { ...metaById[worktreeId], ...meta }
|
||||
return metaById[worktreeId]
|
||||
}
|
||||
),
|
||||
getAllWorktreeLineage: () => lineageById,
|
||||
removeWorktreeLineage
|
||||
}
|
||||
|
||||
@@ -14,6 +14,10 @@ import {
|
||||
makeWorktreeMeta,
|
||||
store
|
||||
} from '../orca-runtime-test-fixtures.spec'
|
||||
import {
|
||||
hostWorktreeTarget,
|
||||
type HostWorktreeTarget
|
||||
} from '../../../shared/worktree/host-qualified-identity'
|
||||
|
||||
describe('OrcaRuntimeService', () => {
|
||||
it('exposes valid parent and child lineage in CLI worktree records', async () => {
|
||||
@@ -46,7 +50,7 @@ describe('OrcaRuntimeService', () => {
|
||||
...store,
|
||||
getAllWorktreeMeta: () => metaById,
|
||||
getWorktreeMeta: (worktreeId: string) => metaById[worktreeId],
|
||||
setWorktreeMeta: (worktreeId: string, meta: Partial<WorktreeMeta>) => {
|
||||
setWorktreeMeta: ({ id: worktreeId }: HostWorktreeTarget, meta: Partial<WorktreeMeta>) => {
|
||||
metaById[worktreeId] = { ...metaById[worktreeId], ...meta }
|
||||
return metaById[worktreeId]
|
||||
},
|
||||
@@ -103,7 +107,7 @@ describe('OrcaRuntimeService', () => {
|
||||
displayName: 'coordinator'
|
||||
})
|
||||
}
|
||||
const setWorktreeLineage = vi.fn((worktreeId: string, lineage) => {
|
||||
const setWorktreeLineage = vi.fn(({ id: worktreeId }: HostWorktreeTarget, lineage) => {
|
||||
metaById[worktreeId] = metaById[worktreeId] ?? makeWorktreeMeta()
|
||||
return lineage
|
||||
})
|
||||
@@ -111,7 +115,7 @@ describe('OrcaRuntimeService', () => {
|
||||
...store,
|
||||
getAllWorktreeMeta: () => metaById,
|
||||
getWorktreeMeta: (worktreeId: string) => metaById[worktreeId],
|
||||
setWorktreeMeta: (worktreeId: string, meta: Partial<WorktreeMeta>) => {
|
||||
setWorktreeMeta: ({ id: worktreeId }: HostWorktreeTarget, meta: Partial<WorktreeMeta>) => {
|
||||
const existing = metaById[worktreeId] ?? makeWorktreeMeta({ instanceId: 'child-instance' })
|
||||
metaById[worktreeId] = { ...existing, ...meta }
|
||||
return metaById[worktreeId]
|
||||
@@ -167,7 +171,10 @@ describe('OrcaRuntimeService', () => {
|
||||
})
|
||||
expect(result.lineage).not.toHaveProperty('createdByTerminalHandle')
|
||||
expect(result.warnings).toEqual([])
|
||||
expect(setWorktreeLineage).toHaveBeenCalledWith(childId, expect.any(Object))
|
||||
expect(setWorktreeLineage).toHaveBeenCalledWith(
|
||||
hostWorktreeTarget({ id: childId, hostId: 'local' }),
|
||||
expect.any(Object)
|
||||
)
|
||||
})
|
||||
|
||||
it('enriches caller-terminal lineage with active orchestration dispatch context', async () => {
|
||||
@@ -185,12 +192,12 @@ describe('OrcaRuntimeService', () => {
|
||||
displayName: 'worker'
|
||||
})
|
||||
}
|
||||
const setWorktreeLineage = vi.fn((_worktreeId: string, lineage) => lineage)
|
||||
const setWorktreeLineage = vi.fn((_target: HostWorktreeTarget, lineage) => lineage)
|
||||
const runtimeStore = {
|
||||
...store,
|
||||
getAllWorktreeMeta: () => metaById,
|
||||
getWorktreeMeta: (worktreeId: string) => metaById[worktreeId],
|
||||
setWorktreeMeta: (worktreeId: string, meta: Partial<WorktreeMeta>) => {
|
||||
setWorktreeMeta: ({ id: worktreeId }: HostWorktreeTarget, meta: Partial<WorktreeMeta>) => {
|
||||
const existing = metaById[worktreeId] ?? makeWorktreeMeta()
|
||||
metaById[worktreeId] = { ...existing, ...meta }
|
||||
return metaById[worktreeId]
|
||||
@@ -287,7 +294,7 @@ describe('OrcaRuntimeService', () => {
|
||||
createdByTerminalHandle: workerHandle
|
||||
})
|
||||
expect(setWorktreeLineage).toHaveBeenCalledWith(
|
||||
childId,
|
||||
hostWorktreeTarget({ id: childId, hostId: 'local' }),
|
||||
expect.objectContaining({
|
||||
worktreeInstanceId: expect.not.stringMatching(/^old-/),
|
||||
parentWorktreeInstanceId: 'worker-instance'
|
||||
|
||||
@@ -15,6 +15,10 @@ import {
|
||||
makeWorktreeMeta,
|
||||
store
|
||||
} from '../orca-runtime-test-fixtures.spec'
|
||||
import {
|
||||
hostWorktreeTarget,
|
||||
type HostWorktreeTarget
|
||||
} from '../../../shared/worktree/host-qualified-identity'
|
||||
|
||||
describe('OrcaRuntimeService', () => {
|
||||
it.each(['failed', 'circuit_broken'] as const)(
|
||||
@@ -125,12 +129,12 @@ describe('OrcaRuntimeService', () => {
|
||||
const metaById: Record<string, WorktreeMeta> = {
|
||||
[parentId]: makeWorktreeMeta({ instanceId: 'parent-instance' })
|
||||
}
|
||||
const setWorktreeLineage = vi.fn((_worktreeId: string, lineage) => lineage)
|
||||
const setWorktreeLineage = vi.fn((_target: HostWorktreeTarget, lineage) => lineage)
|
||||
const runtimeStore = {
|
||||
...store,
|
||||
getAllWorktreeMeta: () => metaById,
|
||||
getWorktreeMeta: (worktreeId: string) => metaById[worktreeId],
|
||||
setWorktreeMeta: (worktreeId: string, meta: Partial<WorktreeMeta>) => {
|
||||
setWorktreeMeta: ({ id: worktreeId }: HostWorktreeTarget, meta: Partial<WorktreeMeta>) => {
|
||||
const existing = metaById[worktreeId] ?? makeWorktreeMeta()
|
||||
metaById[worktreeId] = { ...existing, ...meta }
|
||||
return metaById[worktreeId]
|
||||
@@ -181,7 +185,10 @@ describe('OrcaRuntimeService', () => {
|
||||
childWorktreeIds: [],
|
||||
lineage: result.lineage
|
||||
})
|
||||
expect(setWorktreeLineage).toHaveBeenCalledWith(childId, expect.any(Object))
|
||||
expect(setWorktreeLineage).toHaveBeenCalledWith(
|
||||
hostWorktreeTarget({ id: childId, hostId: 'local' }),
|
||||
expect.any(Object)
|
||||
)
|
||||
})
|
||||
|
||||
it('keeps cwd-inferred lineage best-effort when the cwd parent cannot be resolved', async () => {
|
||||
@@ -235,12 +242,12 @@ describe('OrcaRuntimeService', () => {
|
||||
displayName: 'worker'
|
||||
})
|
||||
}
|
||||
const setWorktreeLineage = vi.fn((_worktreeId: string, lineage) => lineage)
|
||||
const setWorktreeLineage = vi.fn((_target: HostWorktreeTarget, lineage) => lineage)
|
||||
const runtimeStore = {
|
||||
...store,
|
||||
getAllWorktreeMeta: () => metaById,
|
||||
getWorktreeMeta: (worktreeId: string) => metaById[worktreeId],
|
||||
setWorktreeMeta: (worktreeId: string, meta: Partial<WorktreeMeta>) => {
|
||||
setWorktreeMeta: ({ id: worktreeId }: HostWorktreeTarget, meta: Partial<WorktreeMeta>) => {
|
||||
const existing = metaById[worktreeId] ?? makeWorktreeMeta()
|
||||
metaById[worktreeId] = { ...existing, ...meta }
|
||||
return metaById[worktreeId]
|
||||
@@ -315,7 +322,7 @@ describe('OrcaRuntimeService', () => {
|
||||
taskId: 'task_abc123'
|
||||
})
|
||||
expect(setWorktreeLineage).toHaveBeenCalledWith(
|
||||
childId,
|
||||
hostWorktreeTarget({ id: childId, hostId: 'local' }),
|
||||
expect.objectContaining({
|
||||
parentWorktreeInstanceId: 'worker-instance'
|
||||
})
|
||||
@@ -333,12 +340,12 @@ describe('OrcaRuntimeService', () => {
|
||||
displayName: 'parent'
|
||||
})
|
||||
}
|
||||
const setWorktreeLineage = vi.fn((_worktreeId: string, lineage) => lineage)
|
||||
const setWorktreeLineage = vi.fn((_target: HostWorktreeTarget, lineage) => lineage)
|
||||
const runtimeStore = {
|
||||
...store,
|
||||
getAllWorktreeMeta: () => metaById,
|
||||
getWorktreeMeta: (worktreeId: string) => metaById[worktreeId],
|
||||
setWorktreeMeta: (worktreeId: string, meta: Partial<WorktreeMeta>) => {
|
||||
setWorktreeMeta: ({ id: worktreeId }: HostWorktreeTarget, meta: Partial<WorktreeMeta>) => {
|
||||
const existing = metaById[worktreeId] ?? makeWorktreeMeta()
|
||||
metaById[worktreeId] = { ...existing, ...meta }
|
||||
return metaById[worktreeId]
|
||||
@@ -413,7 +420,7 @@ describe('OrcaRuntimeService', () => {
|
||||
taskId: 'task_creator123'
|
||||
})
|
||||
expect(setWorktreeLineage).toHaveBeenCalledWith(
|
||||
childId,
|
||||
hostWorktreeTarget({ id: childId, hostId: 'local' }),
|
||||
expect.objectContaining({
|
||||
parentWorktreeInstanceId: 'parent-instance'
|
||||
})
|
||||
|
||||
@@ -21,6 +21,10 @@ import {
|
||||
store
|
||||
} from '../orca-runtime-test-fixtures.spec'
|
||||
import { REPO_SEARCH_REFS_MAX_LIMIT } from '../../../shared/repo-search-limits'
|
||||
import {
|
||||
hostWorktreeTarget,
|
||||
type HostWorktreeTarget
|
||||
} from '../../../shared/worktree/host-qualified-identity'
|
||||
|
||||
describe('OrcaRuntimeService', () => {
|
||||
it('rejects invalid positive limits for bounded list commands', async () => {
|
||||
@@ -75,14 +79,16 @@ describe('OrcaRuntimeService', () => {
|
||||
[childId]: makeWorktreeMeta({ instanceId: 'child-instance' }),
|
||||
[parentId]: makeWorktreeMeta({ instanceId: 'parent-instance' })
|
||||
}
|
||||
const setWorktreeLineage = vi.fn((_worktreeId: string, lineage: WorktreeLineage) => lineage)
|
||||
const setWorktreeLineage = vi.fn(
|
||||
(_target: HostWorktreeTarget, lineage: WorktreeLineage) => lineage
|
||||
)
|
||||
const runtimeStore = {
|
||||
...store,
|
||||
getRepo: (id: string) => (id === remoteRepo.id ? remoteRepo : undefined),
|
||||
getRepos: () => [remoteRepo],
|
||||
getAllWorktreeMeta: () => metaById,
|
||||
getWorktreeMeta: (worktreeId: string) => metaById[worktreeId],
|
||||
setWorktreeMeta: (worktreeId: string, meta: Partial<WorktreeMeta>) => {
|
||||
setWorktreeMeta: ({ id: worktreeId }: HostWorktreeTarget, meta: Partial<WorktreeMeta>) => {
|
||||
metaById[worktreeId] = { ...(metaById[worktreeId] ?? makeWorktreeMeta()), ...meta }
|
||||
return metaById[worktreeId]
|
||||
},
|
||||
@@ -96,7 +102,7 @@ describe('OrcaRuntimeService', () => {
|
||||
})
|
||||
|
||||
expect(setWorktreeLineage).toHaveBeenCalledWith(
|
||||
childId,
|
||||
hostWorktreeTarget({ id: childId, hostId: 'ssh:ssh-1' }),
|
||||
expect.objectContaining({
|
||||
worktreeId: childId,
|
||||
worktreeInstanceId: 'child-instance',
|
||||
@@ -127,12 +133,12 @@ describe('OrcaRuntimeService', () => {
|
||||
getRepos: () => [remoteRepo],
|
||||
getAllWorktreeMeta: () => metaById,
|
||||
getWorktreeMeta: (worktreeId: string) => metaById[worktreeId],
|
||||
setWorktreeMeta: (worktreeId: string, meta: Partial<WorktreeMeta>) => {
|
||||
setWorktreeMeta: ({ id: worktreeId }: HostWorktreeTarget, meta: Partial<WorktreeMeta>) => {
|
||||
metaById[worktreeId] = { ...(metaById[worktreeId] ?? makeWorktreeMeta()), ...meta }
|
||||
return metaById[worktreeId]
|
||||
},
|
||||
getWorktreeLineage: () => undefined,
|
||||
setWorktreeLineage: vi.fn((_worktreeId: string, lineage: WorktreeLineage) => lineage)
|
||||
setWorktreeLineage: vi.fn((_target: HostWorktreeTarget, lineage: WorktreeLineage) => lineage)
|
||||
}
|
||||
const runtime = new OrcaRuntimeService(runtimeStore as never)
|
||||
|
||||
@@ -152,7 +158,9 @@ describe('OrcaRuntimeService', () => {
|
||||
const childId = `${repoId}::${childPath}`
|
||||
const parentId = `${repoId}::${parentPath}`
|
||||
const metaById: Record<string, WorktreeMeta> = {}
|
||||
const setWorktreeLineage = vi.fn((_worktreeId: string, lineage: WorktreeLineage) => lineage)
|
||||
const setWorktreeLineage = vi.fn(
|
||||
(_target: HostWorktreeTarget, lineage: WorktreeLineage) => lineage
|
||||
)
|
||||
const runtimeStore = {
|
||||
...store,
|
||||
getRepo: (id: string) =>
|
||||
@@ -176,7 +184,7 @@ describe('OrcaRuntimeService', () => {
|
||||
],
|
||||
getAllWorktreeMeta: () => metaById,
|
||||
getWorktreeMeta: (worktreeId: string) => metaById[worktreeId],
|
||||
setWorktreeMeta: (worktreeId: string, meta: Partial<WorktreeMeta>) => {
|
||||
setWorktreeMeta: ({ id: worktreeId }: HostWorktreeTarget, meta: Partial<WorktreeMeta>) => {
|
||||
metaById[worktreeId] = { ...(metaById[worktreeId] ?? makeWorktreeMeta()), ...meta }
|
||||
return metaById[worktreeId]
|
||||
},
|
||||
@@ -227,13 +235,15 @@ describe('OrcaRuntimeService', () => {
|
||||
[parentId]: makeWorktreeMeta({ instanceId: 'parent-instance' }),
|
||||
[childId]: makeWorktreeMeta({ instanceId: 'child-instance' })
|
||||
}
|
||||
const setWorktreeLineage = vi.fn((_worktreeId: string, lineage: WorktreeLineage) => lineage)
|
||||
const setWorktreeLineage = vi.fn(
|
||||
(_target: HostWorktreeTarget, lineage: WorktreeLineage) => lineage
|
||||
)
|
||||
const setWorkspaceLineage = vi.fn((lineage: WorkspaceLineage) => lineage)
|
||||
const runtimeStore = {
|
||||
...store,
|
||||
getAllWorktreeMeta: () => metaById,
|
||||
getWorktreeMeta: (worktreeId: string) => metaById[worktreeId],
|
||||
setWorktreeMeta: (worktreeId: string, meta: Partial<WorktreeMeta>) => {
|
||||
setWorktreeMeta: ({ id: worktreeId }: HostWorktreeTarget, meta: Partial<WorktreeMeta>) => {
|
||||
metaById[worktreeId] = { ...metaById[worktreeId], ...meta }
|
||||
return metaById[worktreeId]
|
||||
},
|
||||
@@ -264,7 +274,7 @@ describe('OrcaRuntimeService', () => {
|
||||
})
|
||||
|
||||
expect(setWorktreeLineage).toHaveBeenCalledWith(
|
||||
childId,
|
||||
hostWorktreeTarget({ id: childId, hostId: 'local' }),
|
||||
expect.objectContaining({
|
||||
parentWorktreeId: parentId,
|
||||
parentWorktreeInstanceId: 'parent-instance',
|
||||
@@ -325,7 +335,9 @@ describe('OrcaRuntimeService', () => {
|
||||
[childId]: makeWorktreeMeta({ instanceId: 'child-instance', ...scenario.childMeta }),
|
||||
[parentId]: makeWorktreeMeta({ instanceId: 'parent-instance', ...scenario.parentMeta })
|
||||
}
|
||||
const setWorktreeLineage = vi.fn()
|
||||
const setWorktreeLineage = vi.fn(
|
||||
(_target: HostWorktreeTarget, lineage: WorktreeLineage) => lineage
|
||||
)
|
||||
const setWorkspaceLineage = vi.fn()
|
||||
const runtimeStore = {
|
||||
...store,
|
||||
@@ -333,7 +345,7 @@ describe('OrcaRuntimeService', () => {
|
||||
getRepo: (id: string) => repos.find((repo) => repo.id === id),
|
||||
getAllWorktreeMeta: () => metaById,
|
||||
getWorktreeMeta: (worktreeId: string) => metaById[worktreeId],
|
||||
setWorktreeMeta: (worktreeId: string, meta: Partial<WorktreeMeta>) => {
|
||||
setWorktreeMeta: ({ id: worktreeId }: HostWorktreeTarget, meta: Partial<WorktreeMeta>) => {
|
||||
metaById[worktreeId] = { ...metaById[worktreeId], ...meta }
|
||||
return metaById[worktreeId]
|
||||
},
|
||||
@@ -353,7 +365,7 @@ describe('OrcaRuntimeService', () => {
|
||||
if (scenario.accepted) {
|
||||
await update
|
||||
expect(setWorktreeLineage).toHaveBeenCalledWith(
|
||||
childId,
|
||||
hostWorktreeTarget({ id: childId, hostId: 'local' }),
|
||||
expect.objectContaining({ parentWorktreeId: parentId })
|
||||
)
|
||||
expect(setWorkspaceLineage).toHaveBeenCalled()
|
||||
@@ -371,17 +383,15 @@ describe('OrcaRuntimeService', () => {
|
||||
[childId]: makeWorktreeMeta({ instanceId: 'child-instance' })
|
||||
}
|
||||
const removeWorktreeLineage = vi.fn()
|
||||
const removeWorkspaceLineage = vi.fn()
|
||||
const runtimeStore = {
|
||||
...store,
|
||||
getAllWorktreeMeta: () => metaById,
|
||||
getWorktreeMeta: (worktreeId: string) => metaById[worktreeId],
|
||||
setWorktreeMeta: (worktreeId: string, meta: Partial<WorktreeMeta>) => {
|
||||
setWorktreeMeta: ({ id: worktreeId }: HostWorktreeTarget, meta: Partial<WorktreeMeta>) => {
|
||||
metaById[worktreeId] = { ...metaById[worktreeId], ...meta }
|
||||
return metaById[worktreeId]
|
||||
},
|
||||
removeWorktreeLineage,
|
||||
removeWorkspaceLineage
|
||||
removeWorktreeLineage
|
||||
}
|
||||
vi.mocked(listWorktrees).mockResolvedValue([
|
||||
{
|
||||
@@ -398,7 +408,8 @@ describe('OrcaRuntimeService', () => {
|
||||
lineage: { noParent: true }
|
||||
})
|
||||
|
||||
expect(removeWorktreeLineage).toHaveBeenCalledWith(childId)
|
||||
expect(removeWorkspaceLineage).toHaveBeenCalledWith(`worktree:${childId}`)
|
||||
expect(removeWorktreeLineage).toHaveBeenCalledWith(
|
||||
hostWorktreeTarget({ id: childId, hostId: 'local' })
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -20,6 +20,7 @@ import {
|
||||
makeWorktreeMeta,
|
||||
store
|
||||
} from '../orca-runtime-test-fixtures.spec'
|
||||
import type { HostWorktreeTarget } from '../../../shared/worktree/host-qualified-identity'
|
||||
|
||||
describe('OrcaRuntimeService', () => {
|
||||
it('creates additional workspace metadata for folder-mode repos through runtime create', async () => {
|
||||
@@ -47,11 +48,11 @@ describe('OrcaRuntimeService', () => {
|
||||
getRepo: (id: string) => (id === folderRepo.id ? folderRepo : undefined),
|
||||
getAllWorktreeMeta: () => metaById,
|
||||
getWorktreeMeta: (worktreeId: string) => metaById[worktreeId],
|
||||
setWorktreeMeta: (worktreeId: string, meta: Partial<WorktreeMeta>) => {
|
||||
setWorktreeMeta: ({ id: worktreeId }: HostWorktreeTarget, meta: Partial<WorktreeMeta>) => {
|
||||
metaById[worktreeId] = { ...(metaById[worktreeId] ?? makeWorktreeMeta()), ...meta }
|
||||
return metaById[worktreeId]
|
||||
},
|
||||
removeWorktreeMeta: (worktreeId: string) => {
|
||||
removeWorktreeMeta: ({ id: worktreeId }: HostWorktreeTarget) => {
|
||||
delete metaById[worktreeId]
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -17,6 +17,7 @@ import {
|
||||
store,
|
||||
withPlatform
|
||||
} from '../orca-runtime-test-fixtures.spec'
|
||||
import type { HostWorktreeTarget } from '../../../shared/worktree/host-qualified-identity'
|
||||
|
||||
describe('OrcaRuntimeService', () => {
|
||||
it('tui-idle times out when PTY data has no agent OSC title transitions', async () => {
|
||||
@@ -268,7 +269,7 @@ describe('OrcaRuntimeService', () => {
|
||||
...store,
|
||||
getAllWorktreeMeta: () => metaById,
|
||||
getWorktreeMeta: (worktreeId: string) => metaById[worktreeId],
|
||||
setWorktreeMeta: (worktreeId: string, meta: Partial<WorktreeMeta>) => {
|
||||
setWorktreeMeta: ({ id: worktreeId }: HostWorktreeTarget, meta: Partial<WorktreeMeta>) => {
|
||||
metaById[worktreeId] = { ...(metaById[worktreeId] ?? makeWorktreeMeta()), ...meta }
|
||||
return metaById[worktreeId]
|
||||
},
|
||||
|
||||
@@ -17,6 +17,10 @@ import {
|
||||
makeWorktreeMeta,
|
||||
store
|
||||
} from '../orca-runtime-test-fixtures.spec'
|
||||
import {
|
||||
hostWorktreeTarget,
|
||||
type HostWorktreeTarget
|
||||
} from '../../../shared/worktree/host-qualified-identity'
|
||||
|
||||
describe('OrcaRuntimeService', () => {
|
||||
it('reports the wake as unsupported when a phone activates a worktree on headless serve', async () => {
|
||||
@@ -138,15 +142,19 @@ describe('OrcaRuntimeService', () => {
|
||||
const metaById: Record<string, WorktreeMeta> = {
|
||||
[TEST_WORKTREE_ID]: makeWorktreeMeta({ isUnread: false, instanceId: 'wt-instance' })
|
||||
}
|
||||
const setWorktreeMeta = vi.fn((worktreeId: string, meta: Partial<WorktreeMeta>) => {
|
||||
metaById[worktreeId] = { ...(metaById[worktreeId] ?? makeWorktreeMeta()), ...meta }
|
||||
return metaById[worktreeId]
|
||||
})
|
||||
const setWorktreeMeta = vi.fn(
|
||||
({ id: worktreeId }: HostWorktreeTarget, meta: Partial<WorktreeMeta>) => {
|
||||
metaById[worktreeId] = { ...(metaById[worktreeId] ?? makeWorktreeMeta()), ...meta }
|
||||
return metaById[worktreeId]
|
||||
}
|
||||
)
|
||||
const worktreesChanged = vi.fn()
|
||||
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: a partial store mock; the code under test reads only the members it defines.
|
||||
const runtime = new OrcaRuntimeService({
|
||||
...store,
|
||||
getAllWorktreeMeta: () => metaById,
|
||||
getWorktreeMeta: (worktreeId: string) => metaById[worktreeId],
|
||||
getWorktreeMetaForHost: (worktreeId: string) => metaById[worktreeId],
|
||||
setWorktreeMeta
|
||||
} as never)
|
||||
runtime.setNotifier({
|
||||
@@ -180,7 +188,10 @@ describe('OrcaRuntimeService', () => {
|
||||
await runtime.activateManagedWorktree(`id:${TEST_WORKTREE_ID}`, { notifyClients: false })
|
||||
|
||||
expect(setWorktreeMeta).toHaveBeenCalledTimes(1)
|
||||
expect(setWorktreeMeta).toHaveBeenCalledWith(TEST_WORKTREE_ID, { isUnread: false })
|
||||
expect(setWorktreeMeta).toHaveBeenCalledWith(
|
||||
hostWorktreeTarget({ id: TEST_WORKTREE_ID, hostId: 'local' }),
|
||||
{ isUnread: false }
|
||||
)
|
||||
expect(worktreesChanged).toHaveBeenCalledTimes(1)
|
||||
expect(worktreesChanged).toHaveBeenCalledWith(TEST_REPO_ID)
|
||||
})
|
||||
@@ -189,14 +200,18 @@ describe('OrcaRuntimeService', () => {
|
||||
const metaById: Record<string, WorktreeMeta> = {
|
||||
[TEST_WORKTREE_ID]: makeWorktreeMeta({ isUnread: true })
|
||||
}
|
||||
const setWorktreeMeta = vi.fn((worktreeId: string, meta: Partial<WorktreeMeta>) => {
|
||||
metaById[worktreeId] = { ...(metaById[worktreeId] ?? makeWorktreeMeta()), ...meta }
|
||||
return metaById[worktreeId]
|
||||
})
|
||||
const setWorktreeMeta = vi.fn(
|
||||
({ id: worktreeId }: HostWorktreeTarget, meta: Partial<WorktreeMeta>) => {
|
||||
metaById[worktreeId] = { ...(metaById[worktreeId] ?? makeWorktreeMeta()), ...meta }
|
||||
return metaById[worktreeId]
|
||||
}
|
||||
)
|
||||
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: a partial store mock; the code under test reads only the members it defines.
|
||||
const runtime = new OrcaRuntimeService({
|
||||
...store,
|
||||
getAllWorktreeMeta: () => metaById,
|
||||
getWorktreeMeta: (worktreeId: string) => metaById[worktreeId],
|
||||
getWorktreeMetaForHost: (worktreeId: string) => metaById[worktreeId],
|
||||
setWorktreeMeta
|
||||
} as never)
|
||||
runtime.setNotifier({
|
||||
|
||||
@@ -12,6 +12,10 @@ import {
|
||||
makeWorktreeMeta,
|
||||
store
|
||||
} from '../orca-runtime-test-fixtures.spec'
|
||||
import {
|
||||
hostWorktreeTarget,
|
||||
type HostWorktreeTarget
|
||||
} from '../../../shared/worktree/host-qualified-identity'
|
||||
|
||||
describe('OrcaRuntimeService', () => {
|
||||
it('retires exited saved PTY bindings instead of publishing a pending ghost', async () => {
|
||||
@@ -528,16 +532,20 @@ describe('OrcaRuntimeService', () => {
|
||||
const metaById: Record<string, WorktreeMeta> = {
|
||||
[TEST_WORKTREE_ID]: makeWorktreeMeta({ isUnread: true })
|
||||
}
|
||||
const setWorktreeMeta = vi.fn((worktreeId: string, meta: Partial<WorktreeMeta>) => {
|
||||
metaById[worktreeId] = { ...(metaById[worktreeId] ?? makeWorktreeMeta()), ...meta }
|
||||
return metaById[worktreeId]
|
||||
})
|
||||
const setWorktreeMeta = vi.fn(
|
||||
({ id: worktreeId }: HostWorktreeTarget, meta: Partial<WorktreeMeta>) => {
|
||||
metaById[worktreeId] = { ...(metaById[worktreeId] ?? makeWorktreeMeta()), ...meta }
|
||||
return metaById[worktreeId]
|
||||
}
|
||||
)
|
||||
const activateWorktree = vi.fn()
|
||||
const worktreesChanged = vi.fn()
|
||||
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: a partial store mock; the code under test reads only the members it defines.
|
||||
const runtime = new OrcaRuntimeService({
|
||||
...store,
|
||||
getAllWorktreeMeta: () => metaById,
|
||||
getWorktreeMeta: (worktreeId: string) => metaById[worktreeId],
|
||||
getWorktreeMetaForHost: (worktreeId: string) => metaById[worktreeId],
|
||||
setWorktreeMeta
|
||||
} as never)
|
||||
runtime.setNotifier({
|
||||
@@ -560,7 +568,10 @@ describe('OrcaRuntimeService', () => {
|
||||
|
||||
await runtime.activateManagedWorktree(`id:${TEST_WORKTREE_ID}`, { notifyClients: false })
|
||||
|
||||
expect(setWorktreeMeta).toHaveBeenCalledWith(TEST_WORKTREE_ID, { isUnread: false })
|
||||
expect(setWorktreeMeta).toHaveBeenCalledWith(
|
||||
hostWorktreeTarget({ id: TEST_WORKTREE_ID, hostId: 'local' }),
|
||||
{ isUnread: false }
|
||||
)
|
||||
expect(metaById[TEST_WORKTREE_ID]?.isUnread).toBe(false)
|
||||
expect(worktreesChanged).toHaveBeenCalledWith(TEST_REPO_ID)
|
||||
expect(activateWorktree).not.toHaveBeenCalled()
|
||||
@@ -573,10 +584,12 @@ describe('OrcaRuntimeService', () => {
|
||||
}
|
||||
const activateWorktree = vi.fn()
|
||||
const resumeSleepingAgents = vi.fn()
|
||||
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: a partial store mock; the code under test reads only the members it defines.
|
||||
const runtime = new OrcaRuntimeService({
|
||||
...store,
|
||||
getAllWorktreeMeta: () => metaById,
|
||||
getWorktreeMeta: (worktreeId: string) => metaById[worktreeId],
|
||||
getWorktreeMetaForHost: (worktreeId: string) => metaById[worktreeId],
|
||||
getWorkspaceSession: () => ({
|
||||
...getDefaultWorkspaceSession(),
|
||||
sleepingAgentSessionsByPaneKey: {
|
||||
|
||||
@@ -15,6 +15,7 @@ import {
|
||||
makeWorktreeMeta,
|
||||
store
|
||||
} from '../orca-runtime-test-fixtures.spec'
|
||||
import type { HostWorktreeTarget } from '../../../shared/worktree/host-qualified-identity'
|
||||
|
||||
// Why: this process serves no SSH git, so an SSH repo lists its stored rows.
|
||||
function storedWorktreeMeta(
|
||||
@@ -254,7 +255,7 @@ describe('OrcaRuntimeService', () => {
|
||||
getRepo,
|
||||
getAllWorktreeMeta: () => metaById,
|
||||
getWorktreeMeta: (worktreeId: string) => metaById[worktreeId],
|
||||
setWorktreeMeta: (worktreeId: string, meta: Partial<WorktreeMeta>) => {
|
||||
setWorktreeMeta: ({ id: worktreeId }: HostWorktreeTarget, meta: Partial<WorktreeMeta>) => {
|
||||
metaById[worktreeId] = { ...(metaById[worktreeId] ?? makeWorktreeMeta()), ...meta }
|
||||
return metaById[worktreeId]
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import {
|
||||
makeWorktreeMeta,
|
||||
store
|
||||
} from '../orca-runtime-test-fixtures.spec'
|
||||
import type { HostWorktreeTarget } from '../../../shared/worktree/host-qualified-identity'
|
||||
|
||||
describe('OrcaRuntimeService', () => {
|
||||
it('rejects when every exact PR branch checkout path suffix is occupied', async () => {
|
||||
@@ -93,7 +94,7 @@ describe('OrcaRuntimeService', () => {
|
||||
...createFolderWorkspaceRuntimeStore(),
|
||||
getAllWorktreeMeta: () => metaById,
|
||||
getWorktreeMeta: (worktreeId: string) => metaById[worktreeId],
|
||||
setWorktreeMeta: (worktreeId: string, meta: Partial<WorktreeMeta>) => {
|
||||
setWorktreeMeta: ({ id: worktreeId }: HostWorktreeTarget, meta: Partial<WorktreeMeta>) => {
|
||||
metaById[worktreeId] = { ...(metaById[worktreeId] ?? makeWorktreeMeta()), ...meta }
|
||||
return metaById[worktreeId]
|
||||
},
|
||||
@@ -138,7 +139,7 @@ describe('OrcaRuntimeService', () => {
|
||||
...createFolderWorkspaceRuntimeStore(),
|
||||
getAllWorktreeMeta: () => metaById,
|
||||
getWorktreeMeta: (worktreeId: string) => metaById[worktreeId],
|
||||
setWorktreeMeta: (worktreeId: string, meta: Partial<WorktreeMeta>) => {
|
||||
setWorktreeMeta: ({ id: worktreeId }: HostWorktreeTarget, meta: Partial<WorktreeMeta>) => {
|
||||
metaById[worktreeId] = { ...(metaById[worktreeId] ?? makeWorktreeMeta()), ...meta }
|
||||
return metaById[worktreeId]
|
||||
},
|
||||
|
||||
+4
-1
@@ -42,6 +42,7 @@ import {
|
||||
syncSinglePty
|
||||
} from '../orca-runtime-test-fixtures.spec'
|
||||
import { createWorktreeRemovalRuntime } from '../orca-runtime-test-scenario-builders.spec'
|
||||
import { hostWorktreeTarget } from '../../../shared/worktree/host-qualified-identity'
|
||||
|
||||
// Why: these fixtures register an SSH provider, which models a connected relay session — and a
|
||||
// connected session has always read the host's `$HOME`. The removal guards refuse without it.
|
||||
@@ -394,7 +395,9 @@ describe('OrcaRuntimeService', () => {
|
||||
})
|
||||
// The repo resolved to the local host, so the metadata purge names it —
|
||||
// an unqualified purge would evict a same-id row owned by another host.
|
||||
expect(removeWorktreeMeta).toHaveBeenCalledWith(worktreeId, 'local')
|
||||
expect(removeWorktreeMeta).toHaveBeenCalledWith(
|
||||
hostWorktreeTarget({ id: worktreeId, hostId: 'local' })
|
||||
)
|
||||
} finally {
|
||||
gitSpy.mockRestore()
|
||||
}
|
||||
|
||||
+13
-4
@@ -30,6 +30,7 @@ import {
|
||||
store
|
||||
} from '../orca-runtime-test-fixtures.spec'
|
||||
import { createWorktreeRemovalRuntime } from '../orca-runtime-test-scenario-builders.spec'
|
||||
import { hostWorktreeTarget } from '../../../shared/worktree/host-qualified-identity'
|
||||
|
||||
// Why: these fixtures register an SSH provider, which models a connected relay session — and a
|
||||
// connected session has always read the host's `$HOME`. The removal guards refuse without it.
|
||||
@@ -226,7 +227,9 @@ describe('OrcaRuntimeService', () => {
|
||||
expect(removeWorktree).not.toHaveBeenCalled()
|
||||
// The repo resolved to the local host, so the metadata purge names it —
|
||||
// an unqualified purge would evict a same-id row owned by another host.
|
||||
expect(removeWorktreeMeta).toHaveBeenCalledWith(worktreeId, 'local')
|
||||
expect(removeWorktreeMeta).toHaveBeenCalledWith(
|
||||
hostWorktreeTarget({ id: worktreeId, hostId: 'local' })
|
||||
)
|
||||
expect(deleteWorktreeHistoryDirMock).toHaveBeenCalledWith(worktreeId)
|
||||
expect(invalidateAuthorizedRootsCacheMock).toHaveBeenCalledWith(runtimeStore, TEST_REPO_ID)
|
||||
expect(notifier.worktreesChanged).toHaveBeenCalledWith(TEST_REPO_ID)
|
||||
@@ -252,7 +255,9 @@ describe('OrcaRuntimeService', () => {
|
||||
expect(removeWorktree).not.toHaveBeenCalled()
|
||||
// The repo resolved to the local host, so the metadata purge names it —
|
||||
// an unqualified purge would evict a same-id row owned by another host.
|
||||
expect(removeWorktreeMeta).toHaveBeenCalledWith(worktreeId, 'local')
|
||||
expect(removeWorktreeMeta).toHaveBeenCalledWith(
|
||||
hostWorktreeTarget({ id: worktreeId, hostId: 'local' })
|
||||
)
|
||||
expect(deleteWorktreeHistoryDirMock).toHaveBeenCalledWith(worktreeId)
|
||||
expect(invalidateAuthorizedRootsCacheMock).toHaveBeenCalledWith(runtimeStore, TEST_REPO_ID)
|
||||
expect(notifier.worktreesChanged).toHaveBeenCalledWith(TEST_REPO_ID)
|
||||
@@ -313,7 +318,9 @@ describe('OrcaRuntimeService', () => {
|
||||
expect(removeWorktree).not.toHaveBeenCalled()
|
||||
// The repo resolved to the local host, so the metadata purge names it —
|
||||
// an unqualified purge would evict a same-id row owned by another host.
|
||||
expect(removeWorktreeMeta).toHaveBeenCalledWith(worktreeId, 'local')
|
||||
expect(removeWorktreeMeta).toHaveBeenCalledWith(
|
||||
hostWorktreeTarget({ id: worktreeId, hostId: 'local' })
|
||||
)
|
||||
expect(deleteWorktreeHistoryDirMock).toHaveBeenCalledWith(worktreeId)
|
||||
expect(invalidateAuthorizedRootsCacheMock).toHaveBeenCalled()
|
||||
expect(notifier.worktreesChanged).toHaveBeenCalledWith(TEST_REPO_ID)
|
||||
@@ -386,7 +393,9 @@ describe('OrcaRuntimeService', () => {
|
||||
expect(removeWorktree).not.toHaveBeenCalled()
|
||||
// The repo resolved to the local host, so the metadata purge names it —
|
||||
// an unqualified purge would evict a same-id row owned by another host.
|
||||
expect(removeWorktreeMeta).toHaveBeenCalledWith(worktreeId, 'local')
|
||||
expect(removeWorktreeMeta).toHaveBeenCalledWith(
|
||||
hostWorktreeTarget({ id: worktreeId, hostId: 'local' })
|
||||
)
|
||||
expect(deleteWorktreeHistoryDirMock).toHaveBeenCalledWith(worktreeId)
|
||||
expect(invalidateAuthorizedRootsCacheMock).toHaveBeenCalled()
|
||||
expect(notifier.worktreesChanged).toHaveBeenCalledWith(TEST_REPO_ID)
|
||||
|
||||
+10
-4
@@ -26,6 +26,10 @@ import {
|
||||
writeFile
|
||||
} from '../orca-runtime-test-mocks.spec'
|
||||
import type { WorktreeMeta } from '../orca-runtime-test-mocks.spec'
|
||||
import {
|
||||
hostWorktreeTarget,
|
||||
type HostWorktreeTarget
|
||||
} from '../../../shared/worktree/host-qualified-identity'
|
||||
import {
|
||||
TEST_REPO_ID,
|
||||
TEST_REPO_PATH,
|
||||
@@ -62,7 +66,7 @@ describe('OrcaRuntimeService', () => {
|
||||
orcaCreationSource: 'ssh'
|
||||
})
|
||||
}
|
||||
const removeWorktreeMeta = vi.fn((id: string) => {
|
||||
const removeWorktreeMeta = vi.fn(({ id }: HostWorktreeTarget) => {
|
||||
delete metaById[id]
|
||||
})
|
||||
const runtimeStore = {
|
||||
@@ -71,7 +75,7 @@ describe('OrcaRuntimeService', () => {
|
||||
getRepo: (id: string) => (id === repo.id ? repo : undefined),
|
||||
getAllWorktreeMeta: () => metaById,
|
||||
getWorktreeMeta: (id: string) => metaById[id],
|
||||
setWorktreeMeta: (id: string, meta: Partial<WorktreeMeta>) => {
|
||||
setWorktreeMeta: ({ id }: HostWorktreeTarget, meta: Partial<WorktreeMeta>) => {
|
||||
metaById[id] = { ...(metaById[id] ?? makeWorktreeMeta()), ...meta }
|
||||
return metaById[id]
|
||||
},
|
||||
@@ -405,7 +409,9 @@ describe('OrcaRuntimeService', () => {
|
||||
await rm(orphanPath, { recursive: true, force: true })
|
||||
vi.mocked(listWorktrees).mockResolvedValue([])
|
||||
await expect(runtime.removeManagedWorktree(worktreeId)).resolves.toEqual({})
|
||||
expect(removeWorktreeMeta).toHaveBeenCalledWith(worktreeId, 'local')
|
||||
expect(removeWorktreeMeta).toHaveBeenCalledWith(
|
||||
hostWorktreeTarget({ id: worktreeId, hostId: 'local' })
|
||||
)
|
||||
} finally {
|
||||
gitSpy.mockRestore()
|
||||
await rm(parentDir, { recursive: true, force: true })
|
||||
@@ -747,7 +753,7 @@ describe('OrcaRuntimeService', () => {
|
||||
updateRepo: () => undefined as never,
|
||||
getAllWorktreeMeta: () => metaById,
|
||||
getWorktreeMeta: (worktreeId: string) => metaById[worktreeId],
|
||||
setWorktreeMeta: (worktreeId: string, meta: Partial<WorktreeMeta>) => {
|
||||
setWorktreeMeta: ({ id: worktreeId }: HostWorktreeTarget, meta: Partial<WorktreeMeta>) => {
|
||||
const existingMeta = metaById[worktreeId]
|
||||
const nextMeta: WorktreeMeta = {
|
||||
displayName: meta.displayName ?? existingMeta?.displayName ?? '',
|
||||
|
||||
@@ -37,6 +37,7 @@ import {
|
||||
import { createWorktreeRemovalRuntime } from '../orca-runtime-test-scenario-builders.spec'
|
||||
import { getLocalWorktreeScanGeneration } from '../../local-worktree-scan-generation'
|
||||
import { makeAgentStatusStoreWiring } from '../agent-status-store-wiring.test-fixture'
|
||||
import { hostWorktreeTarget } from '../../../shared/worktree/host-qualified-identity'
|
||||
|
||||
describe('OrcaRuntimeService', () => {
|
||||
it('creates the first terminal by id when duplicate repo entries expose the same path', async () => {
|
||||
@@ -573,7 +574,9 @@ describe('OrcaRuntimeService', () => {
|
||||
warning: expect.stringContaining(TEST_WORKTREE_PATH)
|
||||
})
|
||||
|
||||
expect(removeWorktreeMeta).toHaveBeenCalledWith(TEST_WORKTREE_ID, 'runtime:env-1')
|
||||
expect(removeWorktreeMeta).toHaveBeenCalledWith(
|
||||
hostWorktreeTarget({ id: TEST_WORKTREE_ID, hostId: 'runtime:env-1' })
|
||||
)
|
||||
expect(deleteWorktreeHistoryDirMock).toHaveBeenCalledWith(TEST_WORKTREE_ID)
|
||||
expect(invalidateAuthorizedRootsCacheMock).toHaveBeenCalled()
|
||||
expect(removeWorktree).not.toHaveBeenCalled()
|
||||
|
||||
@@ -25,6 +25,7 @@ import {
|
||||
_settlePendingWorktreeRemovalsForTests
|
||||
} from '../../worktree-background-removal'
|
||||
import { RuntimeWorktreeRemovalInFlight } from '../runtime-worktree-removal-in-flight'
|
||||
import type { HostWorktreeTarget } from '../../../shared/worktree/host-qualified-identity'
|
||||
|
||||
const REMOTE_REPO_PATH = '/remote/repo'
|
||||
|
||||
@@ -42,8 +43,8 @@ function makeRemoteRepoStore(
|
||||
const metaById: Record<string, WorktreeMeta> = {
|
||||
[TEST_WORKTREE_ID]: makeWorktreeMeta({ hostId: executionHostId, ...metaOverrides })
|
||||
}
|
||||
const removeWorktreeMeta = vi.fn((worktreeId: string, hostId?: string) => {
|
||||
if (!hostId || metaById[worktreeId]?.hostId === hostId) {
|
||||
const removeWorktreeMeta = vi.fn(({ id: worktreeId, hostId }: HostWorktreeTarget) => {
|
||||
if (metaById[worktreeId]?.hostId === hostId) {
|
||||
delete metaById[worktreeId]
|
||||
}
|
||||
})
|
||||
@@ -57,7 +58,7 @@ function makeRemoteRepoStore(
|
||||
getRepo: (id: string) => (id === repo.id ? repo : undefined),
|
||||
getAllWorktreeMeta: () => metaById,
|
||||
getWorktreeMeta: (worktreeId: string) => metaById[worktreeId],
|
||||
setWorktreeMeta: (worktreeId: string, meta: Partial<WorktreeMeta>) => {
|
||||
setWorktreeMeta: ({ id: worktreeId }: HostWorktreeTarget, meta: Partial<WorktreeMeta>) => {
|
||||
metaById[worktreeId] = { ...(metaById[worktreeId] ?? makeWorktreeMeta()), ...meta }
|
||||
return metaById[worktreeId]
|
||||
},
|
||||
|
||||
@@ -30,6 +30,7 @@ import {
|
||||
makeWorktreeMeta,
|
||||
store
|
||||
} from '../orca-runtime-test-fixtures.spec'
|
||||
import type { HostWorktreeTarget } from '../../../shared/worktree/host-qualified-identity'
|
||||
|
||||
const LOCAL_CHILD_REPO = {
|
||||
id: 'child-repo',
|
||||
@@ -191,7 +192,7 @@ describe('OrcaRuntimeService', () => {
|
||||
getRepo: () => remoteRepo,
|
||||
getAllWorktreeMeta: () => metaById,
|
||||
getWorktreeMeta: (worktreeId: string) => metaById[worktreeId],
|
||||
setWorktreeMeta: (worktreeId: string, meta: Partial<WorktreeMeta>) => {
|
||||
setWorktreeMeta: ({ id: worktreeId }: HostWorktreeTarget, meta: Partial<WorktreeMeta>) => {
|
||||
metaById[worktreeId] = { ...metaById[worktreeId], ...meta }
|
||||
return metaById[worktreeId]
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import {
|
||||
store,
|
||||
makeRuntimeStoreWithWorkspaceSession
|
||||
} from '../orca-runtime-test-fixtures.spec'
|
||||
import type { HostWorktreeTarget } from '../../../shared/worktree/host-qualified-identity'
|
||||
|
||||
describe('OrcaRuntimeService', () => {
|
||||
it('does not surface the new workspace when a background create opens Setup', async () => {
|
||||
@@ -193,7 +194,7 @@ describe('OrcaRuntimeService', () => {
|
||||
...store,
|
||||
getAllWorktreeMeta: () => metaById,
|
||||
getWorktreeMeta: (worktreeId: string) => metaById[worktreeId],
|
||||
setWorktreeMeta: (worktreeId: string, meta: Partial<WorktreeMeta>) => {
|
||||
setWorktreeMeta: ({ id: worktreeId }: HostWorktreeTarget, meta: Partial<WorktreeMeta>) => {
|
||||
metaById[worktreeId] = { ...(metaById[worktreeId] ?? makeWorktreeMeta()), ...meta }
|
||||
return metaById[worktreeId]
|
||||
}
|
||||
@@ -256,7 +257,7 @@ describe('OrcaRuntimeService', () => {
|
||||
...store,
|
||||
getAllWorktreeMeta: () => metaById,
|
||||
getWorktreeMeta: (worktreeId: string) => metaById[worktreeId],
|
||||
setWorktreeMeta: (worktreeId: string, meta: Partial<WorktreeMeta>) => {
|
||||
setWorktreeMeta: ({ id: worktreeId }: HostWorktreeTarget, meta: Partial<WorktreeMeta>) => {
|
||||
metaById[worktreeId] = { ...(metaById[worktreeId] ?? makeWorktreeMeta()), ...meta }
|
||||
return metaById[worktreeId]
|
||||
}
|
||||
@@ -331,7 +332,7 @@ describe('OrcaRuntimeService', () => {
|
||||
...store,
|
||||
getAllWorktreeMeta: () => metaById,
|
||||
getWorktreeMeta: (worktreeId: string) => metaById[worktreeId],
|
||||
setWorktreeMeta: (worktreeId: string, meta: Partial<WorktreeMeta>) => {
|
||||
setWorktreeMeta: ({ id: worktreeId }: HostWorktreeTarget, meta: Partial<WorktreeMeta>) => {
|
||||
metaById[worktreeId] = { ...(metaById[worktreeId] ?? makeWorktreeMeta()), ...meta }
|
||||
return metaById[worktreeId]
|
||||
}
|
||||
@@ -419,7 +420,7 @@ describe('OrcaRuntimeService', () => {
|
||||
...store,
|
||||
getAllWorktreeMeta: () => metaById,
|
||||
getWorktreeMeta: (worktreeId: string) => metaById[worktreeId],
|
||||
setWorktreeMeta: (worktreeId: string, meta: Partial<WorktreeMeta>) => {
|
||||
setWorktreeMeta: ({ id: worktreeId }: HostWorktreeTarget, meta: Partial<WorktreeMeta>) => {
|
||||
metaById[worktreeId] = { ...(metaById[worktreeId] ?? makeWorktreeMeta()), ...meta }
|
||||
return metaById[worktreeId]
|
||||
}
|
||||
@@ -515,7 +516,7 @@ describe('OrcaRuntimeService', () => {
|
||||
}),
|
||||
getAllWorktreeMeta: () => metaById,
|
||||
getWorktreeMeta: (worktreeId: string) => metaById[worktreeId],
|
||||
setWorktreeMeta: (worktreeId: string, meta: Partial<WorktreeMeta>) => {
|
||||
setWorktreeMeta: ({ id: worktreeId }: HostWorktreeTarget, meta: Partial<WorktreeMeta>) => {
|
||||
metaById[worktreeId] = { ...(metaById[worktreeId] ?? makeWorktreeMeta()), ...meta }
|
||||
return metaById[worktreeId]
|
||||
}
|
||||
@@ -770,7 +771,7 @@ describe('OrcaRuntimeService', () => {
|
||||
}),
|
||||
getAllWorktreeMeta: () => metaById,
|
||||
getWorktreeMeta: (worktreeId: string) => metaById[worktreeId],
|
||||
setWorktreeMeta: (worktreeId: string, meta: Partial<WorktreeMeta>) => {
|
||||
setWorktreeMeta: ({ id: worktreeId }: HostWorktreeTarget, meta: Partial<WorktreeMeta>) => {
|
||||
metaById[worktreeId] = { ...(metaById[worktreeId] ?? makeWorktreeMeta()), ...meta }
|
||||
return metaById[worktreeId]
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import {
|
||||
store,
|
||||
makeRuntimeStoreWithWorkspaceSession
|
||||
} from '../orca-runtime-test-fixtures.spec'
|
||||
import type { HostWorktreeTarget } from '../../../shared/worktree/host-qualified-identity'
|
||||
|
||||
describe('OrcaRuntimeService', () => {
|
||||
it('sends follow-up prompts for CLI-created stdin-after-start startup agents', async () => {
|
||||
@@ -34,7 +35,7 @@ describe('OrcaRuntimeService', () => {
|
||||
}),
|
||||
getAllWorktreeMeta: () => metaById,
|
||||
getWorktreeMeta: (worktreeId: string) => metaById[worktreeId],
|
||||
setWorktreeMeta: (worktreeId: string, meta: Partial<WorktreeMeta>) => {
|
||||
setWorktreeMeta: ({ id: worktreeId }: HostWorktreeTarget, meta: Partial<WorktreeMeta>) => {
|
||||
metaById[worktreeId] = { ...(metaById[worktreeId] ?? makeWorktreeMeta()), ...meta }
|
||||
return metaById[worktreeId]
|
||||
}
|
||||
@@ -107,7 +108,7 @@ describe('OrcaRuntimeService', () => {
|
||||
}),
|
||||
getAllWorktreeMeta: () => metaById,
|
||||
getWorktreeMeta: (worktreeId: string) => metaById[worktreeId],
|
||||
setWorktreeMeta: (worktreeId: string, meta: Partial<WorktreeMeta>) => {
|
||||
setWorktreeMeta: ({ id: worktreeId }: HostWorktreeTarget, meta: Partial<WorktreeMeta>) => {
|
||||
metaById[worktreeId] = { ...(metaById[worktreeId] ?? makeWorktreeMeta()), ...meta }
|
||||
return metaById[worktreeId]
|
||||
}
|
||||
@@ -177,7 +178,7 @@ describe('OrcaRuntimeService', () => {
|
||||
}),
|
||||
getAllWorktreeMeta: () => metaById,
|
||||
getWorktreeMeta: (worktreeId: string) => metaById[worktreeId],
|
||||
setWorktreeMeta: (worktreeId: string, meta: Partial<WorktreeMeta>) => {
|
||||
setWorktreeMeta: ({ id: worktreeId }: HostWorktreeTarget, meta: Partial<WorktreeMeta>) => {
|
||||
metaById[worktreeId] = { ...(metaById[worktreeId] ?? makeWorktreeMeta()), ...meta }
|
||||
return metaById[worktreeId]
|
||||
}
|
||||
@@ -248,7 +249,7 @@ describe('OrcaRuntimeService', () => {
|
||||
}),
|
||||
getAllWorktreeMeta: () => metaById,
|
||||
getWorktreeMeta: (worktreeId: string) => metaById[worktreeId],
|
||||
setWorktreeMeta: (worktreeId: string, meta: Partial<WorktreeMeta>) => {
|
||||
setWorktreeMeta: ({ id: worktreeId }: HostWorktreeTarget, meta: Partial<WorktreeMeta>) => {
|
||||
metaById[worktreeId] = { ...(metaById[worktreeId] ?? makeWorktreeMeta()), ...meta }
|
||||
return metaById[worktreeId]
|
||||
}
|
||||
@@ -476,7 +477,7 @@ describe('OrcaRuntimeService', () => {
|
||||
}),
|
||||
getAllWorktreeMeta: () => metaById,
|
||||
getWorktreeMeta: (worktreeId: string) => metaById[worktreeId],
|
||||
setWorktreeMeta: (worktreeId: string, meta: Partial<WorktreeMeta>) => {
|
||||
setWorktreeMeta: ({ id: worktreeId }: HostWorktreeTarget, meta: Partial<WorktreeMeta>) => {
|
||||
metaById[worktreeId] = { ...(metaById[worktreeId] ?? makeWorktreeMeta()), ...meta }
|
||||
return metaById[worktreeId]
|
||||
}
|
||||
@@ -562,7 +563,7 @@ describe('OrcaRuntimeService', () => {
|
||||
}),
|
||||
getAllWorktreeMeta: () => metaById,
|
||||
getWorktreeMeta: (worktreeId: string) => metaById[worktreeId],
|
||||
setWorktreeMeta: (worktreeId: string, meta: Partial<WorktreeMeta>) => {
|
||||
setWorktreeMeta: ({ id: worktreeId }: HostWorktreeTarget, meta: Partial<WorktreeMeta>) => {
|
||||
metaById[worktreeId] = { ...(metaById[worktreeId] ?? makeWorktreeMeta()), ...meta }
|
||||
return metaById[worktreeId]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user