test: remove low-value persistence, browser and mobile tests (#43592)

Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
This commit is contained in:
OrcaWin
2026-11-17 04:45:07 -08:00
committed by GitHub
co-authored by OrcaWin
parent 00dee71bec
commit 787138074a
8 changed files with 2 additions and 658 deletions
@@ -88,15 +88,6 @@ it('clears a session this run may have loaded, and leaves its folder for the nex
expect(JSON.parse(readFileSync(pending, 'utf8'))).toEqual([folder])
})
it('deletes the folder at startup without loading its session', async () => {
const dependencies = browserRoutePartitionStorageDependencies(() => false, 'cold')
await dependencies.clearPartitionStorage(PARTITION)
await dependencies.removePartitionDirectory(folder)
expect(mocks.fromPartition).not.toHaveBeenCalled()
expect(existsSync(folder)).toBe(false)
})
it('collects cold orphan folders without opening sessions, preserving retained and listed scopes', async () => {
const store = currentBrowserRoutePartitionBindingStore()
const removedScope = deriveLocalSshBrowserRoutePartitionStorageScope({
@@ -7,13 +7,7 @@ import {
readGitCommonHeadIdentities,
type WorktreeHeadIdentityCache
} from './worktree-head-identity-reader'
import {
FULL_HEAD_IDENTITY_SCOPE,
headIdentityScopeForEntry,
LISTING_HEAD_IDENTITY_SCOPE,
mergeHeadIdentityScopes,
PRIMARY_HEAD_IDENTITY_SCOPE
} from './worktree-head-identity-scope'
import { FULL_HEAD_IDENTITY_SCOPE, headIdentityScopeForEntry } from './worktree-head-identity-scope'
const readIdentities = async (
...args: Parameters<typeof readGitCommonHeadIdentities>
@@ -84,21 +78,6 @@ describe('readGitCommonHeadIdentities (incremental)', () => {
return { commonDir, cache, pathA, pathB }
}
it('re-reads only the committing worktree and leaves the rest cached', async () => {
const { commonDir, cache, pathA, pathB } = await seed()
// Only wt-a is named by the event; wt-b must retain its cached branch identity.
await writeLooseRef(commonDir, 'refs/heads/feature-a', OID_D)
await writeLooseRef(commonDir, 'refs/heads/feature-b', OID_D)
const scoped = await readIdentities(commonDir, cache, headIdentityScopeForEntry('wt-a'))
expect(headOf(scoped, pathA)).toBe(OID_D)
expect(headOf(scoped, pathB)).toBe(OID_C)
const followUp = await readIdentities(commonDir, cache, headIdentityScopeForEntry('wt-b'))
expect(headOf(followUp, pathB)).toBe(OID_D)
})
it('picks up a branch switch through the entry scope', async () => {
const { commonDir, cache, pathA } = await seed()
await writeLooseRef(commonDir, 'refs/heads/other', OID_D)
@@ -113,39 +92,6 @@ describe('readGitCommonHeadIdentities (incremental)', () => {
})
})
it('adds an externally created worktree through the listing scope', async () => {
const { commonDir, cache, pathA } = await seed()
await writeLooseRef(commonDir, 'refs/heads/feature-c', OID_D)
const pathC = await addLinkedWorktree(commonDir, 'wt-c', 'ref: refs/heads/feature-c')
await writeLooseRef(commonDir, 'refs/heads/feature-a', OID_D)
const identities = await readIdentities(commonDir, cache, LISTING_HEAD_IDENTITY_SCOPE)
expect(headOf(identities, pathC)).toBe(OID_D)
expect(headOf(identities, pathA)).toBe(OID_B)
})
it('re-reads an admin entry whose name was removed and immediately reused', async () => {
const { commonDir, cache, pathA } = await seed()
// Coalesced remove/add can reuse an admin name; a listing refresh alone cannot retain its identity.
await rm(join(commonDir, 'worktrees', 'wt-a'), { recursive: true, force: true })
await writeLooseRef(commonDir, 'refs/heads/reused', OID_D)
const reusedPath = await addLinkedWorktree(commonDir, 'wt-a', 'ref: refs/heads/reused')
const identities = await readIdentities(
commonDir,
cache,
mergeHeadIdentityScopes(LISTING_HEAD_IDENTITY_SCOPE, headIdentityScopeForEntry('wt-a'))
)
expect(reusedPath).toBe(pathA)
expect(identities).toContainEqual({
worktreePath: reusedPath,
head: OID_D,
branch: 'refs/heads/reused'
})
})
it('needs the full scope, not a narrow one, to survive a packed-refs rewrite', async () => {
const { commonDir, cache, pathA, pathB } = await seed()
// Packed-ref rewrites can move every branch with no per-worktree event.
@@ -173,20 +119,6 @@ describe('readGitCommonHeadIdentities (incremental)', () => {
expect(headOf(identities, pathB)).toBe(OID_D)
})
it('keeps a worktree whose checkout was deleted behind Orca back', async () => {
const { commonDir, cache, pathA } = await seed()
// Checkout absence is a prunable-listing concern; Git may retain its admin metadata.
await rm(pathA, { recursive: true, force: true })
const identities = await readIdentities(
commonDir,
cache,
mergeHeadIdentityScopes(LISTING_HEAD_IDENTITY_SCOPE, headIdentityScopeForEntry('wt-a'))
)
expect(headOf(identities, pathA)).toBe(OID_B)
})
it('follows a branch shared by several worktrees without re-reading them', async () => {
const commonDir = await makeCommonDir()
await writeLooseRef(commonDir, 'refs/heads/shared', OID_B)
@@ -216,19 +148,6 @@ describe('readGitCommonHeadIdentities (incremental)', () => {
expect(headOf(identities, pathC)).toBe(OID_D)
})
it('propagates a primary-checkout head move to a linked worktree on the same branch', async () => {
const commonDir = await makeCommonDir()
const pathA = await addLinkedWorktree(commonDir, 'wt-a', 'ref: refs/heads/main')
const cache = createWorktreeHeadIdentityCache()
await readIdentities(commonDir, cache)
await writeLooseRef(commonDir, 'refs/heads/main', OID_D)
const identities = await readIdentities(commonDir, cache, PRIMARY_HEAD_IDENTITY_SCOPE)
expect(headOf(identities, dirname(commonDir))).toBe(OID_D)
expect(headOf(identities, pathA)).toBe(OID_D)
})
it('drops entries whose branch stopped resolving instead of serving a stale head', async () => {
const commonDir = await makeCommonDir()
await writeLooseRef(commonDir, 'refs/heads/shared', OID_B)
@@ -288,13 +207,4 @@ describe('readGitCommonHeadIdentities (incremental)', () => {
expect(headOf(identities, path)).toBe(OID_D)
})
it('matches admin entry names across case folding', async () => {
const { commonDir, cache, pathA } = await seed()
await writeLooseRef(commonDir, 'refs/heads/feature-a', OID_D)
const identities = await readIdentities(commonDir, cache, headIdentityScopeForEntry('WT-A'))
expect(headOf(identities, pathA)).toBe(OID_D)
})
})
@@ -1,11 +1,7 @@
import {
closeTestStores,
readPersistedState,
testState,
createStore,
dataFile,
writeDataFile,
readDataFile,
makeRepo,
makeWorkspaceLineage
} from '../persistence-test-harness'
@@ -17,7 +13,6 @@ import { createProfileStateStore } from '../profile-state/startup/profile-state-
import { ProfileStateAuthorityBootstrapError } from '../profile-state/recovery/profile-state-recovery-required'
import { restoreProfileStateJsonExport } from '../profile-state/legacy-json/profile-state-recovery'
import { acquireProfileStateMaintenance } from '../profile-state/access/profile-state-access'
import type { Repo } from '../../../shared/repository/repo-types'
import {
folderWorkspaceKey,
worktreeWorkspaceKey
@@ -187,41 +182,6 @@ describe('Store', () => {
})
})
describe('retired JSON backups', () => {
it.each(['sync', 'async'] as const)(
'leaves legacy JSON and backups unchanged during %s SQL writes',
async (flush) => {
writeDataFile({ repos: [makeRepo({ id: 'seed' })] })
const retained = readFileSync(dataFile())
const backup = `${dataFile()}.bak.0`
writeFileSync(backup, retained)
const store = createStore()
store.addRepo(makeRepo({ id: 'updated', path: '/updated' }))
if (flush === 'sync') {
store.flushOrThrow()
} else {
await store.flushPendingOrThrowAsync()
}
expect(readFileSync(dataFile())).toEqual(retained)
expect(readFileSync(backup)).toEqual(retained)
expect(existsSync(`${dataFile()}.bak.1`)).toBe(false)
const persisted = readDataFile() as { repos: Repo[] }
expect(persisted.repos.map((repo) => repo.id).sort()).toEqual(['seed', 'updated'])
}
)
it('does not create a JSON primary or backup for a fresh SQL profile', () => {
const store = createStore()
store.addRepo(makeRepo())
store.flushOrThrow()
expect(existsSync(dataFile())).toBe(false)
expect(existsSync(`${dataFile()}.bak.0`)).toBe(false)
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: The fixture registered r1 before flushing; its exported repos are Repo records.
expect((readDataFile() as { repos: Repo[] }).repos.map((repo) => repo.id)).toEqual(['r1'])
})
})
describe('legacy backup import and recovery', () => {
const recoveredStores: ReturnType<typeof createProfileStateStore>['store'][] = []
afterEach(async () => {
@@ -313,23 +273,4 @@ describe('Store', () => {
expect(store.getSettings().theme).toBe('dark')
})
})
describe('concurrent write serialization', () => {
it('persists both repo additions across debounced writes', async () => {
vi.useFakeTimers()
try {
const store = await createStore()
store.addRepo(makeRepo({ id: 'first' }))
vi.advanceTimersByTime(1000)
store.addRepo(makeRepo({ id: 'second', path: '/second' }))
vi.advanceTimersByTime(1000)
await store.waitForPendingWrite()
const persisted = readPersistedState()
expect(persisted.repos.map((r) => r.id).sort()).toEqual(['first', 'second'])
} finally {
vi.useRealTimers()
}
})
})
})
@@ -57,7 +57,6 @@ await import('../orca-runtime-tests/mobile-session-tabs-part-13.spec')
await import('../orca-runtime-tests/mobile-session-tabs-empty-headless-snapshot.spec')
await import('../orca-runtime-tests/mobile-session-tabs-windowless-sleep-resume.spec')
await import('../orca-runtime-tests/mobile-session-tabs-targeted-agent-resume.spec')
await import('../orca-runtime-tests/mobile-session-tabs-headless-wake-report.spec')
await import('../orca-runtime-tests/exit-retirement-activation.spec')
await import('../orca-runtime-tests/mobile-creation-and-orchestration.spec')
await import('../orca-runtime-tests/mobile-creation-and-orchestration-part-04.spec')
@@ -1,90 +0,0 @@
import { describe, expect, it, vi } from 'vitest'
import './runtime-test-module-registration.spec'
import { OrcaRuntimeService } from '../orca-runtime'
import { getDefaultWorkspaceSession } from '../../../shared/orca-profiles/constants'
import { electronMocks } from '../orca-runtime-test-mocks/setup.spec'
import type { SleepingAgentSessionRecord } from '../../../shared/agent-session/lifecycle/agent-session-resume'
import {
TEST_REPO_ID,
TEST_WINDOW_ID,
TEST_WORKTREE_ID,
makeRuntimeStoreWithWorkspaceSession,
store
} from './orca-runtime-test-fixtures.spec'
function makeRecord(origin: SleepingAgentSessionRecord['origin']): SleepingAgentSessionRecord {
return {
paneKey: 'tab-1:leaf-1',
tabId: 'tab-1',
worktreeId: TEST_WORKTREE_ID,
agent: 'codex',
providerSession: { key: 'session_id', id: 'session-1' },
prompt: 'test',
state: 'working',
capturedAt: 1,
updatedAt: 1,
...(origin ? { origin } : {})
}
}
async function activateOnHeadlessServe(
record: SleepingAgentSessionRecord,
ownerHostId: 'local' | 'ssh:ssh-1' = 'local'
): Promise<{ wake: string | undefined; readHostIds: (string | undefined)[] }> {
const repo = { ...store.getRepos()[0]!, executionHostId: ownerHostId }
const { runtimeStore } = makeRuntimeStoreWithWorkspaceSession(
{
...getDefaultWorkspaceSession(),
sleepingAgentSessionsByPaneKey: { [record.paneKey]: record }
},
ownerHostId
)
// Make host-less reads empty so only correct partition reads find the record.
const getWorkspaceSession = vi.fn((hostId?: string) =>
hostId === undefined ? getDefaultWorkspaceSession() : runtimeStore.getWorkspaceSession(hostId)
)
const runtime = new OrcaRuntimeService({
...runtimeStore,
getRepos: () => [repo],
getRepo: (id: string) => (id === TEST_REPO_ID ? repo : undefined),
getWorkspaceSession
})
electronMocks.BrowserWindow.fromId.mockReturnValue(null)
runtime.attachWindow(TEST_WINDOW_ID)
runtime.markGraphReady(TEST_WINDOW_ID)
const result = await runtime.activateManagedWorktree(`id:${TEST_WORKTREE_ID}`, {
notifyClients: false,
clientKind: 'mobile'
})
return {
wake: result.sleepingAgentWake,
readHostIds: getWorkspaceSession.mock.calls.map(([hostId]) => hostId)
}
}
describe('OrcaRuntimeService headless wake report', () => {
// Live/quit records are not sleep records and must not trigger false unwakeable warnings.
it.each(['live', 'quit'] as const)(
'reports no headless wake degradation for a worktree with only a %s record',
async (origin) => {
const { wake } = await activateOnHeadlessServe(makeRecord(origin))
expect(wake).toBe('not-applicable')
}
)
it('reports headless wake degradation for a legacy sleep record only a window wakes', async () => {
const { wake } = await activateOnHeadlessServe(makeRecord(undefined))
expect(wake).toBe('unsupported-headless')
})
it('reports a requested wake for a workspace sleep record, which main resumes', async () => {
const { wake } = await activateOnHeadlessServe(makeRecord('worktree-sleep'))
expect(wake).toBe('requested')
})
it('reads the sleep record from an SSH-host worktree partition', async () => {
const { wake, readHostIds } = await activateOnHeadlessServe(makeRecord(undefined), 'ssh:ssh-1')
expect(readHostIds).toContain('ssh:ssh-1')
expect(wake).toBe('unsupported-headless')
})
})
@@ -18,65 +18,6 @@ import {
} from './orca-runtime-test-fixtures.spec'
describe('OrcaRuntimeService', () => {
it('keeps title-only foreground work ahead of monitoring in another split pane', async () => {
const now = Date.now()
const tabId = 'split-tab'
const monitoringLeafId = '33333333-3333-4333-8333-333333333333'
const foregroundLeafId = '44444444-4444-4444-8444-444444444444'
const runtime = new OrcaRuntimeService(store, undefined, {
getAgentStatusSnapshot: () => [
{
paneKey: `${tabId}:${monitoringLeafId}`,
worktreeId: TEST_WORKTREE_ID,
tabId,
state: 'working',
workingMode: 'monitoring',
prompt: 'watch tests',
agentType: 'claude',
connectionId: null,
receivedAt: now,
stateStartedAt: now - 100
}
]
})
runtime.attachWindow(1)
await runtime.syncWindowGraph(1, {
tabs: [
{
tabId,
worktreeId: TEST_WORKTREE_ID,
title: 'Claude',
activeLeafId: monitoringLeafId,
layout: null
}
],
leaves: [
{
tabId,
worktreeId: TEST_WORKTREE_ID,
leafId: monitoringLeafId,
paneRuntimeId: 1,
ptyId: 'monitoring-pty',
paneTitle: 'claude'
},
{
tabId,
worktreeId: TEST_WORKTREE_ID,
leafId: foregroundLeafId,
paneRuntimeId: 2,
ptyId: 'foreground-pty',
paneTitle: 'claude working'
}
]
})
const { worktrees } = await runtime.getWorktreePs()
const summary = worktrees.find((worktree) => worktree.worktreeId === TEST_WORKTREE_ID)
expect(summary).toMatchObject({ status: 'working' })
expect(summary).not.toHaveProperty('workingMode')
})
it('suppresses restored-unconfirmed hook rows from worktree.ps', async () => {
const leafId = '33333333-3333-4333-8333-333333333333'
const now = Date.now()
@@ -268,50 +209,6 @@ describe('OrcaRuntimeService', () => {
})
})
it('keeps a hydrated row while its persisted session tab exists and no renderer graph is attached', async () => {
// Headless session tabs remain current without a renderer graph.
const { runtimeStore } = makeRuntimeStoreWithWorkspaceSession({
...getDefaultWorkspaceSession(),
tabsByWorktree: {
[TEST_WORKTREE_ID]: [
{
id: 'headless-tab',
ptyId: null,
worktreeId: TEST_WORKTREE_ID,
title: 'Codex',
customTitle: null,
color: null,
sortOrder: 0,
createdAt: 1
}
]
}
})
const now = Date.now()
const runtime = new OrcaRuntimeService(runtimeStore as never, undefined, {
getAgentStatusSnapshot: () => [
{
paneKey: 'headless-tab:aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa',
worktreeId: TEST_WORKTREE_ID,
tabId: 'headless-tab',
state: 'done',
prompt: 'finished while headless',
agentType: 'codex',
connectionId: null,
receivedAt: now,
stateStartedAt: now - 60_000
}
]
})
const { worktrees } = await runtime.getWorktreePs()
const summary = worktrees.find((worktree) => worktree.worktreeId === TEST_WORKTREE_ID)
expect(summary?.agents).toEqual([
expect.objectContaining({ state: 'done', prompt: 'finished while headless' })
])
})
it('resolves legacy numeric pane keys through the stale filter too', async () => {
// Non-UUID pane keys without a tabId field must still pass through the closed-tab filter.
const { runtimeStore } = makeRuntimeStoreWithWorkspaceSession({
@@ -26,76 +26,6 @@ function storedWorktreeMeta(
}
describe('OrcaRuntimeService', () => {
it('keeps a hook row with an unresolvable pane key', async () => {
// Without tabId, local staleness is unprovable.
const { runtimeStore } = makeRuntimeStoreWithWorkspaceSession({
...getDefaultWorkspaceSession(),
tabsByWorktree: {}
})
const now = Date.now()
const runtime = new OrcaRuntimeService(runtimeStore as never, undefined, {
getAgentStatusSnapshot: () => [
{
paneKey: 'opaque-key-without-structure',
worktreeId: TEST_WORKTREE_ID,
state: 'working',
prompt: 'unattributable pane',
agentType: 'codex',
connectionId: null,
receivedAt: now,
stateStartedAt: now - 100
}
]
})
const { worktrees } = await runtime.getWorktreePs()
const summary = worktrees.find((worktree) => worktree.worktreeId === TEST_WORKTREE_ID)
expect(summary?.agents).toEqual([expect.objectContaining({ prompt: 'unattributable pane' })])
})
it('keeps a WSL hook row while its tab is still in the session', async () => {
// Local-tab evidence must also rescue WSL rows.
const { runtimeStore } = makeRuntimeStoreWithWorkspaceSession({
...getDefaultWorkspaceSession(),
tabsByWorktree: {
[TEST_WORKTREE_ID]: [
{
id: 'open-wsl-tab',
ptyId: null,
worktreeId: TEST_WORKTREE_ID,
title: 'Codex',
customTitle: null,
color: null,
sortOrder: 0,
createdAt: 1
}
]
}
})
const now = Date.now()
const runtime = new OrcaRuntimeService(runtimeStore as never, undefined, {
getAgentStatusSnapshot: () => [
{
paneKey: 'open-wsl-tab:99999999-9999-4999-8999-999999999997',
worktreeId: TEST_WORKTREE_ID,
tabId: 'open-wsl-tab',
state: 'working',
prompt: 'live in WSL',
agentType: 'codex',
connectionId: 'wsl:Ubuntu',
receivedAt: now,
stateStartedAt: now - 100
}
]
})
const { worktrees } = await runtime.getWorktreePs()
const summary = worktrees.find((worktree) => worktree.worktreeId === TEST_WORKTREE_ID)
expect(summary?.agents).toEqual([expect.objectContaining({ prompt: 'live in WSL' })])
})
it('drops a hydrated WSL hook row after its local tab is closed', async () => {
// A WSL relay id names the transport, not a remote pane.
const { runtimeStore } = makeRuntimeStoreWithWorkspaceSession({
@@ -1,83 +1,19 @@
import { makeRuntimeOrchestrationDb } from './runtime-orchestration-db.test-fixture'
import { describe, expect, it, vi } from 'vitest'
import { makeAgentStatusStoreWiring } from '../terminal/identity/agent-status-store-wiring.test-fixture'
import './runtime-test-module-registration.spec'
import { OrcaRuntimeService } from '../orca-runtime'
import { createRootDispatch } from '../orchestration/db/root-dispatch-test-fixture'
import { listWorktrees } from '../../git/worktrees/catalog/worktree-scan-cache'
import {
HEADLESS_LEAF_ID,
TEST_FOLDER_WORKSPACE_KEY,
TEST_REPO_ID,
TEST_REPO_PATH,
TEST_WORKTREE_ID,
TEST_WORKTREE_PATH,
createFolderWorkspaceRuntimeStore,
makeFolderProjectGroup,
makeFolderWorkspace,
makeHeadlessTerminalLayout,
makeRuntimeStoreWithWorkspaceSession,
makeWorkspaceSessionWithHeadlessTerminal,
store,
syncSinglePty
store
} from './orca-runtime-test-fixtures.spec'
describe('OrcaRuntimeService', () => {
it('applies global custom-source visibility to mobile summaries and file resolution', async () => {
const globalRoot = '/tmp/global-worktrees'
const globalWorktreePath = `${globalRoot}/review`
vi.mocked(listWorktrees).mockResolvedValue([
{
path: TEST_REPO_PATH,
head: 'main',
branch: 'main',
isBare: false,
isMainWorktree: true
},
{
path: globalWorktreePath,
head: 'review',
branch: 'feature/review',
isBare: false,
isMainWorktree: false
}
])
const repo = {
...store.getRepos()[0],
externalWorktreeVisibility: 'hide' as const,
externalWorktreeVisibilityLegacy: false
}
const runtime = new OrcaRuntimeService({
...store,
getRepos: () => [repo],
getRepo: () => repo,
getSettings: () => ({
...store.getSettings(),
worktreeVisibilityDefaults: {
external: 'hide' as const,
customSources: [{ id: 'global', rootPath: globalRoot }],
sourcePreferences: { custom: { global: 'show' as const } }
}
})
} as never)
const summaries = await runtime.getWorktreePs()
const target = await (
runtime as unknown as {
resolveKnownWorkspaceFileTarget: (
path: string,
executionHostId: 'local'
) => Promise<{ worktree: { path: string }; relativePath: string } | null>
}
).resolveKnownWorkspaceFileTarget(`${globalWorktreePath}/src/app.ts`, 'local')
expect(summaries.worktrees.map((worktree) => worktree.path)).toContain(globalWorktreePath)
expect(target).toMatchObject({
worktree: { path: globalWorktreePath },
relativePath: 'src/app.ts'
})
})
it('prefers migrated layout ownership over a worktree id frozen in the PTY id', async () => {
const priorWorktreeId = `${TEST_REPO_ID}::/tmp/worktree-before-rename`
const migratedPtyId = `${priorWorktreeId}@@daemon-controller-pty`
@@ -112,30 +48,6 @@ describe('OrcaRuntimeService', () => {
})
})
it('does not project persisted wake identifiers as live terminal activity', async () => {
const session = makeWorkspaceSessionWithHeadlessTerminal({
activeWorktreeIdsOnShutdown: [TEST_WORKTREE_ID]
})
const { runtimeStore } = makeRuntimeStoreWithWorkspaceSession(session)
const runtime = new OrcaRuntimeService(runtimeStore as never)
runtime.setPtyController({
write: vi.fn(() => true),
kill: vi.fn(() => true),
getForegroundProcess: vi.fn(async () => null),
listProcesses: vi.fn(async () => [])
})
const { worktrees } = await runtime.getWorktreePs()
expect(worktrees[0]).toMatchObject({
worktreeId: TEST_WORKTREE_ID,
hasHostSidebarActivity: false,
liveTerminalCount: 0,
hasAttachedPty: false,
status: 'inactive'
})
})
it('projects zero after sleep despite stale renderer leaves and persisted tabs', async () => {
const session = makeWorkspaceSessionWithHeadlessTerminal()
const { runtimeStore } = makeRuntimeStoreWithWorkspaceSession(session)
@@ -197,152 +109,6 @@ describe('OrcaRuntimeService', () => {
}
})
it('attaches inline agent rows from hook-reported status (not just OSC)', async () => {
// Hook-only agents must appear in worktree.ps without an OSC status.
const leafId = '33333333-3333-4333-8333-333333333333'
const paneKey = `tab-1:${leafId}`
const now = Date.now()
const runtime = new OrcaRuntimeService(store, undefined, {
getAgentStatusSnapshot: () => [
{
paneKey,
worktreeId: TEST_WORKTREE_ID,
tabId: 'tab-1',
state: 'working',
prompt: 'ship it',
agentType: 'claude',
lastAssistantMessage: 'on it',
connectionId: null,
receivedAt: now,
stateStartedAt: now - 100
}
]
})
const workerHandle = runtime.preAllocateHandleForPty('pty-1')
const orchestrationDb = makeRuntimeOrchestrationDb()
const run = orchestrationDb.createRun({
objective: 'Hook summary projection',
coordinatorHandle: null,
coordinatorPaneKey: null
})
const task = orchestrationDb.createTask({
runId: run.id,
taskTitle: 'Dispatch prompt work',
displayName: 'Review dispatch prompts and make worker labels distinct',
spec: 'Review dispatch prompts\n\nand make worker labels distinct'
})
createRootDispatch(orchestrationDb, task.id, workerHandle, paneKey)
runtime.setOrchestrationDb(orchestrationDb)
runtime.attachWindow(1)
await runtime.syncWindowGraph(1, {
tabs: [
{
tabId: 'tab-1',
worktreeId: TEST_WORKTREE_ID,
title: 'Claude',
activeLeafId: leafId,
layout: null
}
],
leaves: [
{
tabId: 'tab-1',
worktreeId: TEST_WORKTREE_ID,
leafId,
paneRuntimeId: 1,
ptyId: 'pty-1'
}
]
})
const { worktrees } = await runtime.getWorktreePs()
const summary = worktrees.find((w) => w.worktreeId === TEST_WORKTREE_ID)
expect(summary?.agents).toEqual([
expect.objectContaining({
paneKey,
state: 'working',
agentType: 'claude',
prompt: 'ship it',
taskTitle: 'Dispatch prompt work',
displayName: 'Review dispatch prompts and make worker labels distinct',
lastAssistantMessage: 'on it',
stateStartedAt: now - 100,
updatedAt: now
})
])
expect(summary).toMatchObject({ hasHostSidebarActivity: true, status: 'working' })
})
it('projects monitoring for folder workspaces without assuming a git worktree', async () => {
const now = Date.now()
const folderWorkspace = makeFolderWorkspace({ name: 'GG' })
const projectGroup = makeFolderProjectGroup({ name: 'Store' })
const runtime = new OrcaRuntimeService(
createFolderWorkspaceRuntimeStore(folderWorkspace, projectGroup) as never,
undefined,
{
getAgentStatusSnapshot: () => [
{
paneKey: 'folder-pane',
worktreeId: TEST_FOLDER_WORKSPACE_KEY,
state: 'working',
workingMode: 'monitoring',
prompt: 'watch tests',
agentType: 'claude',
connectionId: null,
receivedAt: now,
stateStartedAt: now - 100
}
]
}
)
const { worktrees } = await runtime.getWorktreePs()
const summary = worktrees.find((worktree) => worktree.worktreeId === TEST_FOLDER_WORKSPACE_KEY)
expect(summary).toMatchObject({
workspaceKind: 'folder-workspace',
status: 'working',
workingMode: 'monitoring'
})
})
it('keeps hook monitoring mode when a newer mode-less OSC row reports the same work', async () => {
const now = Date.now()
const runtime = new OrcaRuntimeService(store, undefined, {
getAgentStatusSnapshot: () => [
{
paneKey: 'tab-1:1',
worktreeId: TEST_WORKTREE_ID,
tabId: 'tab-1',
state: 'working',
workingMode: 'monitoring',
prompt: 'watch tests',
agentType: 'claude',
connectionId: null,
receivedAt: now - 100,
stateStartedAt: now - 200
}
]
})
await syncSinglePty(runtime)
runtime.onPtyData(
'pty-1',
'\x1b]9999;{"state":"working","prompt":"watch tests","agentType":"claude"}\x07',
1
)
const { worktrees } = await runtime.getWorktreePs()
const summary = worktrees.find((worktree) => worktree.worktreeId === TEST_WORKTREE_ID)
expect(summary).toMatchObject({ status: 'working', workingMode: 'monitoring' })
expect(summary?.agents).toEqual([
expect.objectContaining({
state: 'working',
workingMode: 'monitoring',
prompt: 'watch tests'
})
])
})
it('does not carry hook monitoring mode into a newer OSC turn', async () => {
const leafId = '55555555-5555-4555-8555-555555555555'
const statusWiring = makeAgentStatusStoreWiring()