mirror of
https://github.com/stablyai/orca.git
synced 2026-11-18 11:54:46 +00:00
refactor(tests): colocate runtime and compatibility contracts with owners (#43589)
This commit is contained in:
@@ -49,8 +49,8 @@
|
||||
1 test-no-polling-loop:tests/e2e/browser-guest-crash-recovery.spec.ts
|
||||
1 test-no-polling-loop:tests/e2e/browser-tab.spec.ts
|
||||
1 test-no-polling-loop:tests/e2e/chinese-ime-chat-input-repro.spec.ts
|
||||
1 test-no-polling-loop:tests/e2e/cross-version-wire/released-relay-daemon.ts
|
||||
1 test-no-polling-loop:tests/e2e/cross-version-wire/released-relay-transport.ts
|
||||
1 test-no-polling-loop:tests/e2e/cross-version-wire/relay/released-relay-daemon.ts
|
||||
1 test-no-polling-loop:tests/e2e/cross-version-wire/relay/released-relay-transport.ts
|
||||
1 test-no-polling-loop:tests/e2e/daemon-lifecycle-retirement.spec.ts
|
||||
1 test-no-polling-loop:tests/e2e/fixtures/daemon-generation-legacy-close-client.ts
|
||||
1 test-no-polling-loop:tests/e2e/fixtures/daemon-generation-reconnect-client.ts
|
||||
@@ -181,9 +181,9 @@
|
||||
9 test-no-real-time-wait:tests/e2e/chinese-ime-chat-input-repro.spec.ts
|
||||
2 test-no-real-time-wait:tests/e2e/cli-floating-file-open-position.spec.ts
|
||||
1 test-no-real-time-wait:tests/e2e/codex-ctrl-c-status.spec.ts
|
||||
1 test-no-real-time-wait:tests/e2e/cross-version-wire/legacy-relay-bridge.unit.test.ts
|
||||
1 test-no-real-time-wait:tests/e2e/cross-version-wire/released-relay-daemon.ts
|
||||
2 test-no-real-time-wait:tests/e2e/cross-version-wire/released-relay-transport.ts
|
||||
1 test-no-real-time-wait:tests/e2e/cross-version-wire/relay/legacy-relay-bridge.unit.test.ts
|
||||
1 test-no-real-time-wait:tests/e2e/cross-version-wire/relay/released-relay-daemon.ts
|
||||
2 test-no-real-time-wait:tests/e2e/cross-version-wire/relay/released-relay-transport.ts
|
||||
1 test-no-real-time-wait:tests/e2e/daemon-lifecycle-retirement.spec.ts
|
||||
2 test-no-real-time-wait:tests/e2e/default-tabs-mark-crash-relaunch.spec.ts
|
||||
1 test-no-real-time-wait:tests/e2e/diff-note-draft.spec.ts
|
||||
@@ -429,8 +429,8 @@
|
||||
10 test-no-wall-clock:src/wsl-guest/agent-hooks/publication/agent-hook-integration.test.ts
|
||||
1 test-no-wall-clock:src/wsl-guest/agent-hooks/server/agent-hook-server.test.ts
|
||||
1 test-no-wall-clock:src/wsl-guest/agent-hooks/presence/relay-idle-process-owner.test.ts
|
||||
2 test-no-wall-clock:tests/e2e/cross-version-wire/legacy-relay-bridge.unit.test.ts
|
||||
4 test-no-wall-clock:tests/e2e/cross-version-wire/release-checkout.unit.test.ts
|
||||
2 test-no-wall-clock:tests/e2e/cross-version-wire/relay/legacy-relay-bridge.unit.test.ts
|
||||
2 test-no-wall-clock:tests/e2e/cross-version-wire/release-checkouts/release-checkout.unit.test.ts
|
||||
1 test-no-wall-clock:tests/e2e/host-cold-park-remote-subscriber.unit.test.ts
|
||||
1 test-timeout-needs-reason:src/cli/agents/agent-launch-process.test.ts
|
||||
1 test-timeout-needs-reason:src/cli/runtime/serve/startup/serve-pid1-init-reaper.test.ts
|
||||
@@ -507,11 +507,8 @@
|
||||
1 test-timeout-needs-reason:tests/e2e/cli-agent-unopened-workspace-resume.spec.ts
|
||||
1 test-timeout-needs-reason:tests/e2e/combined-diff-invalidation-freeze-repro.spec.ts
|
||||
1 test-timeout-needs-reason:tests/e2e/completed-worker-retirement-resume.spec.ts
|
||||
2 test-timeout-needs-reason:tests/e2e/cross-version-wire/agent-session-newer-chat-refusal.unit.test.ts
|
||||
3 test-timeout-needs-reason:tests/e2e/cross-version-wire/cross-version-terminal-wire.unit.test.ts
|
||||
4 test-timeout-needs-reason:tests/e2e/cross-version-wire/legacy-relay-bridge.unit.test.ts
|
||||
3 test-timeout-needs-reason:tests/e2e/cross-version-wire/release-checkout.unit.test.ts
|
||||
2 test-timeout-needs-reason:tests/e2e/cross-version-wire/reported-lossy-initial-snapshot.unit.test.ts
|
||||
3 test-timeout-needs-reason:tests/e2e/cross-version-wire/relay/legacy-relay-bridge.unit.test.ts
|
||||
2 test-timeout-needs-reason:tests/e2e/cross-version-wire/release-checkouts/release-checkout.unit.test.ts
|
||||
1 test-timeout-needs-reason:tests/e2e/csv-paged-preview.spec.ts
|
||||
1 test-timeout-needs-reason:tests/e2e/csv-url-links.spec.ts
|
||||
1 test-timeout-needs-reason:tests/e2e/cursor-quota-transport.unit.test.ts
|
||||
|
||||
@@ -25,9 +25,9 @@ src/renderer/src/store/terminals/retirement/legacy-relay-bridged-tab-close.ts
|
||||
src/shared/remote-runtime/relay/legacy-relay-bridge-contract.ts
|
||||
src/shared/remote-runtime/ssh/ssh-types.ts
|
||||
src/shared/telemetry/schemas/telemetry-ssh-host-server-event-schemas.ts
|
||||
tests/e2e/cross-version-wire/legacy-relay-bridge.unit.test.ts
|
||||
tests/e2e/cross-version-wire/released-relay-daemon.ts
|
||||
tests/e2e/cross-version-wire/released-relay-transport.ts
|
||||
tests/e2e/cross-version-wire/relay/legacy-relay-bridge.unit.test.ts
|
||||
tests/e2e/cross-version-wire/relay/released-relay-daemon.ts
|
||||
tests/e2e/cross-version-wire/relay/released-relay-transport.ts
|
||||
tests/e2e/helpers/build-released-relay-bundle.mts
|
||||
tests/e2e/helpers/legacy-relay-docker-host.ts
|
||||
tests/e2e/helpers/orcad-upgrade-profile.ts
|
||||
|
||||
@@ -9,7 +9,7 @@ src/main/ipc/ssh/ssh-host-server-on-connect-wiring.ts
|
||||
src/main/ipc/ssh/ssh-session-teardown.ts
|
||||
src/main/ipc/ssh/ssh.ts
|
||||
src/main/managed-server/lifecycle/orcad-runtime-conversion-wiring.ts
|
||||
tests/e2e/cross-version-wire/legacy-relay-bridge.unit.test.ts
|
||||
tests/e2e/cross-version-wire/relay/legacy-relay-bridge.unit.test.ts
|
||||
tests/e2e/helpers/legacy-relay-docker-host.ts
|
||||
src/main/managed-server/install/remote-install-model.ts
|
||||
src/main/ssh/system-transport/ssh-system-transport.integration.test.ts
|
||||
|
||||
@@ -19,9 +19,9 @@ config/tsconfig.node.json src/renderer/src/components/native-chat/native-chat-co
|
||||
config/tsconfig.node.json src/renderer/src/components/native-chat/native-chat-resolution-receipt.ts
|
||||
config/tsconfig.node.json src/renderer/src/components/native-chat/structured-agent-question-projection.ts
|
||||
tests/e2e/capture-opencode-tui-repro.mjs src/cli/cmd/tui/ui/spinner
|
||||
tests/e2e/cross-version-wire/released-chat-writers.ts src/main/native-chat/agent-session-wire/structured-agent-session-event-sink.ts
|
||||
tests/e2e/cross-version-wire/chat-journals/released-chat-writers.ts src/main/native-chat/agent-session-wire/structured-agent-session-event-sink.ts
|
||||
# Released source trees retain this actual registry; the current registry is checked first.
|
||||
tests/e2e/cross-version-wire/release-module-locations.ts src/main/runtime/rpc/methods/index.ts
|
||||
tests/e2e/cross-version-wire/release-module-locations.ts src/renderer/src/runtime/remote-runtime-terminal-multiplexer.ts
|
||||
tests/e2e/cross-version-wire/release-checkouts/release-module-locations.ts src/main/runtime/rpc/methods/index.ts
|
||||
tests/e2e/cross-version-wire/release-checkouts/release-module-locations.ts src/renderer/src/runtime/remote-runtime-terminal-multiplexer.ts
|
||||
# The rollback negative control restores this source from its fixed affected archive.
|
||||
config/scripts/runtime-verification/ephemeral-store/run-ephemeral-vm-runtime-store-rollback-repro.mjs src/shared/ephemeral-vm-runtime-store.ts
|
||||
|
||||
+37
-123
File diff suppressed because one or more lines are too long
@@ -27,7 +27,7 @@ import {
|
||||
type ArmSpec
|
||||
} from './native-chat-4a-arm-provenance'
|
||||
import { installVisibilityProbe } from './native-chat-4a-probes'
|
||||
import { releaseModuleLocation } from '../../../../tests/e2e/cross-version-wire/release-module-locations'
|
||||
import { releaseModuleLocation } from '../../../../tests/e2e/cross-version-wire/release-checkouts/release-module-locations'
|
||||
|
||||
const HARNESS_ROOT = path.resolve(import.meta.dirname, '../../../..')
|
||||
const SYSTEM_DIRS = ['/usr/bin', '/bin', '/usr/sbin', '/sbin']
|
||||
|
||||
@@ -33,7 +33,6 @@ const NODE_RUNTIME_INCLUDE = [
|
||||
'src/main/runtime/orchestration/mailbox/terminal-pointer/orchestration-mailbox-delivery.test.ts',
|
||||
'src/main/runtime/orchestration/mailbox/routing/orchestration-mailbox-routing.test.ts',
|
||||
|
||||
'tests/e2e/cross-version-wire/agent-session-clear-old-tab-mirror.unit.test.ts',
|
||||
'src/main/pi/rpc/rpc-session-startup.test.ts',
|
||||
'src/main/native-chat/agent-session-wire/host/testing/structured-agent-session-clear-queued-command.test.ts',
|
||||
'src/main/acp/session/acp-structured-session-adapter.test.ts',
|
||||
|
||||
@@ -5,8 +5,8 @@ import { lock } from 'proper-lockfile'
|
||||
import { localRepositoryWorktrees } from './local-repository-worktrees.mjs'
|
||||
import { getDevBundleProcessTable } from '../development/electron-bundle-cache/dev-electron-bundle-cache.mjs'
|
||||
import { worktreeActiveSince } from './worktree-recent-activity.mjs'
|
||||
import { CHECKOUT_FORMAT } from '../../../tests/e2e/cross-version-wire/release-checkout-publication.ts'
|
||||
import { withReleaseSourceFormatLease } from '../../../tests/e2e/cross-version-wire/release-source-retention.ts'
|
||||
import { CHECKOUT_FORMAT } from '../../../tests/e2e/cross-version-wire/release-checkouts/release-checkout-publication.ts'
|
||||
import { withReleaseSourceFormatLease } from '../../../tests/e2e/cross-version-wire/release-checkouts/release-source-retention.ts'
|
||||
|
||||
const COMMIT = '(?:[\\da-f]{40}|[\\da-f]{64})'
|
||||
const LOCAL_ENTRY = new RegExp(`^(${COMMIT})-format-([1-9]\\d*)$`)
|
||||
|
||||
@@ -15,8 +15,8 @@ import { join } from 'node:path'
|
||||
import { afterEach, expect, it } from 'vitest'
|
||||
import { lock } from 'proper-lockfile'
|
||||
import { reclaimReleaseTestCaches } from './reclaim-release-test-caches.mjs'
|
||||
import { withReleaseSourceLease } from '../../../tests/e2e/cross-version-wire/release-source-retention'
|
||||
import { CHECKOUT_FORMAT } from '../../../tests/e2e/cross-version-wire/release-checkout-publication'
|
||||
import { withReleaseSourceLease } from '../../../tests/e2e/cross-version-wire/release-checkouts/release-source-retention'
|
||||
import { CHECKOUT_FORMAT } from '../../../tests/e2e/cross-version-wire/release-checkouts/release-checkout-publication'
|
||||
|
||||
const roots: string[] = []
|
||||
const commit = 'c'.repeat(40)
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
"../src/types/**/*"
|
||||
],
|
||||
"exclude": [
|
||||
"../src/main/runtime/orca-runtime-tests/browser-page-inventory.test.ts",
|
||||
"../src/main/runtime/browser/client-pages/browser-page-inventory.test.ts",
|
||||
"../src/main/runtime/orchestration/terminal-authority/structured-sessions/structured-chat-coordinator-mail.test.ts",
|
||||
"../src/main/github/pull-requests/refresh/pr-refresh-coordinator-local-delivery.test.ts"
|
||||
],
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"extends": "./tsconfig.web.json",
|
||||
"include": [
|
||||
"../src/renderer/src/components/browser-pane/host-guest/browser-profile-native.test-fixture.ts",
|
||||
"../src/main/runtime/orca-runtime-tests/browser-page-inventory.test.ts",
|
||||
"../src/main/runtime/browser/client-pages/browser-page-inventory.test.ts",
|
||||
"../src/renderer/src/components/sidebar/workspace-creation/folder/folder-workspace-composer-submit-host-platform.test.ts",
|
||||
"../src/main/runtime/orchestration/terminal-authority/structured-sessions/structured-chat-coordinator-mail.test.ts",
|
||||
"../src/main/github/pull-requests/refresh/pr-refresh-coordinator-local-delivery.test.ts",
|
||||
|
||||
@@ -99,7 +99,7 @@ Tests cover concurrent publication, lock heartbeats and eviction, independent br
|
||||
corrupt seeds, fallback, the opt-out, and preserved read-only files. Run them with:
|
||||
|
||||
```sh
|
||||
ORCA_BACKGROUND_LAUNCH=1 pnpm test tests/e2e/cross-version-wire/release-source-cache.unit.test.ts tests/e2e/cross-version-wire/release-source-retention.unit.test.ts tests/e2e/cross-version-wire/release-checkout.unit.test.ts tests/e2e/cross-version-wire/release-checkout-tree.unit.test.ts tests/e2e/cross-version-wire/release-missing-packages.unit.test.ts config/scripts/artifact-storage/reflink-copy/space-sharing-copy.test.ts
|
||||
ORCA_BACKGROUND_LAUNCH=1 pnpm test tests/e2e/cross-version-wire/release-source-cache.unit.test.ts tests/e2e/cross-version-wire/release-checkouts/release-source-retention.unit.test.ts tests/e2e/cross-version-wire/release-checkouts/release-checkout.unit.test.ts tests/e2e/cross-version-wire/release-checkouts/release-checkout-tree.unit.test.ts tests/e2e/cross-version-wire/release-checkouts/release-missing-packages.unit.test.ts config/scripts/artifact-storage/reflink-copy/space-sharing-copy.test.ts
|
||||
```
|
||||
|
||||
## P3 remains an experiment
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { withDurableRuntimeStore } from '../orca-runtime-tests/runtime-durable-store-fixture'
|
||||
import { withDurableRuntimeStore } from '../construction/test-context/runtime-durable-store-fixture'
|
||||
import { vi, type Mock } from 'vitest'
|
||||
import { makePaneKey } from '../../../shared/workspace-layout/stable-pane-id'
|
||||
import type { WorkspaceSessionState } from '../../../shared/workspace-session/workspace-session-state-types'
|
||||
|
||||
@@ -0,0 +1,138 @@
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import { registerLivePty } from '../../terminal/layout/bind-first-pane.test-fixture'
|
||||
import '../../construction/test-context/runtime-test-module-registration.spec'
|
||||
import { OrcaRuntimeService } from '../../orca-runtime'
|
||||
import '../../../../shared/workspace-layout/stable-pane-id'
|
||||
import type { RuntimeClientEvent } from '../../../../shared/remote-runtime/session-graph/runtime-client-events'
|
||||
import type { RuntimeSyncWindowGraph } from '../../../../shared/remote-runtime/session-graph/runtime-session-contracts'
|
||||
import { store } from '../../construction/test-context/orca-runtime-test-fixtures.spec'
|
||||
|
||||
describe('OrcaRuntimeService', () => {
|
||||
it('routes a launch-draft resolution to the handle-owning local and remote renderers', async () => {
|
||||
const runtime = new OrcaRuntimeService(store)
|
||||
const nativeChatLaunchDraftResolved = vi.fn()
|
||||
const events: RuntimeClientEvent[] = []
|
||||
runtime.setNotifier({ nativeChatLaunchDraftResolved } as never)
|
||||
runtime.onClientEvent((event) => events.push(event))
|
||||
runtime.attachWindow(1)
|
||||
const graph: RuntimeSyncWindowGraph = {
|
||||
tabs: [
|
||||
{
|
||||
tabId: 'tab-1',
|
||||
worktreeId: 'repo-1::/tmp/worktree-a',
|
||||
title: 'Claude',
|
||||
activeLeafId: 'pane:1',
|
||||
layout: null
|
||||
}
|
||||
],
|
||||
leaves: [
|
||||
{
|
||||
tabId: 'tab-1',
|
||||
worktreeId: 'repo-1::/tmp/worktree-a',
|
||||
leafId: 'pane:1',
|
||||
paneRuntimeId: 1,
|
||||
ptyId: 'pty-1'
|
||||
}
|
||||
],
|
||||
mobileSessionTabs: [
|
||||
{
|
||||
worktree: 'repo-1::/tmp/worktree-a',
|
||||
publicationEpoch: 'launch-draft-epoch',
|
||||
snapshotVersion: 1,
|
||||
activeGroupId: 'group-1',
|
||||
activeTabId: 'tab-1::pane:1',
|
||||
activeTabType: 'terminal',
|
||||
tabs: [
|
||||
{
|
||||
type: 'terminal',
|
||||
id: 'tab-1::pane:1',
|
||||
parentTabId: 'tab-1',
|
||||
leafId: 'pane:1',
|
||||
title: 'Claude',
|
||||
launchDraft: 'seed',
|
||||
launchDraftCreatedAt: 7,
|
||||
isActive: true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
registerLivePty(runtime, 'pty-1', 'repo-1::/tmp/worktree-a', null, {
|
||||
tabId: 'tab-1',
|
||||
leafId: 'pane:1'
|
||||
})
|
||||
await runtime.syncWindowGraph(1, graph)
|
||||
const listed = await runtime.listMobileSessionTabs('branch:feature/foo')
|
||||
const mobileTab = listed.tabs.find((tab) => tab.type === 'terminal')
|
||||
if (!mobileTab?.terminal) {
|
||||
throw new Error('expected mobile terminal handle')
|
||||
}
|
||||
expect(mobileTab).toMatchObject({ launchDraft: 'seed', launchDraftCreatedAt: 7 })
|
||||
|
||||
runtime.notifyNativeChatLaunchDraftResolved(mobileTab.terminal, {
|
||||
text: 'seed',
|
||||
createdAt: 7
|
||||
})
|
||||
|
||||
expect(nativeChatLaunchDraftResolved).toHaveBeenCalledWith('tab-1', {
|
||||
text: 'seed',
|
||||
createdAt: 7
|
||||
})
|
||||
expect(events).toContainEqual({
|
||||
type: 'nativeChatLaunchDraftResolved',
|
||||
tabId: 'tab-1',
|
||||
text: 'seed',
|
||||
createdAt: 7
|
||||
})
|
||||
expect(runtime.getNativeChatLaunchDraftResolutionClientEventSnapshot()).toContainEqual({
|
||||
type: 'nativeChatLaunchDraftResolved',
|
||||
tabId: 'tab-1',
|
||||
text: 'seed',
|
||||
createdAt: 7
|
||||
})
|
||||
const retired = (await runtime.listMobileSessionTabs('branch:feature/foo')).tabs.find(
|
||||
(tab) => tab.type === 'terminal'
|
||||
)
|
||||
expect(retired).not.toHaveProperty('launchDraft')
|
||||
expect(retired).not.toHaveProperty('launchDraftCreatedAt')
|
||||
|
||||
runtime.markRendererReloading(1)
|
||||
const replay = await runtime.syncWindowGraph(1, {
|
||||
...graph,
|
||||
mobileSessionTabs: graph.mobileSessionTabs?.map((snapshot) => ({
|
||||
...snapshot,
|
||||
publicationEpoch: 'launch-draft-reload',
|
||||
snapshotVersion: 2
|
||||
}))
|
||||
})
|
||||
expect(replay.nativeChatLaunchDraftResolutions).toEqual([
|
||||
{ tabId: 'tab-1', text: 'seed', createdAt: 7 }
|
||||
])
|
||||
expect(
|
||||
(await runtime.listMobileSessionTabs('branch:feature/foo')).tabs.find(
|
||||
(tab) => tab.type === 'terminal'
|
||||
)
|
||||
).not.toHaveProperty('launchDraft')
|
||||
|
||||
const reconciled = await runtime.syncWindowGraph(1, {
|
||||
...graph,
|
||||
mobileSessionTabs: graph.mobileSessionTabs?.map((snapshot) => ({
|
||||
...snapshot,
|
||||
publicationEpoch: 'launch-draft-reload',
|
||||
snapshotVersion: 3,
|
||||
tabs: snapshot.tabs.map((tab) => {
|
||||
if (tab.type !== 'terminal') {
|
||||
return tab
|
||||
}
|
||||
return { ...tab, launchDraftCreatedAt: 8 }
|
||||
})
|
||||
}))
|
||||
})
|
||||
expect(reconciled.nativeChatLaunchDraftResolutions).toBeUndefined()
|
||||
expect(
|
||||
(await runtime.listMobileSessionTabs('branch:feature/foo')).tabs.find(
|
||||
(tab) => tab.type === 'terminal'
|
||||
)
|
||||
).toMatchObject({ launchDraft: 'seed', launchDraftCreatedAt: 8 })
|
||||
})
|
||||
})
|
||||
+1
-1
@@ -31,7 +31,7 @@ import { createStructuredAgentSessionLogger } from '../../../native-chat/agent-s
|
||||
import { OrcaRuntimeService } from '../../orca-runtime'
|
||||
import { withChatTabChanges } from '../../session-tabs/chat/agent-session-tab-layout'
|
||||
import { collectSavedStructuredAgentSessionIds } from './saved-structured-agent-session-restoration'
|
||||
import { chatTabCommandsSettled } from '../../orca-runtime-tests/session-layout-apply.test-fixture'
|
||||
import { chatTabCommandsSettled } from '../../terminal/layout/session-layout-apply.test-fixture'
|
||||
import { stopStructuredAgentSessionRuntime } from '../installation/structured-agent-session-runtime'
|
||||
|
||||
export const B = 'chat-b-0002',
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
import { CODEX_MINIMUM_SUPPORTED_VERSION } from '../../../shared/agent-launch/startup/codex-cli-installation'
|
||||
import type { StructuredAgentSessionRuntimeDeps } from '../agent-session/installation/structured-agent-session-runtime-contract'
|
||||
import { CODEX_MINIMUM_SUPPORTED_VERSION } from '../../../../shared/agent-launch/startup/codex-cli-installation'
|
||||
import type { StructuredAgentSessionRuntimeDeps } from '../installation/structured-agent-session-runtime-contract'
|
||||
|
||||
/** Runtime deps that put a scripted Codex child where the real app-server would spawn. It speaks
|
||||
* the supported protocol, so it reports that version; its fake pid has a fixed start time. */
|
||||
+9
-49
@@ -1,20 +1,15 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import './runtime-test-module-registration.spec'
|
||||
import '../orca-runtime'
|
||||
import '../orca-runtime-test-mocks/setup.spec'
|
||||
import { getBrowserHostLeaseRegistry } from '../browser-host/leases/browser-host-lease-registry-instance'
|
||||
import { getRuntimeBrowserPageRegistry } from '../browser/client-pages/runtime-browser-page-registry'
|
||||
import '../../construction/test-context/runtime-test-module-registration.spec'
|
||||
import '../../orca-runtime'
|
||||
import '../../orca-runtime-test-mocks/setup.spec'
|
||||
import '../../browser-host/leases/browser-host-lease-registry-instance'
|
||||
import { getRuntimeBrowserPageRegistry } from './runtime-browser-page-registry'
|
||||
import {
|
||||
TEST_REPO_ID,
|
||||
TEST_WORKTREE_ID,
|
||||
createRuntime,
|
||||
store
|
||||
} from './orca-runtime-test-fixtures.spec'
|
||||
import {
|
||||
attachClientBrowserHost,
|
||||
publishClientHostedPage
|
||||
} from './orca-runtime-test-scenario-builders.spec'
|
||||
import '../../../shared/worktree/host-qualified-identity'
|
||||
createRuntime
|
||||
} from '../../construction/test-context/orca-runtime-test-fixtures.spec'
|
||||
import '../../construction/test-context/orca-runtime-test-scenario-builders.spec'
|
||||
import '../../../../shared/worktree/host-qualified-identity'
|
||||
|
||||
describe('OrcaRuntimeService', () => {
|
||||
it('preserves a live client page across headed renderer graph updates and prunes it after retirement', async () => {
|
||||
@@ -84,39 +79,4 @@ describe('OrcaRuntimeService', () => {
|
||||
})
|
||||
expect((await runtime.listMobileSessionTabs(`id:${TEST_WORKTREE_ID}`)).tabs).toEqual([])
|
||||
})
|
||||
|
||||
it('closes a worktree’s client-hosted browser pages when its metadata is removed (leak fix)', async () => {
|
||||
const runtime = createRuntime()
|
||||
const host = attachClientBrowserHost(runtime)
|
||||
const removed = await publishClientHostedPage(runtime, host, 'page-removed', TEST_WORKTREE_ID)
|
||||
const survivor = await publishClientHostedPage(
|
||||
runtime,
|
||||
host,
|
||||
'page-other',
|
||||
`${TEST_REPO_ID}::/tmp/other`
|
||||
)
|
||||
|
||||
runtime['removeWorktreeMetadataAndHistory'](store as never, TEST_WORKTREE_ID)
|
||||
|
||||
expect(host.takeCommands()).toEqual([
|
||||
expect.objectContaining({
|
||||
browserPageId: 'page-removed',
|
||||
pageHostGeneration: removed.pageHostGeneration,
|
||||
command: {
|
||||
type: 'closePage',
|
||||
targetAuthority: {
|
||||
authorityRuntimeId: runtime.getRuntimeId(),
|
||||
authorityEpoch: getBrowserHostLeaseRegistry(runtime).authorityEpoch,
|
||||
browserHostClientId: removed.browserHostClientId,
|
||||
browserHostGeneration: removed.browserHostGeneration,
|
||||
pageHostGeneration: removed.pageHostGeneration
|
||||
}
|
||||
}
|
||||
})
|
||||
])
|
||||
expect(getRuntimeBrowserPageRegistry(runtime).getPage('page-removed')).toBeUndefined()
|
||||
expect(getRuntimeBrowserPageRegistry(runtime).getPage('page-other')?.placement).toEqual(
|
||||
survivor
|
||||
)
|
||||
})
|
||||
})
|
||||
+12
-36
@@ -1,7 +1,7 @@
|
||||
import { EventEmitter } from 'node:events'
|
||||
import type { AppState } from '../../../renderer/src/store/types'
|
||||
import type { AppState } from '../../../../renderer/src/store/types'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import './orca-runtime-test-lifecycle.spec'
|
||||
import '../../construction/test-context/orca-runtime-test-lifecycle.spec'
|
||||
import {
|
||||
createRuntime,
|
||||
TEST_WORKTREE_ID,
|
||||
@@ -11,22 +11,22 @@ import {
|
||||
makeWorkspaceSessionWithHeadlessTerminal,
|
||||
makeHeadlessTerminalLayout,
|
||||
HEADLESS_LEAF_ID
|
||||
} from './orca-runtime-test-fixtures.spec'
|
||||
import { OrcaRuntimeService } from '../orca-runtime'
|
||||
import { browserManager } from '../../browser/guest-lifecycle/manager/browser-manager'
|
||||
import { electronMocks } from '../orca-runtime-test-mocks/setup.spec'
|
||||
import { buildMobileSessionTabSnapshots } from '../../../renderer/src/runtime/sync-runtime-graph/mobile-session-snapshots'
|
||||
import { makeState } from '../../../renderer/src/runtime/sync-runtime-graph/testing/sync-runtime-graph-test-harness'
|
||||
import { watchBrowserMainWindowReadiness } from '../../browser/guest-lifecycle/browser-main-window-readiness'
|
||||
import { resolveTabRegistrationWaiters } from '../../ipc/browser/browser-tab-registration-wait'
|
||||
} from '../../construction/test-context/orca-runtime-test-fixtures.spec'
|
||||
import { OrcaRuntimeService } from '../../orca-runtime'
|
||||
import { browserManager } from '../../../browser/guest-lifecycle/manager/browser-manager'
|
||||
import { electronMocks } from '../../orca-runtime-test-mocks/setup.spec'
|
||||
import { buildMobileSessionTabSnapshots } from '../../../../renderer/src/runtime/sync-runtime-graph/mobile-session-snapshots'
|
||||
import { makeState } from '../../../../renderer/src/runtime/sync-runtime-graph/testing/sync-runtime-graph-test-harness'
|
||||
import { watchBrowserMainWindowReadiness } from '../../../browser/guest-lifecycle/browser-main-window-readiness'
|
||||
import { resolveTabRegistrationWaiters } from '../../../ipc/browser/browser-tab-registration-wait'
|
||||
import type {
|
||||
BrowserPage,
|
||||
BrowserWorkspace
|
||||
} from '../../../shared/browser/workspaces/browser-workspace-types'
|
||||
} from '../../../../shared/browser/workspaces/browser-workspace-types'
|
||||
import type {
|
||||
RuntimeMobileSessionTabsResult,
|
||||
RuntimeSyncWindowGraph
|
||||
} from '../../../shared/remote-runtime/session-graph/runtime-session-contracts'
|
||||
} from '../../../../shared/remote-runtime/session-graph/runtime-session-contracts'
|
||||
|
||||
const workspace: BrowserWorkspace = {
|
||||
id: 'browser-w',
|
||||
@@ -317,30 +317,6 @@ describe('accepted saved browser page inventory', () => {
|
||||
unsubscribe()
|
||||
})
|
||||
|
||||
it.each([10, 100])('keeps hidden sibling churn local with %i saved pages', async (count) => {
|
||||
vi.useFakeTimers()
|
||||
const { runtime, sync, list } = fixture()
|
||||
const hidden = Array.from({ length: count }, (_, index) => page(`saved-${index}`))
|
||||
await sync(publication([...hidden, page('C')]))
|
||||
await vi.advanceTimersByTimeAsync(100)
|
||||
const initial = await runtime.listMobileSessionTabs(`id:${TEST_WORKTREE_ID}`)
|
||||
expect(initial.tabs).toEqual(
|
||||
expect.arrayContaining([expect.objectContaining({ browserPageId: 'C', title: 'C' })])
|
||||
)
|
||||
const events: RuntimeMobileSessionTabsResult[] = []
|
||||
const unsubscribe = runtime.onMobileSessionTabsChanged((snapshot) => events.push(snapshot))
|
||||
await sync(
|
||||
publication([...hidden.map((entry) => ({ ...entry, title: 'Updated sibling' })), page('C')])
|
||||
)
|
||||
await vi.advanceTimersByTimeAsync(100)
|
||||
expect((await list()).tabs.filter((entry) => entry.title === 'Updated sibling')).toHaveLength(
|
||||
count
|
||||
)
|
||||
expect(await runtime.listMobileSessionTabs(`id:${TEST_WORKTREE_ID}`)).toEqual(initial)
|
||||
expect(events).toEqual([])
|
||||
unsubscribe()
|
||||
})
|
||||
|
||||
it('keeps a simultaneous graph-only visible change after an inventory-only acceptance', async () => {
|
||||
vi.useFakeTimers()
|
||||
const { runtime, sync, list } = fixture()
|
||||
@@ -1,12 +1,15 @@
|
||||
import '../../orca-runtime-tests/orca-runtime-test-lifecycle.spec'
|
||||
import '../../construction/test-context/orca-runtime-test-lifecycle.spec'
|
||||
import { expect, it, vi } from 'vitest'
|
||||
|
||||
import '../../orca-runtime-tests/runtime-test-module-registration.spec'
|
||||
import '../../construction/test-context/runtime-test-module-registration.spec'
|
||||
import { OrcaRuntimeService } from '../../orca-runtime'
|
||||
|
||||
import { electronMocks } from '../../orca-runtime-test-mocks/setup.spec'
|
||||
|
||||
import { TEST_WORKTREE_ID, store } from '../../orca-runtime-tests/orca-runtime-test-fixtures.spec'
|
||||
import {
|
||||
TEST_WORKTREE_ID,
|
||||
store
|
||||
} from '../../construction/test-context/orca-runtime-test-fixtures.spec'
|
||||
import '../../../../shared/orca-profiles/constants'
|
||||
|
||||
import type { BrowserTabInfo } from '../../../../shared/browser/runtime/runtime-browser-contracts'
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
import '../../orca-runtime-tests/orca-runtime-test-lifecycle.spec'
|
||||
import '../../construction/test-context/orca-runtime-test-lifecycle.spec'
|
||||
import { expect, it, vi } from 'vitest'
|
||||
|
||||
import '../../orca-runtime-tests/runtime-test-module-registration.spec'
|
||||
import '../../construction/test-context/runtime-test-module-registration.spec'
|
||||
import { OrcaRuntimeService } from '../../orca-runtime'
|
||||
|
||||
import { electronMocks } from '../../orca-runtime-test-mocks/setup.spec'
|
||||
|
||||
import { TEST_WORKTREE_ID, store } from '../../orca-runtime-tests/orca-runtime-test-fixtures.spec'
|
||||
import {
|
||||
TEST_WORKTREE_ID,
|
||||
store
|
||||
} from '../../construction/test-context/orca-runtime-test-fixtures.spec'
|
||||
|
||||
import type { RuntimeMobileSessionTabsSnapshot } from '../../../../shared/remote-runtime/session-graph/runtime-session-contracts'
|
||||
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import '../../terminal/layout/bind-first-pane.test-fixture'
|
||||
import '../../../../shared/workspace-layout/layout-owner-switch'
|
||||
import '../../construction/test-context/runtime-test-module-registration.spec'
|
||||
import { MOCK_GIT_WORKTREES, electronMocks } from '../../orca-runtime-test-mocks/setup.spec'
|
||||
import '../../orca-runtime'
|
||||
import { AgentBrowserBridge } from '../../../browser/agent-browser/agent-browser-bridge'
|
||||
|
||||
import '../../../git/worktrees/removal/worktree-removal-preflight'
|
||||
import 'electron'
|
||||
import { listWorktrees } from '../../../git/worktrees/catalog/worktree-scan-cache'
|
||||
import '../../../git/worktrees/removal/worktree-removal'
|
||||
import {
|
||||
TEST_REPO_ID,
|
||||
createRuntime
|
||||
} from '../../construction/test-context/orca-runtime-test-fixtures.spec'
|
||||
import '../../construction/test-context/orca-runtime-test-scenario-builders.spec'
|
||||
|
||||
function createBrowserBridge(overrides: Partial<AgentBrowserBridge>): AgentBrowserBridge {
|
||||
return Object.assign(vi.mockObject(AgentBrowserBridge.prototype), overrides)
|
||||
}
|
||||
|
||||
describe('OrcaRuntimeService', () => {
|
||||
describe('browser page targeting', () => {
|
||||
function mockLiveBrowserGuest(): void {
|
||||
electronMocks.webContents.fromId.mockReturnValue({
|
||||
isDestroyed: () => false,
|
||||
isLoading: () => false
|
||||
})
|
||||
}
|
||||
|
||||
it('does not silently drop invalid explicit worktree selectors for page-targeted commands', async () => {
|
||||
vi.mocked(listWorktrees).mockResolvedValue(MOCK_GIT_WORKTREES)
|
||||
mockLiveBrowserGuest()
|
||||
const runtime = createRuntime()
|
||||
const snapshotMock = vi.fn<AgentBrowserBridge['snapshot']>()
|
||||
|
||||
runtime.setAgentBrowserBridge(
|
||||
createBrowserBridge({
|
||||
snapshot: snapshotMock,
|
||||
getRegisteredTabs: vi.fn(() => new Map([['page-1', 1]])),
|
||||
getRegisteredPageWebContentsId: (page: string) => (page === 'page-1' ? 1 : undefined)
|
||||
})
|
||||
)
|
||||
|
||||
await expect(
|
||||
runtime.browserSnapshot({
|
||||
worktree: 'path:/tmp/missing-worktree',
|
||||
page: 'page-1'
|
||||
})
|
||||
).rejects.toThrow('selector_not_found')
|
||||
expect(snapshotMock).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('does not silently drop invalid explicit worktree selectors for non-page browser commands', async () => {
|
||||
vi.mocked(listWorktrees).mockResolvedValue(MOCK_GIT_WORKTREES)
|
||||
const runtime = createRuntime()
|
||||
const tabListMock = vi.fn<AgentBrowserBridge['tabList']>()
|
||||
|
||||
runtime.setAgentBrowserBridge(
|
||||
createBrowserBridge({
|
||||
tabList: tabListMock
|
||||
})
|
||||
)
|
||||
|
||||
await expect(
|
||||
runtime.browserTabList({
|
||||
worktree: 'path:/tmp/missing-worktree'
|
||||
})
|
||||
).rejects.toThrow('selector_not_found')
|
||||
expect(tabListMock).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('rejects closing an unknown page id instead of treating it as success', async () => {
|
||||
vi.mocked(listWorktrees).mockResolvedValue(MOCK_GIT_WORKTREES)
|
||||
mockLiveBrowserGuest()
|
||||
const runtime = createRuntime()
|
||||
|
||||
runtime.setAgentBrowserBridge(
|
||||
createBrowserBridge({
|
||||
getRegisteredTabs: vi.fn(() => new Map([['page-1', 1]])),
|
||||
getRegisteredPageWebContentsId: (page: string) => (page === 'page-1' ? 1 : undefined)
|
||||
})
|
||||
)
|
||||
|
||||
await expect(
|
||||
runtime.browserTabClose({
|
||||
page: 'missing-page'
|
||||
})
|
||||
).rejects.toThrow('Browser page missing-page was not found')
|
||||
})
|
||||
|
||||
it('rejects closing a page outside the explicitly scoped worktree', async () => {
|
||||
mockLiveBrowserGuest()
|
||||
vi.mocked(listWorktrees).mockResolvedValue([
|
||||
...MOCK_GIT_WORKTREES,
|
||||
{
|
||||
path: '/tmp/worktree-b',
|
||||
head: 'def',
|
||||
branch: 'feature/bar',
|
||||
isBare: false,
|
||||
isMainWorktree: false
|
||||
}
|
||||
])
|
||||
const runtime = createRuntime()
|
||||
const getRegisteredTabsMock = vi.fn((worktreeId?: string) =>
|
||||
worktreeId === `${TEST_REPO_ID}::/tmp/worktree-b` ? new Map() : new Map([['page-1', 1]])
|
||||
)
|
||||
|
||||
runtime.setAgentBrowserBridge(
|
||||
createBrowserBridge({
|
||||
getRegisteredTabs: getRegisteredTabsMock,
|
||||
getRegisteredPageWebContentsId: (page: string, worktreeId?: string) =>
|
||||
getRegisteredTabsMock(worktreeId).get(page)
|
||||
})
|
||||
)
|
||||
|
||||
await expect(
|
||||
runtime.browserTabClose({
|
||||
page: 'page-1',
|
||||
worktree: 'path:/tmp/worktree-b'
|
||||
})
|
||||
).rejects.toThrow('Browser page page-1 was not found in this worktree')
|
||||
expect(getRegisteredTabsMock).toHaveBeenCalledWith(`${TEST_REPO_ID}::/tmp/worktree-b`)
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -1,12 +1,12 @@
|
||||
import '../../orca-runtime-tests/orca-runtime-test-lifecycle.spec'
|
||||
import '../../construction/test-context/orca-runtime-test-lifecycle.spec'
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import '../../orca-runtime-tests/runtime-test-module-registration.spec'
|
||||
import '../../construction/test-context/runtime-test-module-registration.spec'
|
||||
import { OrcaRuntimeService } from '../../orca-runtime'
|
||||
import {
|
||||
TEST_WORKTREE_ID,
|
||||
makeRuntimeStoreWithWorkspaceSession,
|
||||
makeWorkspaceSessionWithHeadlessTerminal
|
||||
} from '../../orca-runtime-tests/orca-runtime-test-fixtures.spec'
|
||||
} from '../../construction/test-context/orca-runtime-test-fixtures.spec'
|
||||
import { withOpenedServeBrowserTab } from './serve-browser-tab-layout'
|
||||
import type { WorkspaceSessionState } from '../../../../shared/workspace-session/workspace-session-state-types'
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ import {
|
||||
} from '../rpc/server/runtime-rpc-mobile-ws-test-harness'
|
||||
import { makeStore } from '../rpc/server/runtime-rpc-worktree-store-fixtures'
|
||||
import { DECLARED_CLIENT_RECONNECT_GRACE_MS } from '../rpc/server/pairing/declared-desktop-clients'
|
||||
import { partialRuntimeStore } from '../orca-runtime-tests/runtime-store-partial-fixture'
|
||||
import { partialRuntimeStore } from '../construction/test-context/runtime-store-partial-fixture'
|
||||
|
||||
vi.mock('../../git/worktrees/catalog/worktree-scan-cache', async (importOriginal) => {
|
||||
const facade = getWorktreeListingMocks()
|
||||
|
||||
@@ -7,80 +7,83 @@ vi.mock('node:fs/promises', async (importOriginal) => {
|
||||
return { ...actual, mkdir: vi.fn(actual.mkdir) }
|
||||
})
|
||||
|
||||
await import('../orca-runtime-tests/runtime-test-module-registration.spec')
|
||||
await import('../orca-runtime-tests/orca-runtime-test-lifecycle.spec')
|
||||
await import('../orca-runtime-tests/orca-runtime-test-fixtures.spec')
|
||||
await import('../orca-runtime-tests/orca-runtime-test-scenario-builders.spec')
|
||||
await import('./test-context/runtime-test-module-registration.spec')
|
||||
await import('./test-context/orca-runtime-test-lifecycle.spec')
|
||||
await import('./test-context/orca-runtime-test-fixtures.spec')
|
||||
await import('./test-context/orca-runtime-test-scenario-builders.spec')
|
||||
|
||||
await import('../orca-runtime-tests/browser-capabilities.spec')
|
||||
await import('../orca-runtime-tests/window-authority.spec')
|
||||
await import('../orca-runtime-tests/terminal-handles.spec')
|
||||
await import('../orca-runtime-tests/terminal-handles-part-02.spec')
|
||||
await import('../orca-runtime-tests/terminal-listing.spec')
|
||||
await import('../orca-runtime-tests/worktree-selector-resolution.spec')
|
||||
await import('../orca-runtime-tests/local-worktree-creation.spec')
|
||||
await import('../orca-runtime-tests/hooks-and-hosted-review-part-02.spec')
|
||||
await import('../orca-runtime-tests/repository-project-operations-part-02.spec')
|
||||
await import('../orca-runtime-tests/project-setup-folder-remote-identity.spec')
|
||||
await import('../orca-runtime-tests/terminal-side-effect-facts-part-02.spec')
|
||||
await import('../orca-runtime-tests/headless-snapshots.spec')
|
||||
await import('../orca-runtime-tests/agent-status-and-waits-part-02.spec')
|
||||
await import('../orca-runtime-tests/terminal-creation-and-readiness.spec')
|
||||
await import('../orca-runtime-tests/runtime-orchestration-db.test-fixture')
|
||||
await import('../orca-runtime-tests/terminal-creation-and-readiness-part-04.spec')
|
||||
await import('../browser/client-pages/browser-capabilities.spec')
|
||||
await import('../session-graph/window-authority.spec')
|
||||
await import('../agent-session/launch/runtime-native-chat-draft-resolutions.spec')
|
||||
await import('../terminal/identity/terminal-handles.spec')
|
||||
await import('../terminal/identity/terminal-handles-part-02.spec')
|
||||
|
||||
await import('../orca-runtime-tests/terminal-creation-and-readiness-part-06.spec')
|
||||
await import('../orca-runtime-tests/terminal-creation-and-readiness-part-08.spec')
|
||||
await import('../orca-runtime-tests/terminal-creation-and-readiness-part-09.spec')
|
||||
await import('../orca-runtime-tests/terminal-creation-and-readiness-part-10.spec')
|
||||
await import('../orca-runtime-tests/terminal-creation-and-readiness-part-11.spec')
|
||||
await import('../orca-runtime-tests/conpty-stream-read.spec')
|
||||
await import('../orca-runtime-tests/terminal-output-and-worker-recovery-part-02.spec')
|
||||
await import('../workspaces/catalog/worktree-selector-resolution.spec')
|
||||
await import('../workspaces/creation/local-worktree-creation.spec')
|
||||
await import('../workspaces/references/hooks-and-hosted-review-part-02.spec')
|
||||
await import('../repositories/repository-project-operations-part-02.spec')
|
||||
await import('../repositories/project-setup-folder-remote-identity.spec')
|
||||
await import('../terminal/output/terminal-side-effect-facts-part-02.spec')
|
||||
await import('../terminal/output/headless-snapshots.spec')
|
||||
await import('../terminal/query/agent-status-and-waits-part-02.spec')
|
||||
await import('../orchestration/terminal-authority/terminal-creation-and-readiness.spec')
|
||||
await import('../orchestration/db/runtime-orchestration-db.test-fixture')
|
||||
await import('../terminal/launch/terminal-creation-and-readiness-part-04.spec')
|
||||
|
||||
await import('../orca-runtime-tests/terminal-output-and-worker-recovery-part-06.spec')
|
||||
await import('../orca-runtime-tests/terminal-output-and-worker-recovery-part-07.spec')
|
||||
await import('../orca-runtime-tests/terminal-handles-and-agent-status.spec')
|
||||
await import('../orca-runtime-tests/terminal-handles-and-agent-status-part-04.spec')
|
||||
await import('../orca-runtime-tests/terminal-handles-and-agent-status-part-05.spec')
|
||||
await import('../orca-runtime-tests/mobile-session-tabs.spec')
|
||||
await import('../orca-runtime-tests/mobile-session-tabs-part-02.spec')
|
||||
await import('../orca-runtime-tests/mobile-session-tabs-part-03.spec')
|
||||
await import('../orca-runtime-tests/mobile-session-tabs-part-04.spec')
|
||||
await import('../orca-runtime-tests/mobile-session-tabs-part-05.spec')
|
||||
await import('../orca-runtime-tests/mobile-session-tabs-part-07.spec')
|
||||
await import('../orca-runtime-tests/mobile-session-tabs-part-08.spec')
|
||||
await import('../orca-runtime-tests/mobile-session-tabs-part-09.spec')
|
||||
await import('../orca-runtime-tests/mobile-session-tabs-part-10.spec')
|
||||
await import('../orca-runtime-tests/mobile-session-tabs-part-11.spec')
|
||||
await import('../orca-runtime-tests/mobile-session-tabs-part-12.spec')
|
||||
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/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')
|
||||
await import('../orca-runtime-tests/mobile-summaries.spec')
|
||||
await import('../orca-runtime-tests/mobile-summaries-part-02.spec')
|
||||
await import('../orca-runtime-tests/mobile-summaries-part-03.spec')
|
||||
await import('../orca-runtime-tests/mobile-summaries-part-04.spec')
|
||||
await import('../orca-runtime-tests/worktree-ps-structured-host.spec')
|
||||
await import('../orca-runtime-tests/worktree-ps-agent-wait.spec')
|
||||
await import('../orca-runtime-tests/terminal-sleep-and-teardown.spec')
|
||||
await import('../orca-runtime-tests/terminal-sleep-and-teardown-part-02.spec')
|
||||
await import('../orca-runtime-tests/terminal-sleep-and-teardown-part-03.spec')
|
||||
await import('../orca-runtime-tests/lineage-and-scan-cache.spec')
|
||||
await import('../orca-runtime-tests/lineage-and-scan-cache-part-02.spec')
|
||||
await import('../orca-runtime-tests/lineage-and-scan-cache-part-05.spec')
|
||||
await import('../orca-runtime-tests/wsl-stopped-distro-worktree-scan.spec')
|
||||
await import('../terminal/wait/terminal-creation-and-readiness-part-06.spec')
|
||||
await import('../terminal/focus/terminal-creation-and-readiness-part-08.spec')
|
||||
await import('../terminal/query/terminal-creation-and-readiness-part-09.spec')
|
||||
await import('../terminal/query/terminal-creation-and-readiness-part-10.spec')
|
||||
await import('../terminal/output/terminal-creation-and-readiness-part-11.spec')
|
||||
await import('../terminal/query/conpty-stream-read.spec')
|
||||
await import('../terminal/adoption/terminal-output-and-worker-recovery-part-02.spec')
|
||||
|
||||
await import('../orca-runtime-tests/worktree-setup-and-startup-part-03.spec')
|
||||
await import('../orca-runtime-tests/worktree-setup-and-startup-part-04.spec')
|
||||
await import('../terminal/adoption/terminal-output-and-worker-recovery-part-06.spec')
|
||||
await import('../terminal/adoption/terminal-output-and-worker-recovery-part-07.spec')
|
||||
await import('../terminal/identity/terminal-handles-and-agent-status.spec')
|
||||
await import('../terminal/adoption/terminal-handles-and-agent-status-part-04.spec')
|
||||
|
||||
await import('../orca-runtime-tests/gitlab-and-pr-bases-part-02.spec')
|
||||
await import('../orca-runtime-tests/worktree-removal-and-reconciliation-part-02.spec')
|
||||
await import('../orca-runtime-tests/worktree-removal-and-reconciliation-part-03.spec')
|
||||
await import('../orca-runtime-tests/worktree-removal-and-reconciliation-part-04.spec')
|
||||
await import('../orca-runtime-tests/worktree-removal-failed-retry.spec')
|
||||
await import('../orca-runtime-tests/targeting-and-resilience.spec')
|
||||
await import('../orca-runtime-tests/worktree-scan-cache-ttl.spec')
|
||||
await import('../session-tabs/publication/mobile-session-tabs.spec')
|
||||
await import('../session-tabs/restoration/mobile-session-tabs-part-02.spec')
|
||||
await import('../session-tabs/layout/mobile-session-tabs-part-03.spec')
|
||||
await import('../session-tabs/terminal-retirement/mobile-session-tabs-part-04.spec')
|
||||
await import('../session-tabs/terminal-retirement/mobile-session-tabs-part-05.spec')
|
||||
await import('../session-tabs/restoration/mobile-session-tabs-part-07.spec')
|
||||
await import('../session-tabs/restoration/mobile-session-tabs-part-08.spec')
|
||||
await import('../session-tabs/publication/mobile-session-tabs-part-09.spec')
|
||||
await import('../session-tabs/terminal-retirement/mobile-session-tabs-part-10.spec')
|
||||
await import('../session-tabs/terminal-retirement/mobile-session-tabs-part-11.spec')
|
||||
await import('../session-tabs/layout/mobile-session-tabs-part-12.spec')
|
||||
await import('../session-tabs/layout/mobile-session-tabs-part-13.spec')
|
||||
await import('../session-tabs/inventory/mobile-session-tabs-empty-headless-snapshot.spec')
|
||||
await import('../session-tabs/restoration/mobile-session-tabs-windowless-sleep-resume.spec')
|
||||
await import('../session-lifecycle/projection/mobile-session-tabs-targeted-agent-resume.spec')
|
||||
await import('../session-tabs/terminal-retirement/exit-retirement-activation.spec')
|
||||
await import('../session-tabs/layout/mobile-creation-and-orchestration.spec')
|
||||
await import('../terminal/wait/mobile-creation-and-orchestration-part-04.spec')
|
||||
await import('../sidebar-inputs/workspace-facts/mobile-summaries.spec')
|
||||
await import('../sidebar-inputs/workspace-facts/mobile-summaries-part-02.spec')
|
||||
await import('../sidebar-inputs/workspace-facts/mobile-summaries-part-03.spec')
|
||||
await import('../sidebar-inputs/workspace-facts/mobile-summaries-part-04.spec')
|
||||
await import('../workspaces/process-listing/worktree-ps-structured-host.spec')
|
||||
await import('../workspaces/process-listing/worktree-ps-agent-wait.spec')
|
||||
await import('../terminal/stop/terminal-sleep-and-teardown.spec')
|
||||
await import('../terminal/stop/terminal-sleep-and-teardown-part-02.spec')
|
||||
await import('../push/notifications/runtime-mobile-notification-controller.spec')
|
||||
await import('../terminal/stop/terminal-sleep-idempotency-and-convergence.spec')
|
||||
await import('../terminal/stop/terminal-sleep-and-teardown-part-03.spec')
|
||||
await import('../terminal/query/terminal-listing-fresh-liveness.spec')
|
||||
await import('../workspaces/lineage/lineage-and-scan-cache.spec')
|
||||
await import('../workspaces/lineage/lineage-and-scan-cache-part-02.spec')
|
||||
await import('../orchestration/terminal-authority/lineage-and-scan-cache-part-05.spec')
|
||||
|
||||
await import('../workspaces/startup/worktree-setup-and-startup-part-03.spec')
|
||||
|
||||
await import('../workspaces/references/gitlab-and-pr-bases-part-02.spec')
|
||||
await import('../workspaces/removal/worktree-removal-and-reconciliation-part-02.spec')
|
||||
await import('../workspaces/removal/worktree-removal-and-reconciliation-part-03.spec')
|
||||
await import('../workspaces/removal/worktree-removal-and-reconciliation-part-04.spec')
|
||||
await import('../workspaces/removal/worktree-removal-failed-retry.spec')
|
||||
await import('../browser/commands/browser-page-targeting.spec')
|
||||
await import('../workspaces/removal/runtime-worktree-removal-pty-stop.spec')
|
||||
await import('../session-tabs/layout/mobile-terminal-create-resilience.spec')
|
||||
|
||||
+26
-26
@@ -3,42 +3,42 @@ import { afterEach, beforeEach, expect, vi } from 'vitest'
|
||||
import {
|
||||
forgetInstalledPaneSession,
|
||||
announceSessionWrites
|
||||
} from '../terminal/layout/profile-session-store.test-fixture'
|
||||
} from '../../terminal/layout/profile-session-store.test-fixture'
|
||||
|
||||
import { ORCA_LAYOUT_OWNER_IS_MAIN } from '../../../shared/workspace-layout/layout-owner-switch'
|
||||
import { ORCA_LAYOUT_OWNER_IS_MAIN } from '../../../../shared/workspace-layout/layout-owner-switch'
|
||||
import { createHash } from 'node:crypto'
|
||||
import { HeadlessEmulator } from '../../daemon/emulation/headless-emulator'
|
||||
import { OrcaRuntimeService } from '../orca-runtime'
|
||||
import { HeadlessEmulator } from '../../../daemon/emulation/headless-emulator'
|
||||
import { OrcaRuntimeService } from '../../orca-runtime'
|
||||
import {
|
||||
buildAgentPromptPasteBytes,
|
||||
getTerminalPasteIngestMs
|
||||
} from '../../../shared/agent-launch/startup/agent-prompt-injection'
|
||||
import { getDefaultWorkspaceSession } from '../../../shared/orca-profiles/constants'
|
||||
import { makePaneKey } from '../../../shared/workspace-layout/stable-pane-id'
|
||||
import type { LayoutCommand } from '../../../shared/workspace-layout/workspace-layout-command-types'
|
||||
import { applyCommandToSession } from '../../persistence/terminal-topology/pane-admission/terminal-pane-admission'
|
||||
import { resolveHostId } from '../../persistence/loading-store/workspace-sessions/session-host-partitions'
|
||||
import { toComparableRelaySshPtyId } from '../../../shared/remote-runtime/ssh/ssh-pty-id'
|
||||
import '../terminal/launch/spawned-pty-env-fixtures'
|
||||
} from '../../../../shared/agent-launch/startup/agent-prompt-injection'
|
||||
import { getDefaultWorkspaceSession } from '../../../../shared/orca-profiles/constants'
|
||||
import { makePaneKey } from '../../../../shared/workspace-layout/stable-pane-id'
|
||||
import type { LayoutCommand } from '../../../../shared/workspace-layout/workspace-layout-command-types'
|
||||
import { applyCommandToSession } from '../../../persistence/terminal-topology/pane-admission/terminal-pane-admission'
|
||||
import { resolveHostId } from '../../../persistence/loading-store/workspace-sessions/session-host-partitions'
|
||||
import { toComparableRelaySshPtyId } from '../../../../shared/remote-runtime/ssh/ssh-pty-id'
|
||||
import '../../terminal/launch/spawned-pty-env-fixtures'
|
||||
import './runtime-test-module-registration.spec'
|
||||
import {
|
||||
computeWorktreePathMock,
|
||||
ensurePathWithinWorkspaceMock
|
||||
} from '../orca-runtime-test-mocks/setup.spec'
|
||||
import type { ProjectGroup } from '../../../shared/project/groups/project-group-types'
|
||||
import type { RpcRequest } from '../rpc/core'
|
||||
import type { WorktreeMeta } from '../../../shared/worktree/meta-types'
|
||||
import type { TerminalLayoutSnapshot } from '../../../shared/workspace-layout/terminal-tab-types'
|
||||
import type { WorkspaceSessionState } from '../../../shared/workspace-session/workspace-session-state-types'
|
||||
import type { AgentStatusIpcPayload } from '../../../shared/agent-status/contracts/agent-status-ipc-payload'
|
||||
} from '../../orca-runtime-test-mocks/setup.spec'
|
||||
import type { ProjectGroup } from '../../../../shared/project/groups/project-group-types'
|
||||
import type { RpcRequest } from '../../rpc/core'
|
||||
import type { WorktreeMeta } from '../../../../shared/worktree/meta-types'
|
||||
import type { TerminalLayoutSnapshot } from '../../../../shared/workspace-layout/terminal-tab-types'
|
||||
import type { WorkspaceSessionState } from '../../../../shared/workspace-session/workspace-session-state-types'
|
||||
import type { AgentStatusIpcPayload } from '../../../../shared/agent-status/contracts/agent-status-ipc-payload'
|
||||
|
||||
import type { FolderWorkspace } from '../../../shared/folder-workspaces/folder-workspace-types'
|
||||
import '../orchestration/mailbox/terminal-pointer/in-memory-orchestration-messages.spec'
|
||||
import type { InMemoryOrchestrationMessages } from '../orchestration/mailbox/terminal-pointer/in-memory-orchestration-messages.spec'
|
||||
import type { OrchestrationDb } from '../orchestration/db/orchestration-db'
|
||||
import type { TerminalProcessInspection as PtyProcessInspection } from '../../../shared/terminal/pty/lifecycle/terminal-process-inspection'
|
||||
import type { Store } from '../../persistence/loading-store/store'
|
||||
import type { HostWorktreeTarget } from '../../../shared/worktree/host-qualified-identity'
|
||||
import type { FolderWorkspace } from '../../../../shared/folder-workspaces/folder-workspace-types'
|
||||
import '../../orchestration/mailbox/terminal-pointer/in-memory-orchestration-messages.spec'
|
||||
import type { InMemoryOrchestrationMessages } from '../../orchestration/mailbox/terminal-pointer/in-memory-orchestration-messages.spec'
|
||||
import type { OrchestrationDb } from '../../orchestration/db/orchestration-db'
|
||||
import type { TerminalProcessInspection as PtyProcessInspection } from '../../../../shared/terminal/pty/lifecycle/terminal-process-inspection'
|
||||
import type { Store } from '../../../persistence/loading-store/store'
|
||||
import type { HostWorktreeTarget } from '../../../../shared/worktree/host-qualified-identity'
|
||||
|
||||
type RuntimeService = InstanceType<typeof OrcaRuntimeService>
|
||||
type HeadlessTerminal = InstanceType<typeof HeadlessEmulator>
|
||||
+29
-29
@@ -82,56 +82,56 @@ import {
|
||||
updateGitLabIssueMock,
|
||||
updateGitLabMRMock,
|
||||
updateGitLabMRReviewersMock
|
||||
} from '../orca-runtime-test-mocks/setup.spec'
|
||||
import { RuntimeBrowserCommands } from '../browser/commands/browser-commands'
|
||||
import { _resetTerminalViewAttributesForTest } from '../terminal/view/terminal-view-attribute-store'
|
||||
import { addSparseWorktree } from '../../git/worktrees/creation/worktree-sparse-add'
|
||||
import { addWorktree } from '../../git/worktrees/creation/worktree-add'
|
||||
import { advertisedUrlWatcher } from '../../ports/advertised-url-watcher'
|
||||
} from '../../orca-runtime-test-mocks/setup.spec'
|
||||
import { RuntimeBrowserCommands } from '../../browser/commands/browser-commands'
|
||||
import { _resetTerminalViewAttributesForTest } from '../../terminal/view/terminal-view-attribute-store'
|
||||
import { addSparseWorktree } from '../../../git/worktrees/creation/worktree-sparse-add'
|
||||
import { addWorktree } from '../../../git/worktrees/creation/worktree-add'
|
||||
import { advertisedUrlWatcher } from '../../../ports/advertised-url-watcher'
|
||||
import { afterAll, afterEach, beforeAll, beforeEach, vi, type MockInstance } from 'vitest'
|
||||
import { initOrcaProfilePaths } from '../../orca-profiles/profile-storage-paths'
|
||||
import { stopStructuredAgentSessionRuntime } from '../agent-session/installation/structured-agent-session-runtime'
|
||||
import { assertWorktreeCleanForRemoval } from '../../git/worktrees/removal/worktree-removal-preflight'
|
||||
import { __cancelLegacyWorkerTerminalRecoveryRetriesForTests as cancelLegacyWorkerTerminalRecoveryRetriesForTests } from '../orchestration/terminal-authority/runtime-legacy-worker-terminal-recovery-controller'
|
||||
import { clearConfiguredWorktreeSharedDirectoriesCacheForTests } from '../../git/worktrees/content-paths/worktree-shared-directories'
|
||||
import { initOrcaProfilePaths } from '../../../orca-profiles/profile-storage-paths'
|
||||
import { stopStructuredAgentSessionRuntime } from '../../agent-session/installation/structured-agent-session-runtime'
|
||||
import { assertWorktreeCleanForRemoval } from '../../../git/worktrees/removal/worktree-removal-preflight'
|
||||
import { __cancelLegacyWorkerTerminalRecoveryRetriesForTests as cancelLegacyWorkerTerminalRecoveryRetriesForTests } from '../../orchestration/terminal-authority/runtime-legacy-worker-terminal-recovery-controller'
|
||||
import { clearConfiguredWorktreeSharedDirectoriesCacheForTests } from '../../../git/worktrees/content-paths/worktree-shared-directories'
|
||||
import {
|
||||
createSetupRunnerScript,
|
||||
resolveSetupRunnerShell
|
||||
} from '../../workspace-hooks/worktree-runner-script'
|
||||
} from '../../../workspace-hooks/worktree-runner-script'
|
||||
import {
|
||||
describeCreatedWorktree,
|
||||
listWorktreesStrict
|
||||
} from '../../git/worktrees/catalog/worktree-listing'
|
||||
} from '../../../git/worktrees/catalog/worktree-listing'
|
||||
import {
|
||||
getDefaultTabsLaunch,
|
||||
getEffectiveHooksFromConfig,
|
||||
shouldRunSetupForCreate
|
||||
} from '../../workspace-hooks/effective-hook-config'
|
||||
import { getEffectiveHooks, hasHooksFile, loadHooks, runHook } from '../../workspace-hooks/hooks'
|
||||
import { installFakeAppEnvironment } from '../../../../config/scripts/test-runtime/environment/vitest-host-ports-setup'
|
||||
} from '../../../workspace-hooks/effective-hook-config'
|
||||
import { getEffectiveHooks, hasHooksFile, loadHooks, runHook } from '../../../workspace-hooks/hooks'
|
||||
import { installFakeAppEnvironment } from '../../../../../config/scripts/test-runtime/environment/vitest-host-ports-setup'
|
||||
import {
|
||||
listWorktrees,
|
||||
listWorktreesSharedStrict
|
||||
} from '../../git/worktrees/catalog/worktree-scan-cache'
|
||||
import { parseOrcaYaml } from '../../../shared/workspace-setup/orca-yaml'
|
||||
import { removeWorktree } from '../../git/worktrees/removal/worktree-removal'
|
||||
} from '../../../git/worktrees/catalog/worktree-scan-cache'
|
||||
import { parseOrcaYaml } from '../../../../shared/workspace-setup/orca-yaml'
|
||||
import { removeWorktree } from '../../../git/worktrees/removal/worktree-removal'
|
||||
import {
|
||||
setRuntimeBrowserCommandsFactory,
|
||||
setRuntimeBrowserUnavailableCause
|
||||
} from '../browser/installation/runtime-browser-commands-factory'
|
||||
import { setRuntimeDesktopSurface } from '../construction/runtime-desktop-surface'
|
||||
import { setRuntimeTerminalUnavailableCause } from '../terminal/launch/native-terminal-availability'
|
||||
import { OrcaRuntimeService as runtimeMockOrcaRuntimeService } from '../orca-runtime'
|
||||
} from '../../browser/installation/runtime-browser-commands-factory'
|
||||
import { setRuntimeDesktopSurface } from '../runtime-desktop-surface'
|
||||
import { setRuntimeTerminalUnavailableCause } from '../../terminal/launch/native-terminal-availability'
|
||||
import { OrcaRuntimeService as runtimeMockOrcaRuntimeService } from '../../orca-runtime'
|
||||
|
||||
import * as worktreeChangeInvalidators from '../../ipc/worktrees/listing/worktree-change-invalidators'
|
||||
import { awaitBackgroundRemovalsInRuntimeTests } from '../workspaces/removal/orca-runtime-background-removal-test-support'
|
||||
import { commitFakeSpawnsInRuntimeTests } from './bind-first-pane.test-fixture'
|
||||
import * as worktreeChangeInvalidators from '../../../ipc/worktrees/listing/worktree-change-invalidators'
|
||||
import { awaitBackgroundRemovalsInRuntimeTests } from '../../workspaces/removal/orca-runtime-background-removal-test-support'
|
||||
import { commitFakeSpawnsInRuntimeTests } from '../../terminal/layout/bind-first-pane.test-fixture'
|
||||
import {
|
||||
_resetPendingWorktreeRemovalsForTests,
|
||||
_settlePendingWorktreeRemovalsForTests
|
||||
} from '../../workspaces/removal/worktree-background-removal'
|
||||
import { _resetCanonicalRepoKeyCacheForTests } from '../../git/repositories/canonical-repo-key'
|
||||
import { setWorktreeRemovalRecordsDirectory } from '../../workspaces/removal/worktree-removal-table'
|
||||
} from '../../../workspaces/removal/worktree-background-removal'
|
||||
import { _resetCanonicalRepoKeyCacheForTests } from '../../../git/repositories/canonical-repo-key'
|
||||
import { setWorktreeRemovalRecordsDirectory } from '../../../workspaces/removal/worktree-removal-table'
|
||||
|
||||
awaitBackgroundRemovalsInRuntimeTests(runtimeMockOrcaRuntimeService.prototype)
|
||||
commitFakeSpawnsInRuntimeTests(runtimeMockOrcaRuntimeService.prototype)
|
||||
+13
-13
@@ -1,13 +1,13 @@
|
||||
import * as gitExecFile from '../../git/command-runner/git-exec-file'
|
||||
import { CrewChanges } from '../orchestration/crew/crew-changes'
|
||||
import * as gitExecFile from '../../../git/command-runner/git-exec-file'
|
||||
import { CrewChanges } from '../../orchestration/crew/crew-changes'
|
||||
import { withDurableRuntimeStore } from './runtime-durable-store-fixture'
|
||||
import './runtime-test-module-registration.spec'
|
||||
import { HEADLESS_RUNTIME_WINDOW_ID } from '../../../shared/remote-runtime/session-graph/runtime-session-contracts'
|
||||
import { OrcaRuntimeService } from '../orca-runtime'
|
||||
import { electronMocks } from '../orca-runtime-test-mocks/setup.spec'
|
||||
import { getBrowserHostLeaseRegistry } from '../browser-host/leases/browser-host-lease-registry-instance'
|
||||
import { getDefaultWorkspaceSession } from '../../../shared/orca-profiles/constants'
|
||||
import { getRuntimeBrowserPageRegistry } from '../browser/client-pages/runtime-browser-page-registry'
|
||||
import { HEADLESS_RUNTIME_WINDOW_ID } from '../../../../shared/remote-runtime/session-graph/runtime-session-contracts'
|
||||
import { OrcaRuntimeService } from '../../orca-runtime'
|
||||
import { electronMocks } from '../../orca-runtime-test-mocks/setup.spec'
|
||||
import { getBrowserHostLeaseRegistry } from '../../browser-host/leases/browser-host-lease-registry-instance'
|
||||
import { getDefaultWorkspaceSession } from '../../../../shared/orca-profiles/constants'
|
||||
import { getRuntimeBrowserPageRegistry } from '../../browser/client-pages/runtime-browser-page-registry'
|
||||
import { vi } from 'vitest'
|
||||
import type { Mock } from 'vitest'
|
||||
|
||||
@@ -19,11 +19,11 @@ const { TEST_WORKTREE_PATH, makeHeadlessTerminalLayout, makeRuntimeStoreWithWork
|
||||
fixtures
|
||||
const { makeWorkspaceSessionWithHeadlessTerminal, store } = fixtures
|
||||
|
||||
import type { RuntimeBrowserClientPlacement } from '../../../shared/browser/client-hosting/runtime-browser-placement'
|
||||
import type { WorkspaceSessionState } from '../../../shared/workspace-session/workspace-session-state-types'
|
||||
import type { BrowserClientHostCommandEvent } from '../../../shared/browser/client-hosting/browser-client-host-protocol'
|
||||
import type { TerminalSideEffectBatch } from '../../../shared/terminal/output/terminal-side-effect-facts'
|
||||
import type { OrchestrationDb } from '../orchestration/db/orchestration-db'
|
||||
import type { RuntimeBrowserClientPlacement } from '../../../../shared/browser/client-hosting/runtime-browser-placement'
|
||||
import type { WorkspaceSessionState } from '../../../../shared/workspace-session/workspace-session-state-types'
|
||||
import type { BrowserClientHostCommandEvent } from '../../../../shared/browser/client-hosting/browser-client-host-protocol'
|
||||
import type { TerminalSideEffectBatch } from '../../../../shared/terminal/output/terminal-side-effect-facts'
|
||||
import type { OrchestrationDb } from '../../orchestration/db/orchestration-db'
|
||||
|
||||
type RuntimeService = InstanceType<typeof OrcaRuntimeService>
|
||||
type TestMock = Mock
|
||||
+7
-7
@@ -1,18 +1,18 @@
|
||||
import type { DurableProfileStateMutation } from '../../persistence/loading-store/store-runtime-state'
|
||||
import { profileStateWriterFailureOutcome } from '../../persistence/profile-state/writer/profile-state-writer-errors'
|
||||
import { resolveHostId } from '../../persistence/loading-store/workspace-sessions/session-host-partitions'
|
||||
import type { DurableProfileStateMutation } from '../../../persistence/loading-store/store-runtime-state'
|
||||
import { profileStateWriterFailureOutcome } from '../../../persistence/profile-state/writer/profile-state-writer-errors'
|
||||
import { resolveHostId } from '../../../persistence/loading-store/workspace-sessions/session-host-partitions'
|
||||
import {
|
||||
admitPaneToSession,
|
||||
withdrawPaneFromSession,
|
||||
type PaneLayoutChange,
|
||||
type TerminalPaneAdmission
|
||||
} from '../../persistence/terminal-topology/pane-admission/terminal-pane-admission'
|
||||
} from '../../../persistence/terminal-topology/pane-admission/terminal-pane-admission'
|
||||
import type {
|
||||
CommandOf,
|
||||
LayoutRefusalCode
|
||||
} from '../../../shared/workspace-layout/workspace-layout-command-types'
|
||||
import type { WorkspaceSessionState } from '../../../shared/workspace-session/workspace-session-state-types'
|
||||
import { clearReplacedPaneBinding } from '../../persistence/loading-store/terminal-bindings/replaced-pane-binding'
|
||||
} from '../../../../shared/workspace-layout/workspace-layout-command-types'
|
||||
import type { WorkspaceSessionState } from '../../../../shared/workspace-session/workspace-session-state-types'
|
||||
import { clearReplacedPaneBinding } from '../../../persistence/loading-store/terminal-bindings/replaced-pane-binding'
|
||||
|
||||
/** Keep runtime fakes on the same reserved, durable-before-ack contract as Store. */
|
||||
export function withDurableRuntimeStore<
|
||||
+7
-7
@@ -1,10 +1,10 @@
|
||||
import type { RuntimeStore } from '../construction/runtime-store-contract'
|
||||
import type { GlobalSettings } from '../../../shared/settings/global-settings-types'
|
||||
import type { Repo } from '../../../shared/repository/repo-types'
|
||||
import type { WorktreeMeta } from '../../../shared/worktree/meta-types'
|
||||
import type { Project } from '../../../shared/project/project-types'
|
||||
import type { ProjectGroup } from '../../../shared/project/groups/project-group-types'
|
||||
import type { FolderWorkspace } from '../../../shared/folder-workspaces/folder-workspace-types'
|
||||
import type { RuntimeStore } from '../runtime-store-contract'
|
||||
import type { GlobalSettings } from '../../../../shared/settings/global-settings-types'
|
||||
import type { Repo } from '../../../../shared/repository/repo-types'
|
||||
import type { WorktreeMeta } from '../../../../shared/worktree/meta-types'
|
||||
import type { Project } from '../../../../shared/project/project-types'
|
||||
import type { ProjectGroup } from '../../../../shared/project/groups/project-group-types'
|
||||
import type { FolderWorkspace } from '../../../../shared/folder-workspaces/folder-workspace-types'
|
||||
|
||||
type RuntimeSettings = ReturnType<RuntimeStore['getSettings']>
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
import '../../orca-runtime-test-mocks/setup.spec'
|
||||
import 'vitest'
|
||||
import '../../browser/commands/browser-commands'
|
||||
import '../../browser/installation/runtime-browser-commands-factory'
|
||||
import '../../orchestration/terminal-authority/runtime-legacy-worker-terminal-recovery-controller'
|
||||
import '../../terminal/launch/native-terminal-availability'
|
||||
import '../runtime-desktop-surface'
|
||||
import '../../../../../config/scripts/test-runtime/environment/vitest-host-ports-setup'
|
||||
import 'node:perf_hooks'
|
||||
import 'node:events'
|
||||
import 'node:crypto'
|
||||
import 'node:child_process'
|
||||
import 'node:fs'
|
||||
import 'node:fs/promises'
|
||||
import 'node:os'
|
||||
import 'node:path'
|
||||
import 'electron'
|
||||
import '../../../../shared/agent-status/contracts/agent-status-freshness'
|
||||
import '../../../../shared/worktree/hosted-review/review-head-tracking-ref'
|
||||
import '../../../../shared/agent-status/title/agent-title-status'
|
||||
import '../../../../shared/agent-status/title/osc-title-extraction'
|
||||
import '../../../git/worktrees/creation/worktree-sparse-add'
|
||||
import '../../../git/worktrees/creation/worktree-add'
|
||||
import '../../../git/worktrees/removal/worktree-removal-preflight'
|
||||
import '../../../git/worktrees/catalog/worktree-listing'
|
||||
import '../../../git/worktrees/catalog/worktree-scan-cache'
|
||||
import '../../../git/worktrees/removal/worktree-removal'
|
||||
import '../../workspaces/removal/worktree-teardown'
|
||||
import '../../workspaces/removal/worktree-teardown-deadline'
|
||||
import '../../../git/source-control/submodules/submodule-paths'
|
||||
import '../../../workspace-hooks/hooks'
|
||||
import '../../../../shared/workspace-setup/orca-yaml'
|
||||
import '../../../workspace-hooks/worktree-runner-script'
|
||||
import '../../../workspace-hooks/effective-hook-config'
|
||||
import '../../../git/repositories/repository-name'
|
||||
import '../../../git/remotes/repo-remote-queries'
|
||||
import '../../../git/repositories/discovery/repo-detection'
|
||||
import '../../../git/refs/resolution/repo-base-ref-search'
|
||||
import '../../../git/refs/resolution/repo-branch-conflict'
|
||||
import '../../orchestration/db/orchestration-db'
|
||||
import '../../orchestration/db/contract-constants'
|
||||
import '../../orchestration/db/messages/mailbox-routing-page'
|
||||
import '../../orchestration/db/dispatch-row-writer'
|
||||
import '../../orchestration/db/attempt-outcome-projection'
|
||||
import '../../orca-runtime'
|
||||
import '../../session-graph/runtime-graph-reload-lifecycle'
|
||||
import '../../browser/client-pages/runtime-browser-page-registry'
|
||||
import '../../browser-host/leases/browser-host-lease-registry-instance'
|
||||
import '../../terminal/output/recent-pty-output-buffer'
|
||||
import '../../session-lifecycle/projection/mobile-session-browser-equality'
|
||||
import '../../session-lifecycle/projection/mobile-session-browser-group-projection'
|
||||
import '../../../daemon/emulation/headless-emulator'
|
||||
|
||||
import '../../../../shared/terminal/input/terminal-input'
|
||||
import '../../../../shared/agent-launch/startup/agent-prompt-injection'
|
||||
import '../../../../shared/clipboard/clipboard-text'
|
||||
import '../../../../shared/project/host-setup/project-host-setup-projection'
|
||||
import '../../../memory/pty-registry'
|
||||
import '../../../providers/pty/process-inspection'
|
||||
import '../../../workspaces/catalog/worktree-path-comparison-key'
|
||||
import '../../../workspaces/removal/local-worktree-filesystem'
|
||||
import '../../../../shared/orca-profiles/constants'
|
||||
import '../../../ports/advertised-url-watcher'
|
||||
import '../../../../shared/workspace-layout/stable-pane-id'
|
||||
import '../../../../shared/agent-launch/startup/setup-agent-sequencing'
|
||||
import '../../../../shared/worktree/id'
|
||||
import '../../../../shared/agent-launch/catalog/tui-agent-config'
|
||||
import '../../../workspaces/removal/watcher-removal-gate'
|
||||
import '../../../workspaces/removal/watcher-removal-drain'
|
||||
import '../../terminal/view/terminal-view-attribute-store'
|
||||
import '../../../git/worktrees/content-paths/worktree-shared-directories'
|
||||
import '../../../workspaces/removal/worktree-watcher-removal'
|
||||
import '../../orchestration/db/root-dispatch-test-fixture'
|
||||
@@ -24,7 +24,7 @@ import {
|
||||
} from '../rpc/server/runtime-rpc-mobile-ws-test-harness'
|
||||
import { makeStore } from '../rpc/server/runtime-rpc-worktree-store-fixtures'
|
||||
import type { MobileDesktopRelayHosts } from './mobile-desktop-relay-hosts'
|
||||
import { partialRuntimeStore } from '../orca-runtime-tests/runtime-store-partial-fixture'
|
||||
import { partialRuntimeStore } from '../construction/test-context/runtime-store-partial-fixture'
|
||||
|
||||
vi.mock('../../git/worktrees/catalog/worktree-scan-cache', async (importOriginal) => {
|
||||
const listings = getWorktreeListingMocks()
|
||||
|
||||
@@ -23,10 +23,10 @@ import { OrcaRuntimeRpcServer } from './rpc/server/runtime-rpc'
|
||||
import { readRuntimeMetadata } from './rpc/server/runtime-metadata'
|
||||
import { sendRequest } from './rpc/server/runtime-rpc-test-harness'
|
||||
import { makeStore } from './rpc/server/runtime-rpc-worktree-store-fixtures'
|
||||
import { partialRuntimeStore } from './orca-runtime-tests/runtime-store-partial-fixture'
|
||||
import { partialRuntimeStore } from './construction/test-context/runtime-store-partial-fixture'
|
||||
import { settledWriteStub } from '../providers/testing/settled-pty-write-stub'
|
||||
import { publishHeadlessRuntimeGraph } from './session-graph/headless-runtime-graph'
|
||||
import { committingSpawn } from './orca-runtime-tests/bind-first-pane.test-fixture'
|
||||
import { committingSpawn } from './terminal/layout/bind-first-pane.test-fixture'
|
||||
|
||||
vi.mock('../git/worktrees/catalog/worktree-scan-cache', async (importOriginal) => ({
|
||||
...(await importOriginal<typeof WorktreeScanCacheModule>()),
|
||||
|
||||
@@ -1,212 +0,0 @@
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import './runtime-test-module-registration.spec'
|
||||
import { OrcaRuntimeService } from '../orca-runtime'
|
||||
import { setPlatform } from '../orca-runtime-test-mocks/setup.spec'
|
||||
import type { HeadlessEmulator } from '../../daemon/emulation/headless-emulator'
|
||||
import { makePaneKey } from '../../../shared/workspace-layout/stable-pane-id'
|
||||
import {
|
||||
declarePendingPaneSerializer,
|
||||
settlePendingPaneSerializer
|
||||
} from '../../ipc/pty/pane/serializer-state'
|
||||
import { seedHeadlessTerminalFromSpawnResult } from '../../ipc/pty/pane/terminal-spawn-restore'
|
||||
|
||||
import {
|
||||
TEST_WORKTREE_ID,
|
||||
createRuntime,
|
||||
makeDeferred,
|
||||
parseHeadlessSnapshotLines,
|
||||
store,
|
||||
syncSinglePty
|
||||
} from './orca-runtime-test-fixtures.spec'
|
||||
|
||||
describe('OrcaRuntimeService', () => {
|
||||
it('orders headless mirror resizes behind queued PTY writes', async () => {
|
||||
const spawn = { cols: 80, rows: 10 }
|
||||
const resized = { cols: 120, rows: 10 }
|
||||
let currentSize = spawn
|
||||
const runtime = createRuntime()
|
||||
runtime.setPtyController({
|
||||
write: () => true,
|
||||
kill: () => true,
|
||||
getForegroundProcess: async () => null,
|
||||
getSize: () => currentSize,
|
||||
resize: () => {
|
||||
currentSize = resized
|
||||
return true
|
||||
}
|
||||
})
|
||||
await syncSinglePty(runtime, 'pty-1')
|
||||
runtime.onPtyData('pty-1', 'prompt\r\n', 100)
|
||||
await runtime.serializeMainTerminalBuffer('pty-1')
|
||||
|
||||
type HeadlessStateForTest = {
|
||||
emulator: HeadlessEmulator
|
||||
writeChain: Promise<void>
|
||||
}
|
||||
const headless = (
|
||||
runtime as unknown as { headlessTerminals: Map<string, HeadlessStateForTest> }
|
||||
).headlessTerminals.get('pty-1')
|
||||
expect(headless).toBeDefined()
|
||||
const originalWrite = headless!.emulator.write.bind(headless!.emulator)
|
||||
const queuedWriteStarted = makeDeferred()
|
||||
const releaseQueuedWrite = makeDeferred()
|
||||
headless!.emulator.write = async (data: string): Promise<void> => {
|
||||
queuedWriteStarted.resolve()
|
||||
await releaseQueuedWrite.promise
|
||||
await originalWrite(data)
|
||||
}
|
||||
|
||||
try {
|
||||
runtime.onPtyData('pty-1', '\x1b[90GOLD', 200)
|
||||
await queuedWriteStarted.promise
|
||||
await runtime.updateDesktopViewport('pty-1', resized)
|
||||
runtime.onPtyData('pty-1', '\r\nNEXT', 300)
|
||||
releaseQueuedWrite.resolve()
|
||||
|
||||
const snapshot = await runtime.serializeMainTerminalBuffer('pty-1', { scrollbackRows: 100 })
|
||||
expect(snapshot).toMatchObject({ cols: resized.cols, rows: resized.rows })
|
||||
await expect(parseHeadlessSnapshotLines(snapshot!, resized)).resolves.toEqual([
|
||||
'prompt',
|
||||
' O',
|
||||
'LD',
|
||||
'NEXT'
|
||||
])
|
||||
} finally {
|
||||
headless!.emulator.write = originalWrite
|
||||
releaseQueuedWrite.resolve()
|
||||
}
|
||||
})
|
||||
|
||||
it('keeps pre-TUI shell scrollback when hydrating from a renderer on the alternate screen (#6106)', async () => {
|
||||
// Renderer serialization emits normal scrollback before alt-screen bytes; zeroing scrollback loses shell history.
|
||||
const serializeBuffer = vi.fn(async (_ptyId: string, opts?: { scrollbackRows?: number }) => {
|
||||
const suppressesScrollback =
|
||||
(opts as Record<string, unknown> | undefined)?.altScreenForcesZeroRows === true
|
||||
const scrollback = suppressesScrollback ? '' : 'PRE_CODEX_START\r\nAGENTS.md\r\n'
|
||||
return {
|
||||
data: `${scrollback}\x1b[?1049h\x1b[HCodex TUI frame`,
|
||||
cols: 80,
|
||||
rows: 24
|
||||
}
|
||||
})
|
||||
const runtime = createRuntime()
|
||||
runtime.setPtyController({
|
||||
write: () => true,
|
||||
kill: () => true,
|
||||
getForegroundProcess: async () => null,
|
||||
serializeBuffer,
|
||||
hasRendererSerializer: () => true,
|
||||
getSize: () => ({ cols: 80, rows: 24 })
|
||||
})
|
||||
await syncSinglePty(runtime, 'pty-1')
|
||||
|
||||
runtime.onPtyData('pty-1', 'live byte', 100)
|
||||
|
||||
const snapshot = await runtime.serializeMainTerminalBuffer('pty-1', { scrollbackRows: 1000 })
|
||||
const restored = `${snapshot?.scrollbackAnsi ?? ''}${snapshot?.data ?? ''}`
|
||||
expect(restored).toContain('PRE_CODEX_START')
|
||||
expect(restored).toContain('AGENTS.md')
|
||||
})
|
||||
|
||||
it('retains cold-restored history in hidden-output recovery while renderer serialization is pending', async () => {
|
||||
const runtime = createRuntime()
|
||||
await syncSinglePty(runtime, 'cold-pty')
|
||||
const paneKey = makePaneKey('tab-1', '44444444-4444-4444-8444-444444444444')
|
||||
const generation = declarePendingPaneSerializer(paneKey, undefined)
|
||||
try {
|
||||
seedHeadlessTerminalFromSpawnResult(
|
||||
runtime,
|
||||
{
|
||||
id: 'cold-pty',
|
||||
coldRestore: { scrollback: 'restored history\r\n', cwd: '/tmp', cols: 40, rows: 6 }
|
||||
},
|
||||
paneKey
|
||||
)
|
||||
runtime.onPtyData('cold-pty', 'fresh shell prompt $ ', 100)
|
||||
|
||||
const snapshot = await runtime.serializeHiddenOutputRecoveryBuffer('cold-pty', {
|
||||
scrollbackRows: 100
|
||||
})
|
||||
expect(snapshot?.data).toContain('restored history')
|
||||
expect(snapshot?.data).toContain('fresh shell prompt $ ')
|
||||
} finally {
|
||||
settlePendingPaneSerializer(paneKey, generation)
|
||||
}
|
||||
})
|
||||
|
||||
it('binds shell ownership evidence to the headless snapshot sequence', async () => {
|
||||
const runtime = createRuntime()
|
||||
let resolveConfirmation: ((confirmed: boolean) => void) | undefined
|
||||
const confirmShellForeground = vi.fn(
|
||||
() => new Promise<boolean>((resolve) => void (resolveConfirmation = resolve))
|
||||
)
|
||||
runtime.setPtyController({
|
||||
write: () => true,
|
||||
kill: () => true,
|
||||
getForegroundProcess: async () => null,
|
||||
confirmShellForeground
|
||||
})
|
||||
await syncSinglePty(runtime, 'pty-1')
|
||||
|
||||
runtime.onPtyData('pty-1', '\x1b[?1049hTUI\x1b]133;D;137\x07shell-marker', 100)
|
||||
const shellSnapshotPromise = runtime.serializeHiddenOutputRecoveryBuffer('pty-1')
|
||||
await vi.waitFor(() => expect(confirmShellForeground).toHaveBeenCalledTimes(1))
|
||||
let snapshotSettled = false
|
||||
void shellSnapshotPromise.then(() => {
|
||||
snapshotSettled = true
|
||||
})
|
||||
await Promise.resolve()
|
||||
expect(snapshotSettled).toBe(false)
|
||||
|
||||
resolveConfirmation?.(true)
|
||||
const shellSnapshot = await shellSnapshotPromise
|
||||
// Direct providers cannot inject a daemon reset barrier; retain poisoned alt mode with proof for renderer grounding.
|
||||
expect(shellSnapshot).toMatchObject({
|
||||
alternateScreen: true,
|
||||
terminalOwner: 'shell',
|
||||
seq: '\x1b[?1049hTUI\x1b]133;D;137\x07shell-marker'.length
|
||||
})
|
||||
expect(confirmShellForeground).toHaveBeenCalledTimes(1)
|
||||
|
||||
runtime.onPtyData('pty-1', '\x1b]133;C\x07\x1b[?1049hLIVE-TUI', 101)
|
||||
const liveSnapshot = await runtime.serializeHiddenOutputRecoveryBuffer('pty-1')
|
||||
|
||||
expect(liveSnapshot?.alternateScreen).toBe(true)
|
||||
expect(liveSnapshot?.terminalOwner).toBeUndefined()
|
||||
})
|
||||
|
||||
it('keeps SSH OSC7 cwd POSIX when the desktop runtime is on Windows', async () => {
|
||||
setPlatform('win32')
|
||||
const runtime = new OrcaRuntimeService(store)
|
||||
runtime.preparePtyExecutionContext('pty-ssh', 'Ubuntu', { resetIncarnation: true })
|
||||
runtime.registerPty('pty-ssh', TEST_WORKTREE_ID, 'ssh-conn-1')
|
||||
|
||||
runtime.onPtyData('pty-ssh', '\x1b]7;file://remote-host/home/me/repo/src\x07', 123)
|
||||
|
||||
const internals = runtime as unknown as {
|
||||
terminalCwdByPtyId: Map<string, string>
|
||||
terminalFileUriHostnameByPtyId: Map<string, string>
|
||||
wslDistroByPtyId: Map<string, string>
|
||||
}
|
||||
expect(internals.terminalCwdByPtyId.get('pty-ssh')).toBe('/home/me/repo/src')
|
||||
expect(internals.terminalFileUriHostnameByPtyId.get('pty-ssh')).toBe('remote-host')
|
||||
expect(internals.wslDistroByPtyId.has('pty-ssh')).toBe(false)
|
||||
})
|
||||
|
||||
it('uses per-incarnation WSL context before registration and across simultaneous distros', () => {
|
||||
setPlatform('win32')
|
||||
const runtime = new OrcaRuntimeService(store)
|
||||
runtime.preparePtyExecutionContext('pty-ubuntu', 'Ubuntu', { resetIncarnation: true })
|
||||
runtime.preparePtyExecutionContext('pty-debian', 'Debian', { resetIncarnation: true })
|
||||
runtime.registerPty('pty-ubuntu', TEST_WORKTREE_ID)
|
||||
runtime.registerPty('pty-debian', TEST_WORKTREE_ID)
|
||||
|
||||
runtime.onPtyData('pty-ubuntu', '\x1b]7;file://DESKTOP/home/me/repo\x07', 1)
|
||||
runtime.onPtyData('pty-debian', '\x1b]7;file://DESKTOP/home/me/repo\x07', 1)
|
||||
|
||||
const cwds = (runtime as unknown as { terminalCwdByPtyId: Map<string, string> })
|
||||
.terminalCwdByPtyId
|
||||
expect(cwds.get('pty-ubuntu')).toBe('\\\\wsl.localhost\\Ubuntu\\home\\me\\repo')
|
||||
expect(cwds.get('pty-debian')).toBe('\\\\wsl.localhost\\Debian\\home\\me\\repo')
|
||||
})
|
||||
})
|
||||
@@ -1,133 +0,0 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import './runtime-test-module-registration.spec'
|
||||
import { OrcaRuntimeService } from '../orca-runtime'
|
||||
import { setPlatform } from '../orca-runtime-test-mocks/setup.spec'
|
||||
import * as worktreePathComparison from '../../workspaces/catalog/worktree-path-comparison-key'
|
||||
import type { WorktreeMeta } from '../../../shared/worktree/meta-types'
|
||||
import { makeWorktreeMeta, store, syncSinglePty } from './orca-runtime-test-fixtures.spec'
|
||||
|
||||
describe('OrcaRuntimeService', () => {
|
||||
it('keeps pinned and unread worktrees when active rows fill the mobile summary limit', async () => {
|
||||
setPlatform('win32')
|
||||
const remoteRepo = {
|
||||
id: 'repo-pinned-limit',
|
||||
path: '/remote',
|
||||
displayName: 'pinned-limit-vm',
|
||||
badgeColor: 'blue',
|
||||
addedAt: 1,
|
||||
connectionId: 'ssh-pinned-limit'
|
||||
}
|
||||
const activeWorktrees = Array.from({ length: 199 }, (_, index) => ({
|
||||
path: `relative/active-${String(index).padStart(3, '0')}`,
|
||||
head: `head-${index}`,
|
||||
branch: `refs/heads/active-${index}`,
|
||||
isBare: false,
|
||||
isMainWorktree: false
|
||||
}))
|
||||
const pinnedPath = 'relative/zzz-pinned'
|
||||
const unreadPath = 'relative/zzz-unread'
|
||||
const pinnedId = `${remoteRepo.id}::${pinnedPath}`
|
||||
const unreadId = `${remoteRepo.id}::${unreadPath}`
|
||||
// No SSH Git provider is installed, so these fixtures use stored rows.
|
||||
const metaById: Record<string, WorktreeMeta> = {
|
||||
...Object.fromEntries(
|
||||
activeWorktrees.map((worktree) => [
|
||||
`${remoteRepo.id}::${worktree.path}`,
|
||||
makeWorktreeMeta()
|
||||
])
|
||||
),
|
||||
[pinnedId]: makeWorktreeMeta({ isPinned: true }),
|
||||
[unreadId]: makeWorktreeMeta({ isUnread: true })
|
||||
}
|
||||
const runtimeStore = {
|
||||
...store,
|
||||
getRepos: () => [remoteRepo],
|
||||
getRepo: (id: string) => (id === remoteRepo.id ? remoteRepo : undefined),
|
||||
getAllWorktreeMeta: () => metaById,
|
||||
getWorktreeMeta: (worktreeId: string) => metaById[worktreeId]
|
||||
}
|
||||
const now = Date.now()
|
||||
const runtime = new OrcaRuntimeService(runtimeStore as never, undefined, {
|
||||
getAgentStatusSnapshot: () =>
|
||||
activeWorktrees.map((worktree, index) => ({
|
||||
paneKey: `active-tab:${String(index).padStart(8, '0')}-8888-4888-8888-888888888888`,
|
||||
worktreeId: `${remoteRepo.id}::${worktree.path.replace('relative/', 'relative/./')}`,
|
||||
tabId: 'active-tab',
|
||||
state: 'working' as const,
|
||||
prompt: 'active row',
|
||||
agentType: 'codex',
|
||||
connectionId: 'ssh-pinned-limit',
|
||||
receivedAt: now,
|
||||
stateStartedAt: now - 100
|
||||
}))
|
||||
})
|
||||
|
||||
const summaries = await runtime.getWorktreePs()
|
||||
|
||||
expect(summaries).toMatchObject({ totalCount: 201, truncated: true })
|
||||
expect(summaries.worktrees).toHaveLength(200)
|
||||
expect(summaries.worktrees.find((worktree) => worktree.worktreeId === pinnedId)).toMatchObject({
|
||||
isPinned: true,
|
||||
hasHostSidebarActivity: false
|
||||
})
|
||||
expect(summaries.worktrees.find((worktree) => worktree.worktreeId === unreadId)).toMatchObject({
|
||||
unread: true,
|
||||
hasHostSidebarActivity: false
|
||||
})
|
||||
expect(
|
||||
worktreePathComparison.worktreePathComparisonKey(activeWorktrees[0]!.path, 'linux')
|
||||
).toBe(
|
||||
worktreePathComparison.worktreePathComparisonKey(
|
||||
activeWorktrees[0]!.path.replace('relative/', 'relative/./'),
|
||||
'linux'
|
||||
)
|
||||
)
|
||||
})
|
||||
|
||||
it('clears stale working status after the agent exits and the shell takes over the title', async () => {
|
||||
// Recompute from the live title so retained agent status cannot strand a working spinner (#1437).
|
||||
const runtime = new OrcaRuntimeService(store)
|
||||
|
||||
runtime.attachWindow(1)
|
||||
await runtime.syncWindowGraph(1, {
|
||||
tabs: [
|
||||
{
|
||||
tabId: 'tab-1',
|
||||
worktreeId: 'repo-1::/tmp/worktree-a',
|
||||
title: 'Codex working',
|
||||
activeLeafId: 'pane:1',
|
||||
layout: null
|
||||
}
|
||||
],
|
||||
leaves: [
|
||||
{
|
||||
tabId: 'tab-1',
|
||||
worktreeId: 'repo-1::/tmp/worktree-a',
|
||||
leafId: 'pane:1',
|
||||
paneRuntimeId: 1,
|
||||
ptyId: 'pty-1'
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
runtime.onPtyData('pty-1', '\x1b]0;Codex working\x07', 100)
|
||||
const working = await runtime.getWorktreePs()
|
||||
expect(working.worktrees[0].status).toBe('working')
|
||||
|
||||
runtime.onPtyData('pty-1', '\x1b]0;bash\x07', 200)
|
||||
const afterExit = await runtime.getWorktreePs()
|
||||
expect(afterExit.worktrees[0].status).toBe('active')
|
||||
})
|
||||
|
||||
it('shows worktree.ps active when the current pane is the Claude agents screen', async () => {
|
||||
const runtime = new OrcaRuntimeService(store)
|
||||
|
||||
await syncSinglePty(runtime, 'pty-1', { paneTitle: 'claude working' })
|
||||
runtime.onPtyData('pty-1', '\x1b]0;claude working\x07', 100)
|
||||
await syncSinglePty(runtime, 'pty-1', { paneTitle: 'claude agents' })
|
||||
|
||||
const summary = await runtime.getWorktreePs()
|
||||
|
||||
expect(summary.worktrees[0].status).toBe('active')
|
||||
})
|
||||
})
|
||||
@@ -1,365 +0,0 @@
|
||||
import { realpathSync } from 'node:fs'
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import './runtime-test-module-registration.spec'
|
||||
import { OrcaRuntimeService } from '../orca-runtime'
|
||||
import { execFileSync } from 'node:child_process'
|
||||
import * as forkMetadata from '../../github/client/fetch/repo-slug-upstream'
|
||||
import { join } from 'node:path'
|
||||
import { mkdtemp, rm } from 'node:fs/promises'
|
||||
import { projectHostSetupProjectionFromRepos } from '../../../shared/project/host-setup/project-host-setup-projection'
|
||||
import { tmpdir } from 'node:os'
|
||||
import { store } from './orca-runtime-test-fixtures.spec'
|
||||
import type { Repo } from '../../../shared/repository/repo-types'
|
||||
import type { RuntimeStore } from '../construction/runtime-store-contract'
|
||||
|
||||
const parentProbe = vi.spyOn(forkMetadata, 'probeRepoUpstream')
|
||||
beforeEach(() => {
|
||||
parentProbe.mockReset().mockResolvedValue({ upstream: undefined, origin: null })
|
||||
})
|
||||
|
||||
function createRuntime(repos: Repo[]): OrcaRuntimeService {
|
||||
const runtimeStore: RuntimeStore = {
|
||||
...store,
|
||||
getRepos: () => [...repos],
|
||||
addRepo: (repo: Repo) => {
|
||||
repos.push(repo)
|
||||
},
|
||||
getRepo: (id: string) => repos.find((repo) => repo.id === id),
|
||||
updateRepo: ({ id }, updates) => {
|
||||
const repo = repos.find((entry) => entry.id === id)
|
||||
if (!repo) {
|
||||
return null
|
||||
}
|
||||
Object.assign(repo, updates)
|
||||
return { ...repo }
|
||||
},
|
||||
removeProjectForHost: ({ id }: { id: string }) => {
|
||||
const index = repos.findIndex((repo) => repo.id === id)
|
||||
if (index !== -1) {
|
||||
repos.splice(index, 1)
|
||||
}
|
||||
},
|
||||
getProjects: () => [...projectHostSetupProjectionFromRepos(repos).projects],
|
||||
getProjectHostSetups: () => [...projectHostSetupProjectionFromRepos(repos).setups]
|
||||
}
|
||||
return new OrcaRuntimeService(runtimeStore)
|
||||
}
|
||||
|
||||
async function withGitFolder(
|
||||
remotes: Record<string, string>,
|
||||
run: (path: string) => Promise<void>
|
||||
): Promise<void> {
|
||||
const tempRoot = await mkdtemp(join(tmpdir(), 'orca-runtime-folder-remote-'))
|
||||
try {
|
||||
execFileSync('git', ['init'], { cwd: tempRoot, stdio: 'ignore' })
|
||||
for (const [name, url] of Object.entries(remotes)) {
|
||||
execFileSync('git', ['remote', 'add', name, url], { cwd: tempRoot, stdio: 'ignore' })
|
||||
}
|
||||
await run(tempRoot)
|
||||
} finally {
|
||||
await rm(tempRoot, { recursive: true, force: true })
|
||||
}
|
||||
}
|
||||
|
||||
const repoA = { provider: 'github' as const, owner: 'acme', repo: 'repo-a' }
|
||||
|
||||
describe('OrcaRuntimeService project setup of an existing folder (#30663)', () => {
|
||||
it('refuses to relabel a folder whose own GitHub remote names another repository', async () => {
|
||||
const repos: Repo[] = []
|
||||
const runtime = createRuntime(repos)
|
||||
|
||||
await withGitFolder({ origin: 'https://github.com/acme/repo-b.git' }, async (path) => {
|
||||
await expect(
|
||||
runtime.setupProjectExistingFolder({
|
||||
projectId: 'github:acme/repo-a',
|
||||
projectProviderIdentity: repoA,
|
||||
hostId: 'runtime:env-1',
|
||||
path,
|
||||
kind: 'git'
|
||||
})
|
||||
).rejects.toThrow(/points at acme\/repo-b, not acme\/repo-a/)
|
||||
})
|
||||
|
||||
expect(repos).toHaveLength(0)
|
||||
})
|
||||
|
||||
it('judges an already-registered folder by its current remotes, not the stored ones', async () => {
|
||||
const repos: Repo[] = []
|
||||
const runtime = createRuntime(repos)
|
||||
|
||||
await withGitFolder(
|
||||
{
|
||||
origin: 'https://github.com/me/repo-a-fork.git',
|
||||
upstream: 'https://github.com/acme/repo-a.git'
|
||||
},
|
||||
async (path) => {
|
||||
// Registered before the user added the `upstream` remote the refusal recommends.
|
||||
repos.push({
|
||||
id: 'repo-registered',
|
||||
path: realpathSync(path),
|
||||
displayName: 'repo-a-fork',
|
||||
badgeColor: '#000000',
|
||||
addedAt: 1,
|
||||
kind: 'git',
|
||||
executionHostId: 'runtime:env-1',
|
||||
upstream: null,
|
||||
gitRemoteIdentity: {
|
||||
canonicalKey: 'github.com/me/repo-a-fork',
|
||||
remoteName: 'origin',
|
||||
remoteUrl: 'https://github.com/me/repo-a-fork.git'
|
||||
}
|
||||
})
|
||||
const result = await runtime.setupProjectExistingFolder({
|
||||
projectId: 'github:acme/repo-a',
|
||||
projectProviderIdentity: repoA,
|
||||
hostId: 'runtime:env-1',
|
||||
path,
|
||||
kind: 'git'
|
||||
})
|
||||
expect(result.project.id).toBe('github:acme/repo-a')
|
||||
expect(result.repo.id).toBe('repo-registered')
|
||||
}
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
it('completes parent-selected setup while unrelated background metadata remains pending', async () => {
|
||||
await withGitFolder({ origin: 'https://github.com/me/repo-a.git' }, async (path) => {
|
||||
const repos: Repo[] = [
|
||||
{
|
||||
id: 'blocker',
|
||||
path: '/blocked',
|
||||
displayName: 'blocker',
|
||||
badgeColor: 'blue',
|
||||
addedAt: 1,
|
||||
kind: 'git'
|
||||
}
|
||||
]
|
||||
const runtime = createRuntime(repos)
|
||||
const gate = Promise.withResolvers<forkMetadata.RepoUpstreamProbe>()
|
||||
parentProbe
|
||||
.mockImplementationOnce(() => gate.promise)
|
||||
.mockResolvedValue({
|
||||
upstream: { owner: 'acme', repo: 'repo-a' },
|
||||
origin: { owner: 'me', repo: 'repo-a' }
|
||||
})
|
||||
const background = runtime.repositoryForkBackfill.enqueue(repos)
|
||||
try {
|
||||
const result = await runtime.setupProjectExistingFolder({
|
||||
projectId: 'github:acme/repo-a',
|
||||
projectProviderIdentity: repoA,
|
||||
hostId: 'runtime:env-1',
|
||||
path,
|
||||
kind: 'git'
|
||||
})
|
||||
expect(result.project.id).toBe('github:acme/repo-a')
|
||||
expect(repos[0].upstream).toBeUndefined()
|
||||
expect(parentProbe).toHaveBeenCalledTimes(2)
|
||||
} finally {
|
||||
gate.resolve({ upstream: null, origin: null })
|
||||
await background
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
it.each([false, true])(
|
||||
'refuses changed current origin after an unavailable lookup (pre-existing=%s)',
|
||||
async (existing) => {
|
||||
await withGitFolder({ origin: 'https://github.com/me/repo-a.git' }, async (path) => {
|
||||
const repos: Repo[] = []
|
||||
if (existing) {
|
||||
repos.push({
|
||||
id: 'selected',
|
||||
path: realpathSync(path),
|
||||
displayName: 'repo-a',
|
||||
badgeColor: 'blue',
|
||||
addedAt: 1,
|
||||
kind: 'git',
|
||||
executionHostId: 'runtime:env-1',
|
||||
gitRemoteIdentity: {
|
||||
canonicalKey: 'github.com/me/repo-a',
|
||||
remoteName: 'origin',
|
||||
remoteUrl: 'https://github.com/me/repo-a.git'
|
||||
}
|
||||
})
|
||||
}
|
||||
const runtime = createRuntime(repos)
|
||||
const gate = Promise.withResolvers<forkMetadata.RepoUpstreamProbe>()
|
||||
const started = Promise.withResolvers<void>()
|
||||
parentProbe.mockImplementationOnce(() => {
|
||||
started.resolve()
|
||||
return gate.promise
|
||||
})
|
||||
const setup = runtime.setupProjectExistingFolder({
|
||||
projectId: 'github:me/repo-a',
|
||||
projectProviderIdentity: { provider: 'github', owner: 'me', repo: 'repo-a' },
|
||||
hostId: 'runtime:env-1',
|
||||
path,
|
||||
kind: 'git'
|
||||
})
|
||||
const rejection = expect(setup).rejects.toThrow(/points at other\/repo-a, not me\/repo-a/)
|
||||
await started.promise
|
||||
execFileSync('git', ['remote', 'set-url', 'origin', 'https://github.com/other/repo-a.git'], {
|
||||
cwd: path,
|
||||
stdio: 'ignore'
|
||||
})
|
||||
gate.resolve({ upstream: undefined, origin: { owner: 'me', repo: 'repo-a' } })
|
||||
await rejection
|
||||
expect(repos).toHaveLength(existing ? 1 : 0)
|
||||
expect(parentProbe).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
}
|
||||
)
|
||||
|
||||
it('retains matching null authority when a nonfork result settles during setup', async () => {
|
||||
await withGitFolder({ origin: 'https://github.com/me/repo-a.git' }, async (path) => {
|
||||
const repos: Repo[] = []
|
||||
const runtime = createRuntime(repos)
|
||||
const gate = Promise.withResolvers<forkMetadata.RepoUpstreamProbe>()
|
||||
const started = Promise.withResolvers<void>()
|
||||
parentProbe.mockImplementationOnce(() => {
|
||||
started.resolve()
|
||||
return gate.promise
|
||||
})
|
||||
const setup = runtime.setupProjectExistingFolder({
|
||||
projectId: 'github:me/repo-a',
|
||||
projectProviderIdentity: { provider: 'github', owner: 'me', repo: 'repo-a' },
|
||||
hostId: 'runtime:env-1',
|
||||
path,
|
||||
kind: 'git'
|
||||
})
|
||||
await started.promise
|
||||
execFileSync('git', ['remote', 'set-url', 'origin', 'https://github.com/other/repo-a.git'], {
|
||||
cwd: path,
|
||||
stdio: 'ignore'
|
||||
})
|
||||
gate.resolve({ upstream: null, origin: { owner: 'me', repo: 'repo-a' } })
|
||||
const result = await setup
|
||||
expect(result.project.id).toBe('github:me/repo-a')
|
||||
expect(result.repo.upstream).toBeNull()
|
||||
expect(
|
||||
projectHostSetupProjectionFromRepos(JSON.parse(JSON.stringify(repos))).setups[0].projectId
|
||||
).toBe('github:me/repo-a')
|
||||
})
|
||||
})
|
||||
|
||||
it('publishes metadata retained on a pre-existing row after explicit setup fails', async () => {
|
||||
await withGitFolder({ origin: 'https://github.com/me/repo-a.git' }, async (path) => {
|
||||
const repos: Repo[] = [
|
||||
{
|
||||
id: 'selected',
|
||||
path: realpathSync(path),
|
||||
displayName: 'repo-a',
|
||||
badgeColor: 'blue',
|
||||
addedAt: 1,
|
||||
kind: 'git',
|
||||
executionHostId: 'runtime:env-1'
|
||||
}
|
||||
]
|
||||
const runtime = createRuntime(repos)
|
||||
parentProbe.mockResolvedValue({
|
||||
upstream: { owner: 'acme', repo: 'repo-a' },
|
||||
origin: { owner: 'me', repo: 'repo-a' }
|
||||
})
|
||||
const notifications: string[] = []
|
||||
const unsubscribe = runtime.onClientEvent((event) => {
|
||||
if (event.type === 'reposChanged') {
|
||||
notifications.push(event.type)
|
||||
}
|
||||
})
|
||||
try {
|
||||
await expect(
|
||||
runtime.setupProjectExistingFolder({
|
||||
projectId: 'github:elsewhere/repo-a',
|
||||
projectProviderIdentity: { provider: 'github', owner: 'elsewhere', repo: 'repo-a' },
|
||||
hostId: 'runtime:env-1',
|
||||
path,
|
||||
kind: 'git'
|
||||
})
|
||||
).rejects.toThrow(/points at me\/repo-a, not elsewhere\/repo-a/)
|
||||
expect(repos).toHaveLength(1)
|
||||
expect(repos[0].upstream).toEqual({ owner: 'acme', repo: 'repo-a' })
|
||||
expect(notifications).toEqual(['reposChanged'])
|
||||
expect(parentProbe).toHaveBeenCalledTimes(1)
|
||||
} finally {
|
||||
unsubscribe()
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
it.each(['recovered parent', 'unavailable'] as const)(
|
||||
'settles an explicit origin after ordinary alias enrichment: %s',
|
||||
async (evidence) => {
|
||||
await withGitFolder({ origin: 'git@gh-personal:me/repo-a.git' }, async (path) => {
|
||||
const repos: Repo[] = []
|
||||
const runtime = createRuntime(repos)
|
||||
const origin = { owner: 'me', repo: 'repo-a' }
|
||||
const ordinary = Promise.withResolvers<forkMetadata.RepoUpstreamProbe>()
|
||||
const ordinaryStarted = Promise.withResolvers<void>()
|
||||
const ordinaryFinished = Promise.withResolvers<void>()
|
||||
const required = Promise.withResolvers<forkMetadata.RepoUpstreamProbe>()
|
||||
const requiredStarted = Promise.withResolvers<void>()
|
||||
parentProbe
|
||||
.mockImplementationOnce(() => {
|
||||
ordinaryStarted.resolve()
|
||||
return ordinary.promise
|
||||
})
|
||||
.mockImplementationOnce(() => {
|
||||
requiredStarted.resolve()
|
||||
return required.promise
|
||||
})
|
||||
const unsubscribe = runtime.onClientEvent((event) => {
|
||||
if (event.type === 'reposChanged' && repos[0]?.repoIcon?.type === 'image') {
|
||||
ordinaryFinished.resolve()
|
||||
}
|
||||
})
|
||||
try {
|
||||
const added = await runtime.addRepo(path, 'git', 'runtime:env-1')
|
||||
await ordinaryStarted.promise
|
||||
ordinary.resolve({ upstream: undefined, origin })
|
||||
await ordinaryFinished.promise
|
||||
expect(added.id).toBe(repos[0].id)
|
||||
expect(repos[0].gitRemoteIdentity).toEqual({
|
||||
canonicalKey: 'gh-personal/me/repo-a',
|
||||
remoteName: 'origin',
|
||||
remoteUrl: 'git@gh-personal:me/repo-a.git'
|
||||
})
|
||||
expect(repos[0].repoIcon).toEqual({
|
||||
type: 'image',
|
||||
source: 'github',
|
||||
src: 'https://github.com/me.png?size=64',
|
||||
label: 'me/repo-a'
|
||||
})
|
||||
expect(repos[0].upstream).toBeUndefined()
|
||||
|
||||
const setup = runtime.setupProjectExistingFolder({
|
||||
projectId: 'github:me/repo-a',
|
||||
projectProviderIdentity: { provider: 'github', ...origin },
|
||||
hostId: 'runtime:env-1',
|
||||
path,
|
||||
kind: 'git'
|
||||
})
|
||||
await requiredStarted.promise
|
||||
const completion = runtime.repositoryForkBackfill.resolve(repos[0])
|
||||
required.resolve({
|
||||
upstream: evidence === 'recovered parent' ? { owner: 'acme', repo: 'repo-a' } : undefined,
|
||||
origin
|
||||
})
|
||||
const result = await setup
|
||||
await completion
|
||||
expect(result.project.id).toBe('github:me/repo-a')
|
||||
expect(result.repo.upstream).toEqual(evidence === 'recovered parent' ? origin : null)
|
||||
parentProbe.mockResolvedValue({ upstream: { owner: 'acme', repo: 'repo-a' }, origin })
|
||||
await runtime.repositoryForkBackfill.run()
|
||||
expect(repos[0].upstream).toEqual(evidence === 'recovered parent' ? origin : null)
|
||||
expect(
|
||||
projectHostSetupProjectionFromRepos(JSON.parse(JSON.stringify(repos))).setups[0].projectId
|
||||
).toBe('github:me/repo-a')
|
||||
} finally {
|
||||
ordinary.resolve({ upstream: undefined, origin })
|
||||
required.resolve({ upstream: undefined, origin })
|
||||
unsubscribe()
|
||||
}
|
||||
})
|
||||
}
|
||||
)
|
||||
@@ -1,73 +0,0 @@
|
||||
import '../orca-runtime-test-mocks/setup.spec'
|
||||
import 'vitest'
|
||||
import '../browser/commands/browser-commands'
|
||||
import '../browser/installation/runtime-browser-commands-factory'
|
||||
import '../orchestration/terminal-authority/runtime-legacy-worker-terminal-recovery-controller'
|
||||
import '../terminal/launch/native-terminal-availability'
|
||||
import '../construction/runtime-desktop-surface'
|
||||
import '../../../../config/scripts/test-runtime/environment/vitest-host-ports-setup'
|
||||
import 'node:perf_hooks'
|
||||
import 'node:events'
|
||||
import 'node:crypto'
|
||||
import 'node:child_process'
|
||||
import 'node:fs'
|
||||
import 'node:fs/promises'
|
||||
import 'node:os'
|
||||
import 'node:path'
|
||||
import 'electron'
|
||||
import '../../../shared/agent-status/contracts/agent-status-freshness'
|
||||
import '../../../shared/worktree/hosted-review/review-head-tracking-ref'
|
||||
import '../../../shared/agent-status/title/agent-title-status'
|
||||
import '../../../shared/agent-status/title/osc-title-extraction'
|
||||
import '../../git/worktrees/creation/worktree-sparse-add'
|
||||
import '../../git/worktrees/creation/worktree-add'
|
||||
import '../../git/worktrees/removal/worktree-removal-preflight'
|
||||
import '../../git/worktrees/catalog/worktree-listing'
|
||||
import '../../git/worktrees/catalog/worktree-scan-cache'
|
||||
import '../../git/worktrees/removal/worktree-removal'
|
||||
import '../workspaces/removal/worktree-teardown'
|
||||
import '../workspaces/removal/worktree-teardown-deadline'
|
||||
import '../../git/source-control/submodules/submodule-paths'
|
||||
import '../../workspace-hooks/hooks'
|
||||
import '../../../shared/workspace-setup/orca-yaml'
|
||||
import '../../workspace-hooks/worktree-runner-script'
|
||||
import '../../workspace-hooks/effective-hook-config'
|
||||
import '../../git/repositories/repository-name'
|
||||
import '../../git/remotes/repo-remote-queries'
|
||||
import '../../git/repositories/discovery/repo-detection'
|
||||
import '../../git/refs/resolution/repo-base-ref-search'
|
||||
import '../../git/refs/resolution/repo-branch-conflict'
|
||||
import '../orchestration/db/orchestration-db'
|
||||
import '../orchestration/db/contract-constants'
|
||||
import '../orchestration/db/messages/mailbox-routing-page'
|
||||
import '../orchestration/db/dispatch-row-writer'
|
||||
import '../orchestration/db/attempt-outcome-projection'
|
||||
import '../orca-runtime'
|
||||
import '../session-graph/runtime-graph-reload-lifecycle'
|
||||
import '../browser/client-pages/runtime-browser-page-registry'
|
||||
import '../browser-host/leases/browser-host-lease-registry-instance'
|
||||
import '../terminal/output/recent-pty-output-buffer'
|
||||
import '../session-lifecycle/projection/mobile-session-browser-equality'
|
||||
import '../session-lifecycle/projection/mobile-session-browser-group-projection'
|
||||
import '../../daemon/emulation/headless-emulator'
|
||||
|
||||
import '../../../shared/terminal/input/terminal-input'
|
||||
import '../../../shared/agent-launch/startup/agent-prompt-injection'
|
||||
import '../../../shared/clipboard/clipboard-text'
|
||||
import '../../../shared/project/host-setup/project-host-setup-projection'
|
||||
import '../../memory/pty-registry'
|
||||
import '../../providers/pty/process-inspection'
|
||||
import '../../workspaces/catalog/worktree-path-comparison-key'
|
||||
import '../../workspaces/removal/local-worktree-filesystem'
|
||||
import '../../../shared/orca-profiles/constants'
|
||||
import '../../ports/advertised-url-watcher'
|
||||
import '../../../shared/workspace-layout/stable-pane-id'
|
||||
import '../../../shared/agent-launch/startup/setup-agent-sequencing'
|
||||
import '../../../shared/worktree/id'
|
||||
import '../../../shared/agent-launch/catalog/tui-agent-config'
|
||||
import '../../workspaces/removal/watcher-removal-gate'
|
||||
import '../../workspaces/removal/watcher-removal-drain'
|
||||
import '../terminal/view/terminal-view-attribute-store'
|
||||
import '../../git/worktrees/content-paths/worktree-shared-directories'
|
||||
import '../../workspaces/removal/worktree-watcher-removal'
|
||||
import '../orchestration/db/root-dispatch-test-fixture'
|
||||
@@ -1,310 +0,0 @@
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import { bindPaneFirst, registerBoundPty } from './bind-first-pane.test-fixture'
|
||||
import { ORCA_LAYOUT_OWNER_IS_MAIN } from '../../../shared/workspace-layout/layout-owner-switch'
|
||||
import './runtime-test-module-registration.spec'
|
||||
import { MOCK_GIT_WORKTREES, electronMocks } from '../orca-runtime-test-mocks/setup.spec'
|
||||
import { OrcaRuntimeService } from '../orca-runtime'
|
||||
import { AgentBrowserBridge } from '../../browser/agent-browser/agent-browser-bridge'
|
||||
import type { IPtyProvider } from '../../providers/pty/provider-contract'
|
||||
import '../../git/worktrees/removal/worktree-removal-preflight'
|
||||
import { ipcMain } from 'electron'
|
||||
import { listWorktrees } from '../../git/worktrees/catalog/worktree-scan-cache'
|
||||
import { removeWorktree } from '../../git/worktrees/removal/worktree-removal'
|
||||
import {
|
||||
TEST_REPO_ID,
|
||||
TEST_WORKTREE_ID,
|
||||
createRuntime,
|
||||
store,
|
||||
syncSinglePty
|
||||
} from './orca-runtime-test-fixtures.spec'
|
||||
import { createMobileCreateTestNotifier } from './orca-runtime-test-scenario-builders.spec'
|
||||
|
||||
function createBrowserBridge(overrides: Partial<AgentBrowserBridge>): AgentBrowserBridge {
|
||||
return Object.assign(vi.mockObject(AgentBrowserBridge.prototype), overrides)
|
||||
}
|
||||
|
||||
describe('OrcaRuntimeService', () => {
|
||||
describe('browser page targeting', () => {
|
||||
function mockLiveBrowserGuest(): void {
|
||||
electronMocks.webContents.fromId.mockReturnValue({
|
||||
isDestroyed: () => false,
|
||||
isLoading: () => false
|
||||
})
|
||||
}
|
||||
|
||||
it('does not silently drop invalid explicit worktree selectors for page-targeted commands', async () => {
|
||||
vi.mocked(listWorktrees).mockResolvedValue(MOCK_GIT_WORKTREES)
|
||||
mockLiveBrowserGuest()
|
||||
const runtime = createRuntime()
|
||||
const snapshotMock = vi.fn<AgentBrowserBridge['snapshot']>()
|
||||
|
||||
runtime.setAgentBrowserBridge(
|
||||
createBrowserBridge({
|
||||
snapshot: snapshotMock,
|
||||
getRegisteredTabs: vi.fn(() => new Map([['page-1', 1]])),
|
||||
getRegisteredPageWebContentsId: (page: string) => (page === 'page-1' ? 1 : undefined)
|
||||
})
|
||||
)
|
||||
|
||||
await expect(
|
||||
runtime.browserSnapshot({
|
||||
worktree: 'path:/tmp/missing-worktree',
|
||||
page: 'page-1'
|
||||
})
|
||||
).rejects.toThrow('selector_not_found')
|
||||
expect(snapshotMock).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('does not silently drop invalid explicit worktree selectors for non-page browser commands', async () => {
|
||||
vi.mocked(listWorktrees).mockResolvedValue(MOCK_GIT_WORKTREES)
|
||||
const runtime = createRuntime()
|
||||
const tabListMock = vi.fn<AgentBrowserBridge['tabList']>()
|
||||
|
||||
runtime.setAgentBrowserBridge(
|
||||
createBrowserBridge({
|
||||
tabList: tabListMock
|
||||
})
|
||||
)
|
||||
|
||||
await expect(
|
||||
runtime.browserTabList({
|
||||
worktree: 'path:/tmp/missing-worktree'
|
||||
})
|
||||
).rejects.toThrow('selector_not_found')
|
||||
expect(tabListMock).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('rejects closing an unknown page id instead of treating it as success', async () => {
|
||||
vi.mocked(listWorktrees).mockResolvedValue(MOCK_GIT_WORKTREES)
|
||||
mockLiveBrowserGuest()
|
||||
const runtime = createRuntime()
|
||||
|
||||
runtime.setAgentBrowserBridge(
|
||||
createBrowserBridge({
|
||||
getRegisteredTabs: vi.fn(() => new Map([['page-1', 1]])),
|
||||
getRegisteredPageWebContentsId: (page: string) => (page === 'page-1' ? 1 : undefined)
|
||||
})
|
||||
)
|
||||
|
||||
await expect(
|
||||
runtime.browserTabClose({
|
||||
page: 'missing-page'
|
||||
})
|
||||
).rejects.toThrow('Browser page missing-page was not found')
|
||||
})
|
||||
|
||||
it('rejects closing a page outside the explicitly scoped worktree', async () => {
|
||||
mockLiveBrowserGuest()
|
||||
vi.mocked(listWorktrees).mockResolvedValue([
|
||||
...MOCK_GIT_WORKTREES,
|
||||
{
|
||||
path: '/tmp/worktree-b',
|
||||
head: 'def',
|
||||
branch: 'feature/bar',
|
||||
isBare: false,
|
||||
isMainWorktree: false
|
||||
}
|
||||
])
|
||||
const runtime = createRuntime()
|
||||
const getRegisteredTabsMock = vi.fn((worktreeId?: string) =>
|
||||
worktreeId === `${TEST_REPO_ID}::/tmp/worktree-b` ? new Map() : new Map([['page-1', 1]])
|
||||
)
|
||||
|
||||
runtime.setAgentBrowserBridge(
|
||||
createBrowserBridge({
|
||||
getRegisteredTabs: getRegisteredTabsMock,
|
||||
getRegisteredPageWebContentsId: (page: string, worktreeId?: string) =>
|
||||
getRegisteredTabsMock(worktreeId).get(page)
|
||||
})
|
||||
)
|
||||
|
||||
await expect(
|
||||
runtime.browserTabClose({
|
||||
page: 'page-1',
|
||||
worktree: 'path:/tmp/worktree-b'
|
||||
})
|
||||
).rejects.toThrow('Browser page page-1 was not found in this worktree')
|
||||
expect(getRegisteredTabsMock).toHaveBeenCalledWith(`${TEST_REPO_ID}::/tmp/worktree-b`)
|
||||
})
|
||||
})
|
||||
|
||||
describe('removeManagedWorktree PTY teardown (design §4.3)', () => {
|
||||
function createProviderStub(
|
||||
listProcesses: () => Promise<{ id: string; cwd: string; title: string }[]>
|
||||
) {
|
||||
return {
|
||||
spawn: vi.fn<IPtyProvider['spawn']>(),
|
||||
attach: vi.fn<IPtyProvider['attach']>(),
|
||||
write: vi.fn<IPtyProvider['write']>(),
|
||||
writeWithSettlement: vi.fn<IPtyProvider['writeWithSettlement']>(),
|
||||
resize: vi.fn<IPtyProvider['resize']>(),
|
||||
shutdown: vi.fn<IPtyProvider['shutdown']>().mockResolvedValue(undefined),
|
||||
sendSignal: vi.fn<IPtyProvider['sendSignal']>(),
|
||||
getCwd: vi.fn<IPtyProvider['getCwd']>(),
|
||||
getInitialCwd: vi.fn<IPtyProvider['getInitialCwd']>(),
|
||||
clearBuffer: vi.fn<IPtyProvider['clearBuffer']>(),
|
||||
resetInputModes: vi.fn<IPtyProvider['resetInputModes']>(),
|
||||
acknowledgeDataEvent: vi.fn<IPtyProvider['acknowledgeDataEvent']>(),
|
||||
hasChildProcesses: vi.fn<IPtyProvider['hasChildProcesses']>(),
|
||||
getForegroundProcess: vi.fn<IPtyProvider['getForegroundProcess']>(),
|
||||
serialize: vi.fn<IPtyProvider['serialize']>(),
|
||||
revive: vi.fn<IPtyProvider['revive']>(),
|
||||
listProcesses: vi.fn(listProcesses),
|
||||
getDefaultShell: vi.fn<IPtyProvider['getDefaultShell']>(),
|
||||
getProfiles: vi.fn<IPtyProvider['getProfiles']>(),
|
||||
onData: vi.fn<IPtyProvider['onData']>().mockReturnValue(() => {}),
|
||||
onReplay: vi.fn<IPtyProvider['onReplay']>().mockReturnValue(() => {}),
|
||||
onExit: vi.fn<IPtyProvider['onExit']>().mockReturnValue(() => {})
|
||||
} satisfies IPtyProvider
|
||||
}
|
||||
|
||||
it('does not start Git removal when physical PTY stop cannot be proven', async () => {
|
||||
// Retain the live PTY in fresh inventory so failed stop cannot be mistaken for proven exit.
|
||||
const localProvider = createProviderStub(async () => [
|
||||
{ id: 'pty-1', cwd: '/tmp', title: 'shell' }
|
||||
])
|
||||
const runtime = new OrcaRuntimeService(store, undefined, {
|
||||
getLocalProvider: () => localProvider
|
||||
})
|
||||
runtime.setPtyController({
|
||||
write: () => true,
|
||||
kill: vi.fn(() => true),
|
||||
stopAndWait: vi.fn(async () => false),
|
||||
getForegroundProcess: async () => null
|
||||
})
|
||||
await syncSinglePty(runtime, 'pty-1')
|
||||
|
||||
await expect(runtime.removeManagedWorktree(TEST_WORKTREE_ID)).rejects.toThrow(
|
||||
'Failed to physically stop every PTY'
|
||||
)
|
||||
|
||||
expect(removeWorktree).not.toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
|
||||
describe('mobile terminal create resilience (#7718)', () => {
|
||||
it('cancels the surface wait without rolling back when the client connection dies', async () => {
|
||||
vi.useFakeTimers()
|
||||
try {
|
||||
const closeTerminal = vi.fn()
|
||||
const runtime = new OrcaRuntimeService(store)
|
||||
runtime.setNotifier(createMobileCreateTestNotifier(closeTerminal))
|
||||
const abort = new AbortController()
|
||||
const webContents = { send: vi.fn() }
|
||||
const send = vi.fn((_channel: string, payload: { requestId: string }) => {
|
||||
ipcMain.emit(
|
||||
'terminal:tabCreateReply',
|
||||
{ sender: webContents },
|
||||
{ requestId: payload.requestId, tabId: 'tab-abort', title: 'Terminal' }
|
||||
)
|
||||
})
|
||||
webContents.send = send
|
||||
runtime.attachWindow(1)
|
||||
await runtime.syncWindowGraph(1, { tabs: [], leaves: [] })
|
||||
electronMocks.BrowserWindow.fromId.mockReturnValue({
|
||||
isDestroyed: () => false,
|
||||
webContents
|
||||
})
|
||||
|
||||
const create = runtime.createMobileSessionTerminal(`id:${TEST_WORKTREE_ID}`, {
|
||||
activate: false,
|
||||
signal: abort.signal
|
||||
})
|
||||
const settled = create.then(
|
||||
() => ({ ok: true as const }),
|
||||
(error: Error) => ({ ok: false as const, error })
|
||||
)
|
||||
await vi.waitFor(() => expect(send).toHaveBeenCalledTimes(1))
|
||||
|
||||
// Disconnect must settle promptly without closing the real terminal.
|
||||
abort.abort()
|
||||
await vi.advanceTimersByTimeAsync(0)
|
||||
const outcome = await settled
|
||||
|
||||
expect(outcome.ok).toBe(false)
|
||||
if (outcome.ok === false) {
|
||||
expect(outcome.error.message).toBe('client_disconnected')
|
||||
}
|
||||
expect(closeTerminal).not.toHaveBeenCalled()
|
||||
} finally {
|
||||
vi.useRealTimers()
|
||||
}
|
||||
})
|
||||
|
||||
it('keeps a mobile-created terminal alive when its live shell has no registered pane key', async () => {
|
||||
vi.useFakeTimers()
|
||||
try {
|
||||
const closeTerminal = vi.fn()
|
||||
const runtime = new OrcaRuntimeService(store)
|
||||
runtime.setNotifier(createMobileCreateTestNotifier(closeTerminal))
|
||||
const webContents = { send: vi.fn() }
|
||||
const send = vi.fn((_channel: string, payload: { requestId: string }) => {
|
||||
ipcMain.emit(
|
||||
'terminal:tabCreateReply',
|
||||
{ sender: webContents },
|
||||
{ requestId: payload.requestId, tabId: 'tab-stall', title: 'Terminal' }
|
||||
)
|
||||
})
|
||||
webContents.send = send
|
||||
runtime.attachWindow(1)
|
||||
await runtime.syncWindowGraph(1, { tabs: [], leaves: [] })
|
||||
electronMocks.BrowserWindow.fromId.mockReturnValue({
|
||||
isDestroyed: () => false,
|
||||
webContents
|
||||
})
|
||||
|
||||
const create = runtime.createMobileSessionTerminal(`id:${TEST_WORKTREE_ID}`, {
|
||||
activate: false
|
||||
})
|
||||
const settled = create.then(
|
||||
() => ({ ok: true as const }),
|
||||
(error: Error) => ({ ok: false as const, error })
|
||||
)
|
||||
await vi.waitFor(() => expect(send).toHaveBeenCalledTimes(1))
|
||||
|
||||
// Main-owned layouts require the spawn's binding; a renderer leaf cannot vouch for a live PTY.
|
||||
if (ORCA_LAYOUT_OWNER_IS_MAIN) {
|
||||
registerBoundPty(runtime, 'pty-stall', TEST_WORKTREE_ID, null, {
|
||||
tabId: 'tab-stall',
|
||||
leafId: '88888888-8888-4888-8888-888888888888'
|
||||
})
|
||||
await vi.advanceTimersByTimeAsync(50)
|
||||
expect(await settled).toEqual({ ok: true })
|
||||
expect(closeTerminal).not.toHaveBeenCalled()
|
||||
return
|
||||
}
|
||||
// A live shell exists, but stalled renderer publication never registered its pane key.
|
||||
bindPaneFirst(runtime, {
|
||||
worktreeId: TEST_WORKTREE_ID,
|
||||
tabId: 'tab-stall',
|
||||
leafId: 'pane:1',
|
||||
ptyId: 'pty-stall'
|
||||
})
|
||||
await runtime.syncWindowGraph(1, {
|
||||
tabs: [],
|
||||
leaves: [
|
||||
{
|
||||
tabId: 'tab-stall',
|
||||
worktreeId: TEST_WORKTREE_ID,
|
||||
leafId: 'pane:1',
|
||||
paneRuntimeId: 1,
|
||||
ptyId: 'pty-stall',
|
||||
paneTitle: null
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
await vi.advanceTimersByTimeAsync(11_000)
|
||||
const outcome = await settled
|
||||
|
||||
expect(outcome.ok).toBe(false)
|
||||
if (outcome.ok === false) {
|
||||
expect(outcome.error.message).toContain('Timed out')
|
||||
}
|
||||
expect(closeTerminal).not.toHaveBeenCalled()
|
||||
} finally {
|
||||
vi.useRealTimers()
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -1,172 +0,0 @@
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import './runtime-test-module-registration.spec'
|
||||
import { OrcaRuntimeService } from '../orca-runtime'
|
||||
import { TEST_WORKTREE_ID, TEST_WORKTREE_PATH, store } from './orca-runtime-test-fixtures.spec'
|
||||
|
||||
describe('OrcaRuntimeService', () => {
|
||||
it('replays fast setup completion emitted before its observer is registered', async () => {
|
||||
const runtime = new OrcaRuntimeService(store)
|
||||
runtime.setPtyController({
|
||||
spawn: vi.fn().mockResolvedValue({ id: 'pty-fast-setup' }),
|
||||
write: () => true,
|
||||
kill: () => true,
|
||||
getForegroundProcess: async () => null
|
||||
})
|
||||
runtime.attachWindow(1)
|
||||
await runtime.syncWindowGraph(1, { tabs: [], leaves: [] })
|
||||
const { handle } = await runtime.createTerminal(`path:${TEST_WORKTREE_PATH}`)
|
||||
;(
|
||||
runtime as unknown as { setupCompletionTokenByPtyId: Map<string, string> }
|
||||
).setupCompletionTokenByPtyId.set('pty-fast-setup', 'token-fast')
|
||||
runtime.onPtyData(
|
||||
'pty-fast-setup',
|
||||
'__ORCA_SETUP_COMPLETE__:wrong:9\r\n__ORCA_SETUP_COMPLETE__:token-fast:0\r\n$',
|
||||
100
|
||||
)
|
||||
|
||||
await expect(runtime.waitForSetupTerminalCompletion(handle)).resolves.toEqual({ exitCode: 0 })
|
||||
})
|
||||
|
||||
it('drops retained PTY transcript memory when a background terminal exits', async () => {
|
||||
const runtime = new OrcaRuntimeService(store)
|
||||
runtime.setPtyController({
|
||||
spawn: vi.fn().mockResolvedValue({ id: 'pty-bg' }),
|
||||
write: () => true,
|
||||
kill: () => true,
|
||||
getForegroundProcess: async () => null
|
||||
})
|
||||
runtime.attachWindow(1)
|
||||
await runtime.syncWindowGraph(1, { tabs: [], leaves: [] })
|
||||
const { handle } = await runtime.createTerminal(`path:${TEST_WORKTREE_PATH}`)
|
||||
|
||||
runtime.onPtyData(
|
||||
'pty-bg',
|
||||
`${Array.from({ length: 20 }, (_, i) => `line-${i}`).join('\n')}\nwrote /tmp/exited-result.json\n`,
|
||||
100
|
||||
)
|
||||
await expect(runtime.readTerminal(handle)).resolves.toMatchObject({
|
||||
status: 'running',
|
||||
tail: expect.arrayContaining(['line-0'])
|
||||
})
|
||||
|
||||
runtime.onPtyExit('pty-bg', 0)
|
||||
|
||||
const pty = (
|
||||
runtime as unknown as {
|
||||
ptysById: Map<
|
||||
string,
|
||||
{
|
||||
tailBuffer: string[]
|
||||
tailPartialLine: string
|
||||
tailLinesTotal: number
|
||||
tailTruncated: boolean
|
||||
}
|
||||
>
|
||||
}
|
||||
).ptysById.get('pty-bg')
|
||||
expect(pty).toMatchObject({
|
||||
tailBuffer: [],
|
||||
tailPartialLine: '',
|
||||
tailLinesTotal: 0,
|
||||
tailTruncated: false
|
||||
})
|
||||
await expect(runtime.readTerminal(handle)).resolves.toMatchObject({
|
||||
status: 'exited',
|
||||
tail: []
|
||||
})
|
||||
})
|
||||
|
||||
it('bounds disconnected background PTY records and their synthetic handles', async () => {
|
||||
let nextPtyIndex = 0
|
||||
const runtime = new OrcaRuntimeService(store)
|
||||
runtime.setPtyController({
|
||||
spawn: vi.fn().mockImplementation(async () => ({ id: `pty-bg-${nextPtyIndex++}` })),
|
||||
write: () => true,
|
||||
kill: () => true,
|
||||
getForegroundProcess: async () => null
|
||||
})
|
||||
runtime.attachWindow(1)
|
||||
await runtime.syncWindowGraph(1, { tabs: [], leaves: [] })
|
||||
|
||||
const handles: string[] = []
|
||||
for (let index = 0; index < 140; index += 1) {
|
||||
const { handle } = await runtime.createTerminal(`path:${TEST_WORKTREE_PATH}`)
|
||||
handles.push(handle)
|
||||
runtime.onPtyData(`pty-bg-${index}`, `wrote /tmp/result-${index}.json\n`, 100 + index)
|
||||
runtime.onPtyExit(`pty-bg-${index}`, 0)
|
||||
}
|
||||
|
||||
const internals = runtime as unknown as {
|
||||
ptysById: Map<string, unknown>
|
||||
handles: Map<string, unknown>
|
||||
handleByPtyId: Map<string, string>
|
||||
}
|
||||
expect(internals.ptysById.size).toBeLessThanOrEqual(128)
|
||||
expect(internals.ptysById.has('pty-bg-0')).toBe(false)
|
||||
expect(internals.ptysById.has('pty-bg-139')).toBe(true)
|
||||
expect(internals.handleByPtyId.has('pty-bg-0')).toBe(false)
|
||||
expect(internals.handles.has(handles[0]!)).toBe(false)
|
||||
|
||||
await expect(runtime.readTerminal(handles[0]!)).rejects.toThrow('terminal_handle_stale')
|
||||
await expect(runtime.readTerminal(handles.at(-1)!)).resolves.toMatchObject({
|
||||
status: 'exited'
|
||||
})
|
||||
})
|
||||
|
||||
it('does not treat a Codex launch title as tui-idle readiness', async () => {
|
||||
vi.useFakeTimers()
|
||||
try {
|
||||
const runtime = new OrcaRuntimeService(store)
|
||||
const serializeProviderBuffer = vi.fn().mockResolvedValue({
|
||||
data: 'OpenAI Codex\r\nmodel: gpt-5.5\r\ndirectory: /repo\r\n',
|
||||
cols: 80,
|
||||
rows: 24,
|
||||
seq: 1
|
||||
})
|
||||
runtime.setPtyController({
|
||||
spawn: vi.fn().mockResolvedValue({ id: 'pty-bg' }),
|
||||
write: () => true,
|
||||
kill: () => true,
|
||||
getForegroundProcess: async () => null,
|
||||
serializeProviderBuffer
|
||||
})
|
||||
const { handle } = await runtime.createTerminal(`path:${TEST_WORKTREE_PATH}`)
|
||||
|
||||
runtime.attachWindow(1)
|
||||
await runtime.syncWindowGraph(1, {
|
||||
tabs: [
|
||||
{
|
||||
tabId: 'tab-bg',
|
||||
worktreeId: TEST_WORKTREE_ID,
|
||||
title: 'Codex YOLO',
|
||||
activeLeafId: 'pane-bg',
|
||||
layout: null
|
||||
}
|
||||
],
|
||||
leaves: [
|
||||
{
|
||||
tabId: 'tab-bg',
|
||||
worktreeId: TEST_WORKTREE_ID,
|
||||
leafId: 'pane-bg',
|
||||
paneRuntimeId: 1,
|
||||
ptyId: 'pty-bg',
|
||||
paneTitle: null
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
const waitPromise = runtime.waitForTerminal(handle, {
|
||||
condition: 'tui-idle',
|
||||
timeoutMs: 1_000
|
||||
})
|
||||
const timeoutAssertion = expect(waitPromise).rejects.toThrow('timeout')
|
||||
|
||||
await vi.advanceTimersByTimeAsync(2_000)
|
||||
|
||||
await timeoutAssertion
|
||||
expect(serializeProviderBuffer).not.toHaveBeenCalled()
|
||||
} finally {
|
||||
vi.useRealTimers()
|
||||
}
|
||||
})
|
||||
})
|
||||
-234
@@ -1,234 +0,0 @@
|
||||
import type { AdoptStablePaneArgs, AdoptStablePaneResult } from '../../ipc/pty/ipc/spawn-types'
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import './bind-first-pane.test-fixture'
|
||||
import './runtime-test-module-registration.spec'
|
||||
import { OrcaRuntimeService } from '../orca-runtime'
|
||||
import { HEADLESS_LEAF_ID, TEST_WORKTREE_ID, store } from './orca-runtime-test-fixtures.spec'
|
||||
|
||||
describe('OrcaRuntimeService', () => {
|
||||
it.each([
|
||||
{
|
||||
behavior: 'fills a missing renderer session',
|
||||
hookAgentType: 'codex',
|
||||
hookOffset: 0,
|
||||
rendererSessionId: null,
|
||||
expectedSessionId: 'hook-session'
|
||||
},
|
||||
{
|
||||
behavior: 'replaces a stale renderer session at the same event timestamp',
|
||||
hookAgentType: 'codex',
|
||||
hookOffset: 0,
|
||||
rendererSessionId: 'stale-renderer-session',
|
||||
expectedSessionId: 'hook-session'
|
||||
},
|
||||
{
|
||||
behavior: 'preserves a renderer session newer than the hook row',
|
||||
hookAgentType: 'codex',
|
||||
hookOffset: -1,
|
||||
rendererSessionId: 'newer-renderer-session',
|
||||
expectedSessionId: 'newer-renderer-session'
|
||||
},
|
||||
{
|
||||
behavior: 'rejects a hook session owned by another agent',
|
||||
hookAgentType: 'claude',
|
||||
hookOffset: 1,
|
||||
rendererSessionId: null,
|
||||
expectedSessionId: null
|
||||
}
|
||||
] as const)(
|
||||
'$behavior',
|
||||
async ({ hookAgentType, hookOffset, rendererSessionId, expectedSessionId }) => {
|
||||
const leafId = '11111111-1111-4111-8111-111111111111'
|
||||
const paneKey = `codex-tab:${leafId}`
|
||||
const providerSession = {
|
||||
key: 'session_id' as const,
|
||||
id: 'hook-session'
|
||||
}
|
||||
const now = Date.now()
|
||||
const runtime = new OrcaRuntimeService(store, undefined, {
|
||||
getAgentStatusSnapshot: () => [
|
||||
{
|
||||
paneKey,
|
||||
state: 'done',
|
||||
prompt: '',
|
||||
agentType: hookAgentType,
|
||||
connectionId: null,
|
||||
receivedAt: now + hookOffset,
|
||||
stateStartedAt: now + hookOffset,
|
||||
tabId: 'codex-tab',
|
||||
worktreeId: TEST_WORKTREE_ID,
|
||||
providerSession
|
||||
}
|
||||
]
|
||||
})
|
||||
runtime.attachWindow(1)
|
||||
await runtime.syncWindowGraph(1, {
|
||||
tabs: [],
|
||||
leaves: [],
|
||||
mobileSessionTabs: [
|
||||
{
|
||||
worktree: TEST_WORKTREE_ID,
|
||||
publicationEpoch: 'epoch-1',
|
||||
snapshotVersion: 1,
|
||||
activeGroupId: null,
|
||||
activeTabId: `codex-tab::${leafId}`,
|
||||
activeTabType: 'terminal',
|
||||
tabs: [
|
||||
{
|
||||
type: 'terminal',
|
||||
id: `codex-tab::${leafId}`,
|
||||
parentTabId: 'codex-tab',
|
||||
leafId,
|
||||
title: 'Codex',
|
||||
launchAgent: 'codex',
|
||||
agentStatus: {
|
||||
state: 'working',
|
||||
prompt: 'Reply with MOBILE QA OK and nothing else.',
|
||||
updatedAt: now,
|
||||
stateStartedAt: now,
|
||||
agentType: 'codex',
|
||||
paneKey,
|
||||
stateHistory: [],
|
||||
...(rendererSessionId
|
||||
? {
|
||||
providerSession: {
|
||||
key: 'session_id' as const,
|
||||
id: rendererSessionId
|
||||
}
|
||||
}
|
||||
: {})
|
||||
},
|
||||
isActive: true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
const result = await runtime.listMobileSessionTabs(`id:${TEST_WORKTREE_ID}`)
|
||||
|
||||
expect(result.tabs[0]).toEqual(
|
||||
expect.objectContaining({
|
||||
type: 'terminal',
|
||||
agentStatus: expect.objectContaining({
|
||||
state: 'working',
|
||||
prompt: 'Reply with MOBILE QA OK and nothing else.',
|
||||
agentType: 'codex'
|
||||
})
|
||||
})
|
||||
)
|
||||
if (expectedSessionId) {
|
||||
expect(result.tabs[0]).toHaveProperty('agentStatus.providerSession', {
|
||||
key: 'session_id',
|
||||
id: expectedSessionId
|
||||
})
|
||||
} else {
|
||||
expect(result.tabs[0]).not.toHaveProperty('agentStatus.providerSession')
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
it('preserves host metadata when terminal.create adopts a stable pane owner', async () => {
|
||||
const adoptStablePane = vi.fn(
|
||||
async (args: AdoptStablePaneArgs): Promise<AdoptStablePaneResult | null> => {
|
||||
await args.spawnFresh?.({ mustExist: false })
|
||||
return null
|
||||
}
|
||||
)
|
||||
const spawn = vi.fn(async (opts: { adoptedStablePane?: { owner: { handle?: string } } }) =>
|
||||
opts.adoptedStablePane
|
||||
? {
|
||||
id: 'pty-stable-owner',
|
||||
isReattach: true,
|
||||
stablePaneOwner: {
|
||||
handle: opts.adoptedStablePane.owner.handle!,
|
||||
tabId: 'stable-owner-tab',
|
||||
leafId: HEADLESS_LEAF_ID
|
||||
}
|
||||
}
|
||||
: { id: 'pty-stable-owner' }
|
||||
)
|
||||
const runtimeStore = {
|
||||
...store,
|
||||
getSettings: () => ({
|
||||
...store.getSettings(),
|
||||
claudeAgentTeamsMode: 'in-process' as const
|
||||
})
|
||||
}
|
||||
const runtime = new OrcaRuntimeService(runtimeStore)
|
||||
runtime.setPtyController({
|
||||
adoptStablePane,
|
||||
spawn,
|
||||
write: () => true,
|
||||
kill: () => true,
|
||||
getForegroundProcess: async () => null
|
||||
})
|
||||
const first = await runtime.createTerminal(`id:${TEST_WORKTREE_ID}`, {
|
||||
tabId: 'stable-owner-tab',
|
||||
leafId: HEADLESS_LEAF_ID,
|
||||
title: 'Original owner',
|
||||
launchAgent: 'claude'
|
||||
})
|
||||
adoptStablePane.mockResolvedValueOnce({
|
||||
materialized: true,
|
||||
result: { id: 'pty-stable-owner', isReattach: true },
|
||||
owner: {
|
||||
handle: first.handle,
|
||||
tabId: 'stable-owner-tab',
|
||||
leafId: HEADLESS_LEAF_ID,
|
||||
ptyId: 'pty-stable-owner'
|
||||
}
|
||||
})
|
||||
|
||||
const adopted = await runtime.createTerminal(`id:${TEST_WORKTREE_ID}`, {
|
||||
tabId: 'stable-owner-tab',
|
||||
leafId: HEADLESS_LEAF_ID,
|
||||
title: 'Replacement intent',
|
||||
command: "claude 'replacement'",
|
||||
launchAgent: 'claude'
|
||||
})
|
||||
const listed = await runtime.listMobileSessionTabs(`id:${TEST_WORKTREE_ID}`)
|
||||
|
||||
expect(adopted).toMatchObject({
|
||||
handle: first.handle,
|
||||
ptyId: 'pty-stable-owner',
|
||||
title: 'Original owner',
|
||||
isReattach: true
|
||||
})
|
||||
expect(listed.tabs).toEqual([
|
||||
expect.objectContaining({
|
||||
parentTabId: 'stable-owner-tab',
|
||||
title: 'Original owner',
|
||||
launchAgent: 'claude'
|
||||
})
|
||||
])
|
||||
expect(spawn).toHaveBeenCalledOnce()
|
||||
})
|
||||
|
||||
it('refuses before spawning when the client disconnects during pane adoption', async () => {
|
||||
const abort = new AbortController()
|
||||
const spawn = vi.fn()
|
||||
const runtime = new OrcaRuntimeService(store)
|
||||
runtime.setPtyController({
|
||||
adoptStablePane: vi.fn(async (args: AdoptStablePaneArgs) => {
|
||||
abort.abort()
|
||||
await args.spawnFresh?.({ mustExist: false })
|
||||
return null
|
||||
}),
|
||||
spawn,
|
||||
write: () => true,
|
||||
kill: () => true,
|
||||
getForegroundProcess: async () => null
|
||||
})
|
||||
|
||||
await expect(
|
||||
runtime.createTerminal(`id:${TEST_WORKTREE_ID}`, {
|
||||
tabId: 'disconnected-during-adopt',
|
||||
leafId: HEADLESS_LEAF_ID,
|
||||
signal: abort.signal
|
||||
})
|
||||
).rejects.toThrow('client_disconnected')
|
||||
|
||||
expect(spawn).not.toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
@@ -1,81 +0,0 @@
|
||||
import type { RuntimeMobileSessionTabsResult } from '../../../shared/remote-runtime/session-graph/runtime-session-contracts'
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import { committingSpawn } from './bind-first-pane.test-fixture'
|
||||
import './runtime-test-module-registration.spec'
|
||||
import '../../../shared/agent-status/contracts/agent-status-freshness'
|
||||
import { OrcaRuntimeService } from '../orca-runtime'
|
||||
import '../../../shared/workspace-layout/stable-pane-id'
|
||||
import '../orca-runtime-test-mocks/setup.spec'
|
||||
import { waitForMobileSessionTabsEvents } from './mobile-session-tab-event-wait'
|
||||
|
||||
import {
|
||||
HEADLESS_LEAF_ID,
|
||||
TEST_WORKTREE_ID,
|
||||
deferred,
|
||||
store
|
||||
} from './orca-runtime-test-fixtures.spec'
|
||||
|
||||
describe('OrcaRuntimeService', () => {
|
||||
it('coalesces same-status title frames behind one post-title foreground probe', async () => {
|
||||
const staleForegroundProcess = deferred<string | null>()
|
||||
const freshForegroundProcess = deferred<string | null>()
|
||||
const spawn = vi.fn().mockResolvedValue({ id: 'pty-typed-omp' })
|
||||
const getForegroundProcess = vi
|
||||
.fn()
|
||||
.mockReturnValueOnce(staleForegroundProcess.promise)
|
||||
.mockReturnValueOnce(freshForegroundProcess.promise)
|
||||
const runtime = new OrcaRuntimeService(store)
|
||||
runtime.setPtyController({
|
||||
spawn: committingSpawn(runtime, spawn),
|
||||
write: () => true,
|
||||
kill: () => true,
|
||||
getForegroundProcess
|
||||
})
|
||||
const terminal = await runtime.createTerminal(`id:${TEST_WORKTREE_ID}`, {
|
||||
tabId: 'typed-omp-tab',
|
||||
leafId: HEADLESS_LEAF_ID,
|
||||
title: 'Terminal'
|
||||
})
|
||||
const events: RuntimeMobileSessionTabsResult[] = []
|
||||
const unsubscribe = runtime.onMobileSessionTabsChanged((snapshot) => events.push(snapshot))
|
||||
|
||||
runtime.onPtyData('pty-typed-omp', '\x1b]0;Pi ready\x07', 123)
|
||||
await new Promise<void>((resolve) => setImmediate(resolve))
|
||||
runtime.onPtyData('pty-typed-omp', '\x1b]0;Pi idle\x07', 124)
|
||||
runtime.onPtyData('pty-typed-omp', '\x1b]0;Pi done\x07', 125)
|
||||
await new Promise<void>((resolve) => setImmediate(resolve))
|
||||
|
||||
expect(getForegroundProcess).toHaveBeenCalledTimes(1)
|
||||
expect(events).toHaveLength(0)
|
||||
|
||||
staleForegroundProcess.resolve(null)
|
||||
await new Promise<void>((resolve) => setImmediate(resolve))
|
||||
|
||||
expect(getForegroundProcess).toHaveBeenCalledTimes(2)
|
||||
expect(events).toHaveLength(0)
|
||||
|
||||
freshForegroundProcess.resolve('omp')
|
||||
await new Promise<void>((resolve) => setImmediate(resolve))
|
||||
await waitForMobileSessionTabsEvents(events, 1)
|
||||
|
||||
expect(getForegroundProcess).toHaveBeenCalledTimes(2)
|
||||
expect(events).toEqual([
|
||||
expect.objectContaining({
|
||||
tabs: [
|
||||
expect.objectContaining({
|
||||
type: 'terminal',
|
||||
title: 'OMP ready',
|
||||
agentStatus: expect.objectContaining({
|
||||
state: 'done',
|
||||
agentType: 'omp',
|
||||
terminalHandle: terminal.handle,
|
||||
terminalTitle: 'OMP ready'
|
||||
})
|
||||
})
|
||||
]
|
||||
})
|
||||
])
|
||||
|
||||
unsubscribe()
|
||||
})
|
||||
})
|
||||
@@ -1,149 +0,0 @@
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import './runtime-test-module-registration.spec'
|
||||
import { FOLDER_WORKSPACE_INSTANCE_SEPARATOR } from '../../../shared/worktree/id'
|
||||
import { MOCK_GIT_WORKTREES } from '../orca-runtime-test-mocks/setup.spec'
|
||||
import { OrcaRuntimeService } from '../orca-runtime'
|
||||
import { listWorktrees } from '../../git/worktrees/catalog/worktree-scan-cache'
|
||||
import {
|
||||
TEST_FOLDER_WORKSPACE_PATH,
|
||||
TEST_REPO_ID,
|
||||
TEST_WORKTREE_ID,
|
||||
TEST_WORKTREE_PATH,
|
||||
createRuntime,
|
||||
makeWorktreeMeta,
|
||||
store
|
||||
} from './orca-runtime-test-fixtures.spec'
|
||||
|
||||
describe('OrcaRuntimeService', () => {
|
||||
it('keeps targeted terminal lists from adopting controller PTYs for other worktrees', async () => {
|
||||
vi.mocked(listWorktrees).mockResolvedValue([
|
||||
...MOCK_GIT_WORKTREES,
|
||||
{
|
||||
path: '/tmp/worktree-b',
|
||||
head: 'def',
|
||||
branch: 'feature/bar',
|
||||
isBare: false,
|
||||
isMainWorktree: false
|
||||
},
|
||||
{
|
||||
path: '/tmp/worktree-a/nested',
|
||||
head: 'ghi',
|
||||
branch: 'feature/nested',
|
||||
isBare: false,
|
||||
isMainWorktree: false
|
||||
}
|
||||
])
|
||||
const runtime = createRuntime()
|
||||
runtime.setPtyController({
|
||||
write: () => true,
|
||||
kill: () => true,
|
||||
getForegroundProcess: async () => null,
|
||||
listProcesses: async () => [
|
||||
{ id: 'target-controller-pty', cwd: '/tmp/worktree-a/src', title: 'target' },
|
||||
{ id: 'other-controller-pty', cwd: '/tmp/worktree-b/src', title: 'other' },
|
||||
{
|
||||
id: 'repo-1::/tmp/worktree-b@@other-controller-pty',
|
||||
cwd: '/tmp/worktree-a/src',
|
||||
title: 'prefixed other'
|
||||
},
|
||||
{ id: 'nested-controller-pty', cwd: '/tmp/worktree-a/nested/src', title: 'nested' }
|
||||
]
|
||||
})
|
||||
runtime.attachWindow(1)
|
||||
runtime.markGraphReady(1)
|
||||
|
||||
const terminals = await runtime.listTerminals(`path:${TEST_WORKTREE_PATH}`)
|
||||
|
||||
expect(terminals.terminals).toHaveLength(1)
|
||||
expect(terminals.terminals[0]).toMatchObject({
|
||||
worktreeId: TEST_WORKTREE_ID,
|
||||
worktreePath: TEST_WORKTREE_PATH
|
||||
})
|
||||
const internals = runtime as unknown as { ptysById: Map<string, unknown> }
|
||||
expect(internals.ptysById.has('target-controller-pty')).toBe(true)
|
||||
expect(internals.ptysById.has('other-controller-pty')).toBe(false)
|
||||
expect(internals.ptysById.has('repo-1::/tmp/worktree-b@@other-controller-pty')).toBe(false)
|
||||
expect(internals.ptysById.has('nested-controller-pty')).toBe(false)
|
||||
})
|
||||
|
||||
it('keeps explicit-id cold-cache terminal lists from adopting nested worktree PTYs', async () => {
|
||||
const nestedWorktreeId = `${TEST_REPO_ID}::${TEST_WORKTREE_PATH}/nested`
|
||||
vi.mocked(listWorktrees).mockClear()
|
||||
vi.mocked(listWorktrees).mockRejectedValue(
|
||||
new Error('explicit-id fallback should not rescan worktrees')
|
||||
)
|
||||
const runtime = new OrcaRuntimeService({
|
||||
...store,
|
||||
getAllWorktreeMeta: () => ({
|
||||
[TEST_WORKTREE_ID]: store.getAllWorktreeMeta()[TEST_WORKTREE_ID],
|
||||
[nestedWorktreeId]: makeWorktreeMeta()
|
||||
}),
|
||||
getWorktreeMeta: (worktreeId: string) =>
|
||||
({
|
||||
[TEST_WORKTREE_ID]: store.getAllWorktreeMeta()[TEST_WORKTREE_ID],
|
||||
[nestedWorktreeId]: makeWorktreeMeta()
|
||||
})[worktreeId]
|
||||
})
|
||||
runtime.setPtyController({
|
||||
write: () => true,
|
||||
kill: () => true,
|
||||
getForegroundProcess: async () => null,
|
||||
listProcesses: async () => [
|
||||
{ id: 'cwd-only-pty', cwd: `${TEST_WORKTREE_PATH}/src`, title: 'cwd shell' },
|
||||
{ id: 'nested-controller-pty', cwd: `${TEST_WORKTREE_PATH}/nested/src`, title: 'nested' }
|
||||
]
|
||||
})
|
||||
|
||||
const terminals = await runtime.listTerminals(`id:${TEST_WORKTREE_ID}`)
|
||||
|
||||
expect(listWorktrees).not.toHaveBeenCalled()
|
||||
expect(terminals.terminals.map((terminal) => terminal.worktreeId)).toEqual([TEST_WORKTREE_ID])
|
||||
const internals = runtime as unknown as { ptysById: Map<string, unknown> }
|
||||
expect(internals.ptysById.has('cwd-only-pty')).toBe(true)
|
||||
expect(internals.ptysById.has('nested-controller-pty')).toBe(false)
|
||||
})
|
||||
|
||||
it('keeps same-path folder workspace instance PTYs scoped to their exact ids', async () => {
|
||||
const firstWorktreeId = `${TEST_REPO_ID}::${TEST_FOLDER_WORKSPACE_PATH}${FOLDER_WORKSPACE_INSTANCE_SEPARATOR}11111111-1111-4111-8111-111111111111`
|
||||
const secondWorktreeId = `${TEST_REPO_ID}::${TEST_FOLDER_WORKSPACE_PATH}${FOLDER_WORKSPACE_INSTANCE_SEPARATOR}22222222-2222-4222-8222-222222222222`
|
||||
vi.mocked(listWorktrees).mockClear()
|
||||
vi.mocked(listWorktrees).mockRejectedValue(
|
||||
new Error('folder explicit-id fallback should not rescan worktrees')
|
||||
)
|
||||
const runtime = createRuntime()
|
||||
runtime.setPtyController({
|
||||
write: () => true,
|
||||
kill: () => true,
|
||||
getForegroundProcess: async () => null,
|
||||
listProcesses: async () => [
|
||||
{
|
||||
id: 'first-folder-pty',
|
||||
cwd: TEST_FOLDER_WORKSPACE_PATH,
|
||||
title: 'first',
|
||||
worktreeId: firstWorktreeId
|
||||
},
|
||||
{
|
||||
id: 'second-folder-pty',
|
||||
cwd: TEST_FOLDER_WORKSPACE_PATH,
|
||||
title: 'second',
|
||||
worktreeId: secondWorktreeId
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
const terminals = await runtime.listTerminals(`id:${secondWorktreeId}`)
|
||||
|
||||
expect(listWorktrees).not.toHaveBeenCalled()
|
||||
expect(terminals.terminals).toHaveLength(1)
|
||||
expect(terminals.terminals[0]).toMatchObject({
|
||||
ptyId: 'second-folder-pty',
|
||||
worktreeId: secondWorktreeId,
|
||||
worktreePath: TEST_FOLDER_WORKSPACE_PATH
|
||||
})
|
||||
const internals = runtime as unknown as {
|
||||
ptysById: Map<string, { worktreeId: string }>
|
||||
}
|
||||
expect(internals.ptysById.get('first-folder-pty')).toBeUndefined()
|
||||
expect(internals.ptysById.get('second-folder-pty')?.worktreeId).toBe(secondWorktreeId)
|
||||
})
|
||||
})
|
||||
@@ -1,260 +0,0 @@
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import './runtime-test-module-registration.spec'
|
||||
import { AUTHORITATIVE_TERMINAL_SNAPSHOT_TIMEOUT_MS } from '../terminal/output/provider-snapshot-budget'
|
||||
import { OrcaRuntimeService } from '../orca-runtime'
|
||||
import type { AgentStatusIpcPayload } from '../../../shared/agent-status/contracts/agent-status-ipc-payload'
|
||||
import { syncSinglePty, store } from './orca-runtime-test-fixtures.spec'
|
||||
import { createSideEffectRuntime } from './orca-runtime-test-scenario-builders.spec'
|
||||
|
||||
describe('terminal side-effect fact channel', () => {
|
||||
it('bounds a hung authoritative provider acquisition and reuses its fallback', async () => {
|
||||
vi.useFakeTimers()
|
||||
try {
|
||||
let releaseProvider: (value: null) => void = () => {}
|
||||
const hungProvider = new Promise<null>((resolve) => {
|
||||
releaseProvider = resolve
|
||||
})
|
||||
const serializeProviderBuffer = vi
|
||||
.fn()
|
||||
.mockReturnValueOnce(hungProvider)
|
||||
.mockResolvedValueOnce({
|
||||
data: 'provider recovered\r\n',
|
||||
cols: 100,
|
||||
rows: 30,
|
||||
seq: 200,
|
||||
source: 'headless'
|
||||
})
|
||||
const { runtime } = createSideEffectRuntime()
|
||||
runtime.setPtyController({
|
||||
write: () => true,
|
||||
kill: () => true,
|
||||
getForegroundProcess: async () => null,
|
||||
serializeProviderBuffer,
|
||||
hasRendererSerializer: () => false
|
||||
})
|
||||
await syncSinglePty(runtime)
|
||||
runtime.onPtyData('pty-1', 'available mirror\r\n', 100)
|
||||
|
||||
const firstSnapshot = runtime.serializeAuthoritativeTerminalBuffer('pty-1', {
|
||||
scrollbackRows: 5000
|
||||
})
|
||||
const concurrentSnapshot = runtime.serializeAuthoritativeTerminalBuffer('pty-1', {
|
||||
scrollbackRows: 5000
|
||||
})
|
||||
expect(serializeProviderBuffer).toHaveBeenCalledOnce()
|
||||
await vi.advanceTimersByTimeAsync(AUTHORITATIVE_TERMINAL_SNAPSHOT_TIMEOUT_MS)
|
||||
await expect(firstSnapshot).resolves.toMatchObject({
|
||||
data: expect.stringContaining('available mirror'),
|
||||
source: 'headless'
|
||||
})
|
||||
await expect(concurrentSnapshot).resolves.toMatchObject({
|
||||
data: expect.stringContaining('available mirror'),
|
||||
source: 'headless'
|
||||
})
|
||||
|
||||
await expect(
|
||||
runtime.serializeAuthoritativeTerminalBuffer('pty-1', { scrollbackRows: 5000 })
|
||||
).resolves.toMatchObject({
|
||||
data: expect.stringContaining('available mirror'),
|
||||
source: 'headless'
|
||||
})
|
||||
expect(serializeProviderBuffer).toHaveBeenCalledOnce()
|
||||
|
||||
releaseProvider(null)
|
||||
await vi.advanceTimersByTimeAsync(0)
|
||||
await expect(
|
||||
runtime.serializeAuthoritativeTerminalBuffer('pty-1', { scrollbackRows: 5000 })
|
||||
).resolves.toMatchObject({
|
||||
data: 'provider recovered\r\n',
|
||||
source: 'headless'
|
||||
})
|
||||
expect(serializeProviderBuffer).toHaveBeenCalledTimes(2)
|
||||
} finally {
|
||||
vi.useRealTimers()
|
||||
}
|
||||
})
|
||||
|
||||
it('falls back to provider history when a mounted renderer has not hydrated yet', async () => {
|
||||
const { runtime } = createSideEffectRuntime()
|
||||
const serializeBuffer = vi.fn().mockResolvedValue({
|
||||
data: '',
|
||||
cols: 80,
|
||||
rows: 24
|
||||
})
|
||||
const serializeProviderBuffer = vi.fn().mockResolvedValue({
|
||||
data: '',
|
||||
scrollbackAnsi: 'restored history\r\n',
|
||||
cols: 120,
|
||||
rows: 40,
|
||||
seq: 900,
|
||||
source: 'headless'
|
||||
})
|
||||
runtime.setPtyController({
|
||||
write: () => true,
|
||||
kill: () => true,
|
||||
getForegroundProcess: async () => null,
|
||||
serializeBuffer,
|
||||
serializeProviderBuffer,
|
||||
hasRendererSerializer: () => true
|
||||
})
|
||||
|
||||
const snapshot = await runtime.serializeTerminalBuffer('pty-restored', {
|
||||
scrollbackRows: 5000
|
||||
})
|
||||
|
||||
expect(serializeBuffer).toHaveBeenCalledOnce()
|
||||
expect(serializeProviderBuffer).toHaveBeenCalledWith('pty-restored', {
|
||||
scrollbackRows: 5000
|
||||
})
|
||||
expect(snapshot).toMatchObject({
|
||||
data: '',
|
||||
scrollbackAnsi: 'restored history\r\n',
|
||||
source: 'headless'
|
||||
})
|
||||
})
|
||||
|
||||
it('does not let pre-response bytes hide restored provider history', async () => {
|
||||
const { runtime } = createSideEffectRuntime()
|
||||
const serializeProviderBuffer = vi.fn().mockResolvedValue({
|
||||
data: 'restored history\r\nqueued',
|
||||
cols: 80,
|
||||
rows: 24,
|
||||
seq: 906,
|
||||
source: 'headless'
|
||||
})
|
||||
runtime.setPtyController({
|
||||
write: () => true,
|
||||
kill: () => true,
|
||||
getForegroundProcess: async () => null,
|
||||
serializeProviderBuffer,
|
||||
hasRendererSerializer: () => false
|
||||
})
|
||||
runtime.onPtyData('pty-restored', 'queued', 100)
|
||||
runtime.synchronizePtyOutputSequenceFromProvider(
|
||||
'pty-restored',
|
||||
{ value: 900, generation: 'continued' },
|
||||
0
|
||||
)
|
||||
|
||||
const snapshot = await runtime.serializeTerminalBuffer('pty-restored', {
|
||||
scrollbackRows: 5000
|
||||
})
|
||||
|
||||
expect(snapshot?.data).toContain('restored history')
|
||||
expect(serializeProviderBuffer).toHaveBeenCalledOnce()
|
||||
})
|
||||
|
||||
it('keeps mode transitions that race a provider snapshot response', async () => {
|
||||
const { runtime } = createSideEffectRuntime()
|
||||
let resolveProviderSnapshot:
|
||||
| ((snapshot: {
|
||||
data: string
|
||||
cols: number
|
||||
rows: number
|
||||
seq: number
|
||||
source: 'headless'
|
||||
alternateScreen: boolean
|
||||
}) => void)
|
||||
| undefined
|
||||
const serializeProviderBuffer = vi.fn(
|
||||
() =>
|
||||
new Promise<{
|
||||
data: string
|
||||
cols: number
|
||||
rows: number
|
||||
seq: number
|
||||
source: 'headless'
|
||||
alternateScreen: boolean
|
||||
}>((resolve) => {
|
||||
resolveProviderSnapshot = resolve
|
||||
})
|
||||
)
|
||||
runtime.setPtyController({
|
||||
write: () => true,
|
||||
kill: () => true,
|
||||
getForegroundProcess: async () => null,
|
||||
serializeProviderBuffer,
|
||||
hasRendererSerializer: () => false
|
||||
})
|
||||
runtime.synchronizePtyOutputSequenceFromProvider(
|
||||
'pty-tui-race',
|
||||
{ value: 900, generation: 'continued' },
|
||||
0
|
||||
)
|
||||
|
||||
const snapshotPromise = runtime.serializeTerminalBuffer('pty-tui-race')
|
||||
await vi.waitFor(() => expect(resolveProviderSnapshot).toBeDefined())
|
||||
runtime.onPtyData('pty-tui-race', '\x1b[?1049l', 100)
|
||||
resolveProviderSnapshot?.({
|
||||
data: 'captured alt screen',
|
||||
cols: 80,
|
||||
rows: 24,
|
||||
seq: 900,
|
||||
source: 'headless',
|
||||
alternateScreen: true
|
||||
})
|
||||
await snapshotPromise
|
||||
|
||||
expect(runtime.isTerminalAlternateScreen('pty-tui-race')).toBe(false)
|
||||
})
|
||||
|
||||
it('parses synthetic frames statelessly so ticks cannot corrupt the bell detector', async () => {
|
||||
const { runtime, batches } = createSideEffectRuntime()
|
||||
await syncSinglePty(runtime)
|
||||
|
||||
runtime.onPtyData('pty-1', '\x1b]0;split ti', 100)
|
||||
// An 80ms spinner tick lands between the two halves of the real OSC.
|
||||
runtime.ingestSyntheticTitleFrame('pty-1', '\x1b]0;⠋ Cursor Agent\x07')
|
||||
// This BEL terminates the real partial OSC; it is not a bell.
|
||||
runtime.onPtyData('pty-1', 'tle\x07', 101)
|
||||
// A later standalone BEL must still produce a bell fact.
|
||||
runtime.onPtyData('pty-1', 'ready\x07', 102)
|
||||
|
||||
expect(batches.flatMap((batch) => batch.facts)).toEqual([
|
||||
{ kind: 'title', normalizedTitle: '⠋ Cursor Agent', rawTitle: '⠋ Cursor Agent' },
|
||||
{ kind: 'agent-working' },
|
||||
{ kind: 'title', normalizedTitle: 'split title', rawTitle: 'split title' },
|
||||
{ kind: 'bell' }
|
||||
])
|
||||
})
|
||||
})
|
||||
|
||||
it.each([false, true])(
|
||||
'does not infer completion during stop; stopped=%s settles the pending producer',
|
||||
async (stopped) => {
|
||||
vi.useFakeTimers()
|
||||
let row: AgentStatusIpcPayload | undefined
|
||||
const runtime = new OrcaRuntimeService(store, undefined, {
|
||||
getAgentStatusSnapshotForPane: () => (row ? [row] : []),
|
||||
onTerminalAgentStatus: (event) => {
|
||||
row = {
|
||||
...event.payload,
|
||||
paneKey: event.paneKey,
|
||||
connectionId: null,
|
||||
stateStartedAt: Date.now(),
|
||||
receivedAt: Date.now()
|
||||
}
|
||||
}
|
||||
})
|
||||
try {
|
||||
syncSinglePty(runtime)
|
||||
runtime.onPtyData('pty-1', '# Command Code v0.27.3\r\n', 100)
|
||||
runtime.onPtyData('pty-1', '❯ say hi\r\n✻ Thinking...', 101)
|
||||
expect(row).toMatchObject({ state: 'working', agentType: 'command-code', prompt: 'say hi' })
|
||||
const settle = runtime.intentionalPtyStops.mark('pty-1', 'reversible', null)
|
||||
runtime.onPtyData(
|
||||
'pty-1',
|
||||
'\r\n✻ Thought for 1 second\r\n:: Hi!\r\n❯ Ask your question...',
|
||||
102
|
||||
)
|
||||
await vi.advanceTimersByTimeAsync(2000)
|
||||
expect(row?.state).toBe('working')
|
||||
settle(stopped)
|
||||
await vi.advanceTimersByTimeAsync(2000)
|
||||
expect(row?.state).toBe(stopped ? 'working' : 'done')
|
||||
} finally {
|
||||
await runtime.onPtyExit('pty-1', 0)
|
||||
vi.useRealTimers()
|
||||
}
|
||||
}
|
||||
)
|
||||
@@ -1,87 +0,0 @@
|
||||
import { makeStructuredAgentStatusSubject } from '../../../shared/agent-status/contracts/agent-status-subject'
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import './runtime-test-module-registration.spec'
|
||||
import { OrcaRuntimeService } from '../orca-runtime'
|
||||
import { TEST_WORKTREE_ID, store } from './orca-runtime-test-fixtures.spec'
|
||||
import { AgentHookServer, _internals } from '../../agent-hooks/server/agent-hook-server'
|
||||
|
||||
vi.mock('../../telemetry/client', () => ({ track: vi.fn() }))
|
||||
vi.mock('../../telemetry/cohort-classifier', () => ({
|
||||
getCohortAtEmit: vi.fn(() => ({ nth_repo_added: 2 }))
|
||||
}))
|
||||
|
||||
/** Covers the production status-store read, which a hand-built projection snapshot can bypass. */
|
||||
const SESSION = 'a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d'
|
||||
const SUBJECT = makeStructuredAgentStatusSubject(
|
||||
{
|
||||
executionHostId: 'local',
|
||||
wslDistro: null,
|
||||
workspaceId: TEST_WORKTREE_ID,
|
||||
workspaceKind: 'git-worktree'
|
||||
},
|
||||
SESSION
|
||||
)
|
||||
|
||||
beforeEach(() => {
|
||||
_internals.resetCachesForTests()
|
||||
})
|
||||
|
||||
describe('worktree ps reads structured sessions from the agent-status store', () => {
|
||||
it('lists a host-held structured session with no terminal behind it', async () => {
|
||||
const statusStore = new AgentHookServer()
|
||||
statusStore.ingestStructuredStatus(
|
||||
{
|
||||
sessionId: SESSION,
|
||||
workspaceId: TEST_WORKTREE_ID,
|
||||
agent: 'claude',
|
||||
status: 'working',
|
||||
hostExecutionOwned: true,
|
||||
latestPrompt: 'ship the thing',
|
||||
updatedAt: 1_757_030_400_000
|
||||
},
|
||||
SUBJECT
|
||||
)
|
||||
const getAgentStatusSnapshot = vi.fn(() => statusStore.getStatusSnapshot())
|
||||
|
||||
const { worktrees } = await new OrcaRuntimeService(store, undefined, {
|
||||
getAgentStatusSnapshot
|
||||
}).getWorktreePs()
|
||||
|
||||
const worktree = worktrees.find((entry) => entry.worktreeId === TEST_WORKTREE_ID)
|
||||
expect(worktree).toBeDefined()
|
||||
expect(worktree?.agents).toHaveLength(1)
|
||||
expect(worktree?.agents[0]).toMatchObject({
|
||||
state: 'working',
|
||||
agentType: 'claude',
|
||||
prompt: 'ship the thing',
|
||||
structuredHostOwned: true
|
||||
})
|
||||
expect(worktree?.status).toBe('working')
|
||||
expect(getAgentStatusSnapshot).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it('lists nothing once the host has dropped the session', async () => {
|
||||
const statusStore = new AgentHookServer()
|
||||
statusStore.ingestStructuredStatus(
|
||||
{
|
||||
sessionId: SESSION,
|
||||
workspaceId: TEST_WORKTREE_ID,
|
||||
agent: 'claude',
|
||||
status: 'attention',
|
||||
latestPrompt: 'rm the branch',
|
||||
updatedAt: 1_757_030_400_000
|
||||
},
|
||||
SUBJECT
|
||||
)
|
||||
statusStore.dropStructuredStatus(SUBJECT)
|
||||
|
||||
const { worktrees } = await new OrcaRuntimeService(store, undefined, {
|
||||
getAgentStatusSnapshot: () => statusStore.getStatusSnapshot()
|
||||
}).getWorktreePs()
|
||||
|
||||
const worktree = worktrees.find((entry) => entry.worktreeId === TEST_WORKTREE_ID)
|
||||
expect(worktree).toBeDefined()
|
||||
expect(worktree?.agents).toEqual([])
|
||||
expect(worktree?.status).not.toBe('permission')
|
||||
})
|
||||
})
|
||||
-108
@@ -1,108 +0,0 @@
|
||||
import * as gitExecFile from '../../git/command-runner/git-exec-file'
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import { readFile, mkdir, rm, writeFile } from 'node:fs/promises'
|
||||
|
||||
import './runtime-test-module-registration.spec'
|
||||
import {
|
||||
MOCK_GIT_WORKTREES,
|
||||
closeLocalWatcherForWorktreePathMock,
|
||||
deleteWorktreeHistoryDirMock,
|
||||
restoreLocalWatcherAfterFailedRemovalMock,
|
||||
setPlatform
|
||||
} from '../orca-runtime-test-mocks/setup.spec'
|
||||
import { WATCHER_REMOVAL_DRAIN_BUDGET_MS } from '../../workspaces/removal/watcher-removal-drain'
|
||||
import { beginWatcherInstall } from '../../workspaces/removal/watcher-removal-gate'
|
||||
import { join } from 'node:path'
|
||||
import { listWorktreesStrict } from '../../git/worktrees/catalog/worktree-listing'
|
||||
|
||||
import { removeWorktree } from '../../git/worktrees/removal/worktree-removal'
|
||||
import {
|
||||
TEST_WORKTREE_ID,
|
||||
TEST_WORKTREE_PATH,
|
||||
createRuntime,
|
||||
createStaleRuntimeWorktreeStore
|
||||
} from './orca-runtime-test-fixtures.spec'
|
||||
import { createWorktreeRemovalRuntime } from './orca-runtime-test-scenario-builders.spec'
|
||||
|
||||
describe('OrcaRuntimeService', () => {
|
||||
it('blocks new watcher installs while a pre-removal install drains', async () => {
|
||||
const runtime = createRuntime()
|
||||
const finishInstall = beginWatcherInstall(TEST_WORKTREE_PATH)
|
||||
|
||||
const acquiring = runtime.acquireFileWatcherRemoval(TEST_WORKTREE_PATH)
|
||||
await vi.waitFor(() => expect(closeLocalWatcherForWorktreePathMock).toHaveBeenCalled())
|
||||
expect(() => beginWatcherInstall(TEST_WORKTREE_PATH)).toThrow(
|
||||
'cannot start while the worktree is being removed'
|
||||
)
|
||||
|
||||
finishInstall()
|
||||
const gate = await acquiring
|
||||
await gate.finish(false)
|
||||
expect(restoreLocalWatcherAfterFailedRemovalMock).toHaveBeenCalledWith(TEST_WORKTREE_PATH)
|
||||
|
||||
const finishRetry = beginWatcherInstall(TEST_WORKTREE_PATH)
|
||||
finishRetry()
|
||||
})
|
||||
|
||||
it('proceeds when a wedged install never releases the removal fence', async () => {
|
||||
vi.useFakeTimers()
|
||||
// Model an unabortable native subscribe; removal must abandon its fence slot instead of leaking it.
|
||||
beginWatcherInstall(TEST_WORKTREE_PATH)
|
||||
try {
|
||||
const runtime = createRuntime()
|
||||
|
||||
let acquired = false
|
||||
const acquiring = runtime.acquireFileWatcherRemoval(TEST_WORKTREE_PATH).then((gate) => {
|
||||
acquired = true
|
||||
return gate
|
||||
})
|
||||
await vi.advanceTimersByTimeAsync(WATCHER_REMOVAL_DRAIN_BUDGET_MS - 1)
|
||||
expect(acquired).toBe(false)
|
||||
|
||||
await vi.advanceTimersByTimeAsync(1)
|
||||
const gate = await acquiring
|
||||
expect(acquired).toBe(true)
|
||||
|
||||
await gate.finish(true)
|
||||
const finishRetry = beginWatcherInstall(TEST_WORKTREE_PATH)
|
||||
finishRetry()
|
||||
} finally {
|
||||
vi.useRealTimers()
|
||||
}
|
||||
})
|
||||
|
||||
it('refuses a nonempty markerless Windows folder before teardown', async () => {
|
||||
setPlatform('win32')
|
||||
const { runtimeStore, removeWorktreeMeta } = createStaleRuntimeWorktreeStore(TEST_WORKTREE_ID)
|
||||
const runtime = createWorktreeRemovalRuntime(runtimeStore)
|
||||
deleteWorktreeHistoryDirMock.mockClear()
|
||||
const teardown = vi.spyOn(runtime, 'acquireFileWatcherRemoval')
|
||||
await mkdir(TEST_WORKTREE_PATH, { recursive: true })
|
||||
await writeFile(join(TEST_WORKTREE_PATH, 'scratch.txt'), 'delete me')
|
||||
const gitSpy = vi.spyOn(gitExecFile, 'gitExecFileAsync').mockResolvedValue({
|
||||
stdout: '',
|
||||
stderr: ''
|
||||
})
|
||||
vi.mocked(listWorktreesStrict)
|
||||
.mockResolvedValueOnce(MOCK_GIT_WORKTREES)
|
||||
.mockResolvedValueOnce(MOCK_GIT_WORKTREES)
|
||||
.mockResolvedValue([])
|
||||
|
||||
try {
|
||||
await expect(
|
||||
runtime.removeManagedWorktree(TEST_WORKTREE_ID, { force: true })
|
||||
).rejects.toThrow('is no longer a Git worktree, so its folder was left on disk.')
|
||||
expect(teardown).not.toHaveBeenCalled()
|
||||
expect(removeWorktree).not.toHaveBeenCalled()
|
||||
expect(removeWorktreeMeta).not.toHaveBeenCalled()
|
||||
expect(deleteWorktreeHistoryDirMock).not.toHaveBeenCalled()
|
||||
expect(closeLocalWatcherForWorktreePathMock).not.toHaveBeenCalled()
|
||||
expect(await readFile(join(TEST_WORKTREE_PATH, 'scratch.txt'), 'utf8')).toBe('delete me')
|
||||
expect(runtimeStore.getWorktreeMeta(TEST_WORKTREE_ID)).toBeDefined()
|
||||
} finally {
|
||||
teardown.mockRestore()
|
||||
gitSpy.mockRestore()
|
||||
await rm(TEST_WORKTREE_PATH, { recursive: true, force: true })
|
||||
}
|
||||
})
|
||||
})
|
||||
@@ -1,98 +0,0 @@
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import './runtime-test-module-registration.spec'
|
||||
import { OrcaRuntimeService } from '../orca-runtime'
|
||||
import { listWorktrees } from '../../git/worktrees/catalog/worktree-scan-cache'
|
||||
import { resolveWorktreeScanCacheTtlMs } from '../workspaces/catalog/runtime-worktree-scan-cache'
|
||||
import { store } from './orca-runtime-test-fixtures.spec'
|
||||
import { bumpLocalWorktreeScanGeneration } from '../../workspaces/catalog/local-worktree-scan-generation'
|
||||
|
||||
describe('resolveWorktreeScanCacheTtlMs', () => {
|
||||
const BASE_TTL_MS = 30_000
|
||||
const SCRATCH_TTL_MS = 5 * 60_000
|
||||
|
||||
it('never extends the TTL for SSH repos', () => {
|
||||
// Remote paths that resemble local scratch paths must retain normal freshness.
|
||||
expect(
|
||||
resolveWorktreeScanCacheTtlMs({
|
||||
path: '/home/dev/.codex-tmp/capsule',
|
||||
connectionId: 'ssh-1'
|
||||
})
|
||||
).toBe(BASE_TTL_MS)
|
||||
})
|
||||
|
||||
it('keeps a scratch repo scan cached past the base TTL while normal repos rescan', async () => {
|
||||
// Fake only Date: real admin-fingerprint probes must settle before refresh can invalidate the cache.
|
||||
vi.useFakeTimers({ toFake: ['Date'] })
|
||||
let runtimeProbes: { size: number } = { size: 0 }
|
||||
const settleFingerprintProbes = async (): Promise<void> => {
|
||||
for (let attempt = 0; attempt < 400 && runtimeProbes.size > 0; attempt += 1) {
|
||||
await new Promise((resolve) => setTimeout(resolve, 5))
|
||||
}
|
||||
}
|
||||
vi.mocked(listWorktrees).mockClear()
|
||||
try {
|
||||
const scratchPath = '/tmp/.codex-tmp/capsule-a'
|
||||
const runtime = new OrcaRuntimeService({
|
||||
...store,
|
||||
getRepos: () => [
|
||||
{ id: 'repo-1', path: '/tmp/repo', displayName: 'repo', badgeColor: 'blue', addedAt: 1 },
|
||||
{
|
||||
id: 'repo-scratch',
|
||||
path: scratchPath,
|
||||
displayName: 'capsule',
|
||||
badgeColor: 'blue',
|
||||
addedAt: 1
|
||||
}
|
||||
]
|
||||
} as never)
|
||||
const internals = runtime as unknown as { listResolvedWorktrees: () => Promise<unknown> }
|
||||
runtimeProbes = runtime['worktreeAdminFingerprintProbes']
|
||||
const scanCallsFor = (path: string): number =>
|
||||
vi.mocked(listWorktrees).mock.calls.filter((call) => call[0] === path).length
|
||||
|
||||
await internals.listResolvedWorktrees()
|
||||
await settleFingerprintProbes()
|
||||
expect(scanCallsFor('/tmp/repo')).toBe(1)
|
||||
expect(scanCallsFor(scratchPath)).toBe(1)
|
||||
|
||||
vi.advanceTimersByTime(BASE_TTL_MS + 1_000)
|
||||
await internals.listResolvedWorktrees()
|
||||
expect(scanCallsFor('/tmp/repo')).toBe(2)
|
||||
expect(scanCallsFor(scratchPath)).toBe(1)
|
||||
|
||||
vi.advanceTimersByTime(SCRATCH_TTL_MS)
|
||||
await internals.listResolvedWorktrees()
|
||||
expect(scanCallsFor(scratchPath)).toBe(2)
|
||||
} finally {
|
||||
vi.useRealTimers()
|
||||
}
|
||||
})
|
||||
|
||||
it('scans a repo registered after the last snapshot instead of answering from it', async () => {
|
||||
// A newly registered SSH repo must invalidate the fleet snapshot or workspace lookup falsely reports absence.
|
||||
vi.mocked(listWorktrees).mockClear()
|
||||
const addedPath = '/tmp/repo-registered-later'
|
||||
const repos = [
|
||||
{ id: 'repo-1', path: '/tmp/repo', displayName: 'repo', badgeColor: 'blue', addedAt: 1 }
|
||||
]
|
||||
const runtime = new OrcaRuntimeService({ ...store, getRepos: () => repos } as never)
|
||||
const internals = runtime as unknown as { listResolvedWorktrees: () => Promise<unknown> }
|
||||
const scanCallsFor = (path: string): number =>
|
||||
vi.mocked(listWorktrees).mock.calls.filter((call) => call[0] === path).length
|
||||
|
||||
await internals.listResolvedWorktrees()
|
||||
expect(scanCallsFor(addedPath)).toBe(0)
|
||||
|
||||
repos.push({
|
||||
id: 'repo-added',
|
||||
path: addedPath,
|
||||
displayName: 'added',
|
||||
badgeColor: 'blue',
|
||||
addedAt: 2
|
||||
})
|
||||
bumpLocalWorktreeScanGeneration('repo-added')
|
||||
|
||||
await internals.listResolvedWorktrees()
|
||||
expect(scanCallsFor(addedPath)).toBe(1)
|
||||
})
|
||||
})
|
||||
@@ -1,106 +0,0 @@
|
||||
import '../../providers/ssh-host-not-served-error'
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import './runtime-test-module-registration.spec'
|
||||
import '../../../shared/orca-profiles/constants'
|
||||
import {
|
||||
MOCK_GIT_WORKTREES,
|
||||
computeWorktreePathMock,
|
||||
ensurePathWithinWorkspaceMock
|
||||
} from '../orca-runtime-test-mocks/setup.spec'
|
||||
import { OrcaRuntimeService } from '../orca-runtime'
|
||||
import '../../git/worktrees/creation/worktree-sparse-add'
|
||||
import '../../git/worktrees/creation/worktree-add'
|
||||
import { join } from 'node:path'
|
||||
import { listWorktrees } from '../../git/worktrees/catalog/worktree-scan-cache'
|
||||
import { mkdir, mkdtemp, writeFile } from 'node:fs/promises'
|
||||
import { tmpdir } from 'node:os'
|
||||
import '../rpc/dispatcher'
|
||||
import '../rpc/methods/terminal/terminal'
|
||||
import {
|
||||
TEST_FOLDER_WORKSPACE_KEY,
|
||||
TEST_REPO_ID,
|
||||
TEST_WORKTREE_ID,
|
||||
createFolderWorkspaceRuntimeStore,
|
||||
deferred,
|
||||
makeFolderProjectGroup,
|
||||
makeFolderWorkspace,
|
||||
store
|
||||
} from './orca-runtime-test-fixtures.spec'
|
||||
|
||||
describe('OrcaRuntimeService', () => {
|
||||
it.each([
|
||||
{ label: 'canonical folder workspace selector', selector: TEST_FOLDER_WORKSPACE_KEY },
|
||||
{ label: 'id-prefixed folder workspace selector', selector: `id:${TEST_FOLDER_WORKSPACE_KEY}` }
|
||||
])('reads file explorer paths for a $label', async ({ selector }) => {
|
||||
const folderPath = await mkdtemp(join(tmpdir(), 'orca-runtime-folder-files-'))
|
||||
await mkdir(join(folderPath, 'src'))
|
||||
await writeFile(join(folderPath, 'src', 'app.ts'), 'export {}\n')
|
||||
const folderWorkspace = makeFolderWorkspace({ folderPath })
|
||||
const projectGroup = makeFolderProjectGroup({ parentPath: folderPath })
|
||||
const runtime = new OrcaRuntimeService(
|
||||
createFolderWorkspaceRuntimeStore(folderWorkspace, projectGroup) as never
|
||||
)
|
||||
|
||||
await expect(runtime.readFileExplorerDir(selector, 'src')).resolves.toContainEqual({
|
||||
name: 'app.ts',
|
||||
isDirectory: false,
|
||||
isSymlink: false
|
||||
})
|
||||
await expect(runtime.readFileExplorerPreview(selector, 'src/app.ts')).resolves.toMatchObject({
|
||||
content: 'export {}\n',
|
||||
isBinary: false
|
||||
})
|
||||
})
|
||||
|
||||
it('does not reuse stale in-flight worktree scans after creating a worktree', async () => {
|
||||
const addRetiredWorktreeName = vi.fn()
|
||||
const runtime = new OrcaRuntimeService({
|
||||
...store,
|
||||
addRetiredWorktreeName,
|
||||
getRetiredWorktreeNameRegistry: () => ({
|
||||
exhaustedTiers: 0,
|
||||
names: Array.from({ length: 100 }, (_unused, index) =>
|
||||
index === 0 ? 'nautilus' : `nautilus-${index + 1}`
|
||||
)
|
||||
})
|
||||
})
|
||||
const staleScan = deferred<typeof MOCK_GIT_WORKTREES>()
|
||||
const createdWorktree = {
|
||||
path: '/tmp/workspaces/repo-nautilus-101',
|
||||
head: 'def',
|
||||
branch: 'nautilus-101',
|
||||
isBare: false,
|
||||
isMainWorktree: false
|
||||
}
|
||||
computeWorktreePathMock.mockReturnValue(createdWorktree.path)
|
||||
ensurePathWithinWorkspaceMock.mockReturnValue(createdWorktree.path)
|
||||
vi.mocked(listWorktrees)
|
||||
.mockImplementationOnce(() => staleScan.promise)
|
||||
.mockResolvedValueOnce([createdWorktree])
|
||||
// listDetected prunes after the create, so it observes again with its own pre-scan claim.
|
||||
.mockResolvedValueOnce([...MOCK_GIT_WORKTREES, createdWorktree])
|
||||
.mockResolvedValueOnce([...MOCK_GIT_WORKTREES, createdWorktree])
|
||||
|
||||
const staleLookup = runtime.showManagedWorktree(TEST_WORKTREE_ID)
|
||||
const result = await runtime.createManagedWorktree({
|
||||
repoSelector: 'id:repo-1',
|
||||
name: 'nautilus',
|
||||
nameWasGenerated: true
|
||||
})
|
||||
const freshLookup = runtime.showManagedWorktree(result.worktree.id)
|
||||
|
||||
staleScan.resolve(MOCK_GIT_WORKTREES)
|
||||
|
||||
await expect(staleLookup).resolves.toMatchObject({ id: TEST_WORKTREE_ID })
|
||||
await expect(freshLookup).resolves.toMatchObject({
|
||||
id: result.worktree.id,
|
||||
path: createdWorktree.path
|
||||
})
|
||||
await expect(runtime.listDetectedManagedWorktrees(`id:${TEST_REPO_ID}`)).resolves.toMatchObject(
|
||||
{
|
||||
worktrees: expect.arrayContaining([expect.objectContaining({ path: createdWorktree.path })])
|
||||
}
|
||||
)
|
||||
expect(addRetiredWorktreeName).toHaveBeenCalledWith(TEST_REPO_ID, 'nautilus-101')
|
||||
})
|
||||
})
|
||||
@@ -1,87 +0,0 @@
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
|
||||
import './runtime-test-module-registration.spec'
|
||||
import { OrcaRuntimeService } from '../orca-runtime'
|
||||
|
||||
import {
|
||||
computeWorktreePathMock,
|
||||
ensurePathWithinWorkspaceMock
|
||||
} from '../orca-runtime-test-mocks/setup.spec'
|
||||
|
||||
import { listWorktrees } from '../../git/worktrees/catalog/worktree-scan-cache'
|
||||
|
||||
import type { WorktreeMeta } from '../../../shared/worktree/meta-types'
|
||||
|
||||
import { TEST_REPO_ID, makeWorktreeMeta, store } from './orca-runtime-test-fixtures.spec'
|
||||
|
||||
import type { HostWorktreeTarget } from '../../../shared/worktree/host-qualified-identity'
|
||||
|
||||
describe('OrcaRuntimeService', () => {
|
||||
it('does not send stdin-after-start prompts into a shell when the agent never starts', async () => {
|
||||
vi.useFakeTimers()
|
||||
try {
|
||||
const metaById: Record<string, WorktreeMeta> = {}
|
||||
const runtimeStore = {
|
||||
...store,
|
||||
getSettings: () => ({
|
||||
...store.getSettings(),
|
||||
agentCmdOverrides: {}
|
||||
}),
|
||||
getAllWorktreeMeta: () => metaById,
|
||||
getWorktreeMeta: (worktreeId: string) => metaById[worktreeId],
|
||||
setWorktreeMeta: ({ id: worktreeId }: HostWorktreeTarget, meta: Partial<WorktreeMeta>) => {
|
||||
metaById[worktreeId] = { ...(metaById[worktreeId] ?? makeWorktreeMeta()), ...meta }
|
||||
return metaById[worktreeId]
|
||||
}
|
||||
}
|
||||
const runtime = new OrcaRuntimeService(runtimeStore as never)
|
||||
const write = vi.fn().mockReturnValue(true)
|
||||
runtime.setPtyController({
|
||||
spawn: vi.fn().mockResolvedValue({ id: 'pty-cli-aider-shell' }),
|
||||
write,
|
||||
kill: () => true,
|
||||
getForegroundProcess: async () => 'zsh',
|
||||
hasChildProcesses: vi.fn().mockResolvedValue(false)
|
||||
})
|
||||
runtime.setNotifier({
|
||||
worktreesChanged: vi.fn(),
|
||||
reposChanged: vi.fn(),
|
||||
activateWorktree: vi.fn(),
|
||||
createTerminal: vi.fn(),
|
||||
revealTerminalSession: vi.fn().mockResolvedValue({ tabId: 'tab-cli-aider-shell' }),
|
||||
splitTerminal: vi.fn(),
|
||||
renameTerminal: vi.fn(),
|
||||
focusTerminal: vi.fn(),
|
||||
closeTerminal: vi.fn(),
|
||||
terminalFitOverrideChanged: vi.fn(),
|
||||
terminalDriverChanged: vi.fn()
|
||||
})
|
||||
runtime.attachWindow(1)
|
||||
|
||||
computeWorktreePathMock.mockReturnValue('/tmp/workspaces/runtime-cli-aider-shell')
|
||||
ensurePathWithinWorkspaceMock.mockReturnValue('/tmp/workspaces/runtime-cli-aider-shell')
|
||||
vi.mocked(listWorktrees).mockResolvedValue([
|
||||
{
|
||||
path: '/tmp/workspaces/runtime-cli-aider-shell',
|
||||
head: 'def',
|
||||
branch: 'runtime-cli-aider-shell',
|
||||
isBare: false,
|
||||
isMainWorktree: false
|
||||
}
|
||||
])
|
||||
|
||||
await runtime.createManagedWorktree({
|
||||
repoSelector: TEST_REPO_ID,
|
||||
name: 'runtime-cli-aider-shell',
|
||||
startupAgent: 'aider',
|
||||
startupPrompt: 'fix it'
|
||||
})
|
||||
|
||||
await vi.advanceTimersByTimeAsync(6000)
|
||||
|
||||
expect(write).not.toHaveBeenCalled()
|
||||
} finally {
|
||||
vi.useRealTimers()
|
||||
}
|
||||
})
|
||||
})
|
||||
@@ -1,89 +0,0 @@
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import * as repoWorktreeAdminFingerprint from '../workspaces/catalog/repo-worktree-admin-fingerprint'
|
||||
import * as wslUncAccessGate from '../../wsl/filesystem/wsl-unc-access-gate'
|
||||
import './runtime-test-module-registration.spec'
|
||||
import { OrcaRuntimeService } from '../orca-runtime'
|
||||
import { listWorktrees } from '../../git/worktrees/catalog/worktree-scan-cache'
|
||||
import { makeWorktreeInfo, makeWorktreeMeta, store } from './orca-runtime-test-fixtures.spec'
|
||||
|
||||
const WSL_REPO_PATH = '\\\\wsl.localhost\\Ubuntu\\home\\me\\repo'
|
||||
|
||||
function runtimeFor(path: string, storedWorktreePaths: string[] = []): OrcaRuntimeService {
|
||||
const repos = [{ ...store.getRepos()[0], id: 'wsl-repo', path }]
|
||||
const storedMeta = Object.fromEntries(
|
||||
storedWorktreePaths.map((worktreePath) => [`wsl-repo::${worktreePath}`, makeWorktreeMeta()])
|
||||
)
|
||||
const runtimeStore = {
|
||||
...store,
|
||||
getAllWorktreeMeta: () => storedMeta,
|
||||
getRepos: () => repos,
|
||||
getRepo: (id: string) => repos.find((repo) => repo.id === id)
|
||||
}
|
||||
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: the shared runtime fixture store, as sibling scan-cache specs build it.
|
||||
return new OrcaRuntimeService(runtimeStore as never)
|
||||
}
|
||||
|
||||
describe('worktree scans of a stopped WSL distro (E9)', () => {
|
||||
it('keeps the known rows and never reads the admin dir or runs Git while the distro is stopped', async () => {
|
||||
vi.mocked(listWorktrees).mockReset()
|
||||
vi.mocked(listWorktrees).mockImplementation(async (repoPath) => [makeWorktreeInfo(repoPath)])
|
||||
vi.useFakeTimers({ now: 0 })
|
||||
const fingerprint = vi
|
||||
.spyOn(repoWorktreeAdminFingerprint, 'readRepoWorktreeAdminFingerprint')
|
||||
.mockResolvedValue(null)
|
||||
const blocked = vi.spyOn(wslUncAccessGate, 'blockedWslDistroForPath').mockResolvedValue(null)
|
||||
// This test runs off Windows; the gate only asks about paths it maps to a distro.
|
||||
const distroFor = vi.spyOn(wslUncAccessGate, 'wslDistroForPath').mockReturnValue('Ubuntu')
|
||||
try {
|
||||
const runtime = runtimeFor(WSL_REPO_PATH)
|
||||
const running = await runtime.listDetectedManagedWorktrees('id:wsl-repo')
|
||||
expect(listWorktrees).toHaveBeenCalledTimes(1)
|
||||
|
||||
blocked.mockResolvedValue({ distro: 'Ubuntu', state: 'stopped' })
|
||||
fingerprint.mockClear()
|
||||
vi.setSystemTime(10 * 60_000)
|
||||
const stopped = await runtime.listDetectedManagedWorktrees('id:wsl-repo')
|
||||
|
||||
expect(listWorktrees).toHaveBeenCalledTimes(1)
|
||||
expect(fingerprint).not.toHaveBeenCalled()
|
||||
expect(stopped.worktrees.map((worktree) => worktree.path)).toEqual(
|
||||
running.worktrees.map((worktree) => worktree.path)
|
||||
)
|
||||
expect(blocked).toHaveBeenCalledWith(WSL_REPO_PATH, undefined)
|
||||
|
||||
// Once it runs again, the next scan goes to Git as before.
|
||||
blocked.mockResolvedValue(null)
|
||||
vi.setSystemTime(20 * 60_000)
|
||||
await runtime.listDetectedManagedWorktrees('id:wsl-repo')
|
||||
expect(listWorktrees).toHaveBeenCalledTimes(2)
|
||||
} finally {
|
||||
distroFor.mockRestore()
|
||||
blocked.mockRestore()
|
||||
fingerprint.mockRestore()
|
||||
vi.useRealTimers()
|
||||
}
|
||||
})
|
||||
|
||||
it.each(['stopped', 'unverifiable'] as const)(
|
||||
'with no cached scan, a %s distro answers from stored rows without any read or Git',
|
||||
async (state) => {
|
||||
vi.mocked(listWorktrees).mockReset()
|
||||
const fingerprint = vi.spyOn(repoWorktreeAdminFingerprint, 'readRepoWorktreeAdminFingerprint')
|
||||
const blocked = vi
|
||||
.spyOn(wslUncAccessGate, 'blockedWslDistroForPath')
|
||||
.mockResolvedValue({ distro: 'Ubuntu', state })
|
||||
const distroFor = vi.spyOn(wslUncAccessGate, 'wslDistroForPath').mockReturnValue('Ubuntu')
|
||||
try {
|
||||
const runtime = runtimeFor(WSL_REPO_PATH, [WSL_REPO_PATH])
|
||||
const result = await runtime.listDetectedManagedWorktrees('id:wsl-repo')
|
||||
expect(listWorktrees).not.toHaveBeenCalled()
|
||||
expect(fingerprint).not.toHaveBeenCalled()
|
||||
expect(result.worktrees.map((worktree) => worktree.path)).toEqual([WSL_REPO_PATH])
|
||||
} finally {
|
||||
distroFor.mockRestore()
|
||||
blocked.mockRestore()
|
||||
fingerprint.mockRestore()
|
||||
}
|
||||
}
|
||||
)
|
||||
})
|
||||
+3
-7
@@ -1,11 +1,7 @@
|
||||
import { afterEach, vi } from 'vitest'
|
||||
import { OrchestrationDb } from '../orchestration/db/orchestration-db'
|
||||
import type { TaskRuntimeLineageRow } from '../orchestration/db/run-list-page'
|
||||
import type {
|
||||
CoordinatorRun,
|
||||
DispatchContextRow,
|
||||
RunRow
|
||||
} from '../orchestration/db/orchestration-records'
|
||||
import { OrchestrationDb } from './orchestration-db'
|
||||
import type { TaskRuntimeLineageRow } from './run-list-page'
|
||||
import type { CoordinatorRun, DispatchContextRow, RunRow } from './orchestration-records'
|
||||
|
||||
const databases = new Set<OrchestrationDb>()
|
||||
const createdAt = '2026-10-27T12:00:00Z'
|
||||
+1
-1
@@ -13,7 +13,7 @@ import { ORCA_LAYOUT_OWNER_IS_MAIN } from '../../../../../shared/workspace-layou
|
||||
import {
|
||||
bindPaneFirst,
|
||||
registerBoundPty
|
||||
} from '../../../orca-runtime-tests/bind-first-pane.test-fixture'
|
||||
} from '../../../terminal/layout/bind-first-pane.test-fixture'
|
||||
import { publishHeadlessRuntimeGraph } from '../../../session-graph/headless-runtime-graph'
|
||||
|
||||
export const TAB_ID = '11111111-1111-4111-8111-111111111111'
|
||||
|
||||
+13
-159
@@ -1,164 +1,18 @@
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import './runtime-test-module-registration.spec'
|
||||
import { FOLDER_WORKSPACE_INSTANCE_SEPARATOR } from '../../../shared/worktree/id'
|
||||
import { OrcaRuntimeService } from '../orca-runtime'
|
||||
import { OrchestrationDb } from '../orchestration/db/orchestration-db'
|
||||
import { createRootDispatch } from '../orchestration/db/root-dispatch-test-fixture'
|
||||
import { join } from 'node:path'
|
||||
import { makePaneKey } from '../../../shared/workspace-layout/stable-pane-id'
|
||||
import { tmpdir } from 'node:os'
|
||||
import { TEST_REPO_ID, TEST_WORKTREE_ID, store } from './orca-runtime-test-fixtures.spec'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import '../../construction/test-context/runtime-test-module-registration.spec'
|
||||
import '../../../../shared/worktree/id'
|
||||
import { OrcaRuntimeService } from '../../orca-runtime'
|
||||
import { OrchestrationDb } from '../db/orchestration-db'
|
||||
import { createRootDispatch } from '../db/root-dispatch-test-fixture'
|
||||
import 'node:path'
|
||||
import { makePaneKey } from '../../../../shared/workspace-layout/stable-pane-id'
|
||||
import 'node:os'
|
||||
import {
|
||||
TEST_WORKTREE_ID,
|
||||
store
|
||||
} from '../../construction/test-context/orca-runtime-test-fixtures.spec'
|
||||
|
||||
describe('OrcaRuntimeService', () => {
|
||||
it('uses durable Run ownership before worktree-scoped legacy attribution', async () => {
|
||||
const childWorktreeId = `${TEST_REPO_ID}::${join(tmpdir(), 'workspaces', 'run-a-worker')}`
|
||||
const folderWorktreeId = `${TEST_REPO_ID}::${join(tmpdir(), 'folder')}${FOLDER_WORKSPACE_INSTANCE_SEPARATOR}11111111-1111-4111-8111-111111111111`
|
||||
const meta = store.getAllWorktreeMeta()[TEST_WORKTREE_ID]
|
||||
const metaById = {
|
||||
...store.getAllWorktreeMeta(),
|
||||
[childWorktreeId]: meta,
|
||||
[folderWorktreeId]: meta
|
||||
}
|
||||
const runtime = new OrcaRuntimeService({
|
||||
...store,
|
||||
getAllWorktreeMeta: () => metaById,
|
||||
getWorktreeMeta: (worktreeId: string) => metaById[worktreeId]
|
||||
} as never)
|
||||
const terminals = [
|
||||
{
|
||||
name: 'coordinator-a',
|
||||
worktreeId: TEST_WORKTREE_ID,
|
||||
leafId: '11111111-1111-4111-8111-111111111111'
|
||||
},
|
||||
{
|
||||
name: 'coordinator-b',
|
||||
worktreeId: TEST_WORKTREE_ID,
|
||||
leafId: '22222222-2222-4222-8222-222222222222'
|
||||
},
|
||||
{
|
||||
name: 'worker-cross-worktree',
|
||||
worktreeId: childWorktreeId,
|
||||
leafId: '33333333-3333-4333-8333-333333333333'
|
||||
},
|
||||
{
|
||||
name: 'worker-same-worktree',
|
||||
worktreeId: TEST_WORKTREE_ID,
|
||||
leafId: '44444444-4444-4444-8444-444444444444'
|
||||
},
|
||||
{
|
||||
name: 'worker-folder',
|
||||
worktreeId: folderWorktreeId,
|
||||
leafId: '55555555-5555-4555-8555-555555555555'
|
||||
},
|
||||
{
|
||||
name: 'legacy-worker',
|
||||
worktreeId: childWorktreeId,
|
||||
leafId: '66666666-6666-4666-8666-666666666666'
|
||||
}
|
||||
].map((terminal, index) => ({
|
||||
...terminal,
|
||||
tabId: `tab-${terminal.name}`,
|
||||
ptyId: `pty-${terminal.name}`,
|
||||
paneRuntimeId: index + 1
|
||||
}))
|
||||
const terminalByName = Object.fromEntries(
|
||||
terminals.map((terminal) => [terminal.name, terminal])
|
||||
)
|
||||
const handles = Object.fromEntries(
|
||||
terminals.map((terminal) => [terminal.name, runtime.preAllocateHandleForPty(terminal.ptyId)])
|
||||
)
|
||||
const paneKey = (name: string): string => {
|
||||
const terminal = terminalByName[name]
|
||||
return makePaneKey(terminal.tabId, terminal.leafId)
|
||||
}
|
||||
const db = new OrchestrationDb(':memory:')
|
||||
try {
|
||||
const runA = db.createRun({
|
||||
objective: 'coordinate run A',
|
||||
coordinatorHandle: handles['coordinator-a'],
|
||||
coordinatorPaneKey: paneKey('coordinator-a')
|
||||
})
|
||||
const runB = db.createRun({
|
||||
objective: 'coordinate run B',
|
||||
coordinatorHandle: handles['coordinator-b'],
|
||||
coordinatorPaneKey: paneKey('coordinator-b')
|
||||
})
|
||||
const dispatches = Object.fromEntries(
|
||||
[
|
||||
['worker-cross-worktree', runA.id],
|
||||
['worker-same-worktree', runA.id],
|
||||
['worker-folder', runB.id]
|
||||
].map(([name, runId]) => {
|
||||
const task = db.createTask({ spec: name, runId })
|
||||
return [name, createRootDispatch(db, task.id, handles[name], paneKey(name))]
|
||||
})
|
||||
)
|
||||
const legacyTask = db.createTask({
|
||||
runId: 'run_legacy_local',
|
||||
spec: 'legacy worker'
|
||||
})
|
||||
const legacyDispatch = createRootDispatch(
|
||||
db,
|
||||
legacyTask.id,
|
||||
handles['legacy-worker'],
|
||||
paneKey('legacy-worker')
|
||||
)
|
||||
db.createCoordinatorRun({
|
||||
spec: 'unrelated legacy coordinator',
|
||||
coordinatorHandle: handles['coordinator-b']
|
||||
})
|
||||
const getActiveCoordinatorRun = vi.spyOn(db, 'getActiveCoordinatorRun')
|
||||
runtime.setOrchestrationDb(db)
|
||||
runtime.attachWindow(1)
|
||||
|
||||
const result = await runtime.syncWindowGraph(1, {
|
||||
tabs: terminals.map((terminal) => ({
|
||||
tabId: terminal.tabId,
|
||||
worktreeId: terminal.worktreeId,
|
||||
title: terminal.name,
|
||||
activeLeafId: terminal.leafId,
|
||||
layout: null
|
||||
})),
|
||||
leaves: terminals.map((terminal) => ({
|
||||
tabId: terminal.tabId,
|
||||
worktreeId: terminal.worktreeId,
|
||||
leafId: terminal.leafId,
|
||||
paneRuntimeId: terminal.paneRuntimeId,
|
||||
ptyId: terminal.ptyId,
|
||||
paneTitle: null
|
||||
}))
|
||||
})
|
||||
|
||||
for (const [name, run, coordinator] of [
|
||||
['worker-cross-worktree', runA, 'coordinator-a'],
|
||||
['worker-same-worktree', runA, 'coordinator-a'],
|
||||
['worker-folder', runB, 'coordinator-b']
|
||||
] as const) {
|
||||
expect(result.agentOrchestrationByPaneKey?.[paneKey(name)]).toMatchObject({
|
||||
taskId: dispatches[name].task_id,
|
||||
dispatchId: dispatches[name].id,
|
||||
dispatchStatus: 'dispatched',
|
||||
parentTerminalHandle: handles[coordinator],
|
||||
parentPaneKey: paneKey(coordinator),
|
||||
coordinatorHandle: handles[coordinator],
|
||||
orchestrationRunId: run.id
|
||||
})
|
||||
}
|
||||
const legacyContext = result.agentOrchestrationByPaneKey?.[paneKey('legacy-worker')]
|
||||
expect(legacyContext).toMatchObject({
|
||||
taskId: legacyTask.id,
|
||||
dispatchId: legacyDispatch.id,
|
||||
dispatchStatus: 'dispatched'
|
||||
})
|
||||
expect(legacyContext).not.toHaveProperty('parentTerminalHandle')
|
||||
expect(legacyContext).not.toHaveProperty('coordinatorHandle')
|
||||
expect(legacyContext).not.toHaveProperty('orchestrationRunId')
|
||||
expect(getActiveCoordinatorRun).toHaveBeenCalledOnce()
|
||||
} finally {
|
||||
db.close()
|
||||
}
|
||||
})
|
||||
|
||||
it('uses the still-bound owning Run coordinator after a creator pane rebinds', async () => {
|
||||
const runtime = new OrcaRuntimeService(store)
|
||||
const terminals = [
|
||||
+1
-1
@@ -17,7 +17,7 @@ import { AgentHookServer } from '../../../agent-hooks/server/agent-hook-server'
|
||||
import { OrcaRuntimeService } from '../../orca-runtime'
|
||||
import { makeStore } from '../../rpc/server/runtime-rpc-worktree-store-fixtures'
|
||||
import { spawnedPtyEnv } from '../../terminal/launch/spawned-pty-env-fixtures'
|
||||
import { committingSpawn } from '../../orca-runtime-tests/bind-first-pane.test-fixture'
|
||||
import { committingSpawn } from '../../terminal/layout/bind-first-pane.test-fixture'
|
||||
|
||||
// STA-4557: deferred OpenCode foreground reads retained/revived finished authority (#14866, reverted in #14943).
|
||||
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ import type { ExecutionHostId } from '../../../../shared/execution-host/executio
|
||||
|
||||
import type { WorkspaceSessionState } from '../../../../shared/workspace-session/workspace-session-state-types'
|
||||
|
||||
import { withDurableRuntimeStore } from '../../orca-runtime-tests/runtime-durable-store-fixture'
|
||||
import { withDurableRuntimeStore } from '../../construction/test-context/runtime-durable-store-fixture'
|
||||
|
||||
import { RuntimeLegacyWorkerTerminalRecoveryPersistence } from './runtime-legacy-worker-terminal-recovery-persistence'
|
||||
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ import {
|
||||
type FakeConnection
|
||||
} from './structured-chat-coordinator-fake-codex-fixture'
|
||||
import { createStructuredAgentSessionLogger } from '../../../../native-chat/agent-session-wire/host/structured-agent-session-logger'
|
||||
import { scriptedCodexTransport } from '../../../orca-runtime-tests/scripted-codex-transport.test-fixture'
|
||||
import { scriptedCodexTransport } from '../../../agent-session/testing/scripted-codex-transport.test-fixture'
|
||||
|
||||
export const COORDINATOR = '4a1f6c2e-8b3d-4e7a-9c15-0d2b6e8f1a37'
|
||||
export const PEER_CHAT = '7e3b9d15-2c4a-4f86-a0b1-5c9e2d7f3b64'
|
||||
|
||||
+11
-130
@@ -1,9 +1,12 @@
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import { committingSpawn, registerLivePty } from './bind-first-pane.test-fixture'
|
||||
import './runtime-test-module-registration.spec'
|
||||
import { OrcaRuntimeService } from '../orca-runtime'
|
||||
import '../orca-runtime-test-mocks/setup.spec'
|
||||
import { makePaneKey } from '../../../shared/workspace-layout/stable-pane-id'
|
||||
import {
|
||||
committingSpawn,
|
||||
registerLivePty
|
||||
} from '../../terminal/layout/bind-first-pane.test-fixture'
|
||||
import '../../construction/test-context/runtime-test-module-registration.spec'
|
||||
import { OrcaRuntimeService } from '../../orca-runtime'
|
||||
import '../../orca-runtime-test-mocks/setup.spec'
|
||||
import { makePaneKey } from '../../../../shared/workspace-layout/stable-pane-id'
|
||||
import {
|
||||
HEADLESS_LEAF_ID,
|
||||
RESTORED_AUTHORITY_TOKEN,
|
||||
@@ -11,14 +14,12 @@ import {
|
||||
TEST_WINDOW_ID,
|
||||
TEST_WORKTREE_ID,
|
||||
TEST_WORKTREE_PATH,
|
||||
deferred,
|
||||
makeHeadlessTerminalLayout,
|
||||
makeRuntimeStoreWithWorkspaceSession,
|
||||
makeWorkspaceSessionWithHeadlessTerminal,
|
||||
store
|
||||
} from './orca-runtime-test-fixtures.spec'
|
||||
import { spawnedPtyEnv } from '../terminal/launch/spawned-pty-env-fixtures'
|
||||
import '../../../shared/agent-launch/startup/jcode-runtime-dir'
|
||||
} from '../../construction/test-context/orca-runtime-test-fixtures.spec'
|
||||
import { spawnedPtyEnv } from '../../terminal/launch/spawned-pty-env-fixtures'
|
||||
import '../../../../shared/agent-launch/startup/jcode-runtime-dir'
|
||||
|
||||
describe('OrcaRuntimeService', () => {
|
||||
it('retires inherited launch authority when the agent command exits', async () => {
|
||||
@@ -163,124 +164,4 @@ describe('OrcaRuntimeService', () => {
|
||||
processIncarnation: `persisted-pty:${incarnationId}`
|
||||
})
|
||||
})
|
||||
|
||||
it('drops an out-of-order aggregate inventory after a newer SSH inventory', async () => {
|
||||
const targetId = 'ssh-1'
|
||||
const ptyId = `ssh:${targetId}@@persisted-pty`
|
||||
const paneKey = makePaneKey('host-tab', HEADLESS_LEAF_ID)
|
||||
const oldIncarnation = 'bbbbbbbb-bbbb-4bbb-8bbb-bbbbbbbbbbbb'
|
||||
const newIncarnation = 'cccccccc-cccc-4ccc-8ccc-cccccccccccc'
|
||||
const session = makeWorkspaceSessionWithHeadlessTerminal({
|
||||
tabsByWorktree: {
|
||||
[TEST_WORKTREE_ID]: [
|
||||
{
|
||||
id: 'host-tab',
|
||||
ptyId,
|
||||
worktreeId: TEST_WORKTREE_ID,
|
||||
title: 'Persisted Terminal',
|
||||
customTitle: null,
|
||||
color: null,
|
||||
sortOrder: 0,
|
||||
createdAt: 1
|
||||
}
|
||||
]
|
||||
},
|
||||
terminalLayoutsByTabId: {
|
||||
'host-tab': makeHeadlessTerminalLayout({ [HEADLESS_LEAF_ID]: ptyId })
|
||||
},
|
||||
terminalPtyIncarnationsByPaneKey: { [paneKey]: oldIncarnation }
|
||||
})
|
||||
const { runtimeStore } = makeRuntimeStoreWithWorkspaceSession(session)
|
||||
const runtime = new OrcaRuntimeService(runtimeStore as never, undefined, {
|
||||
attestAgentHookCompatibilityAuthority: ({ paneKey: candidate, launchTokenHash }) =>
|
||||
candidate === paneKey && launchTokenHash === RESTORED_AUTHORITY_TOKEN_HASH
|
||||
? { paneKey: candidate, source: 'hydrated_commitment' }
|
||||
: null
|
||||
})
|
||||
const oldInventory = deferred<
|
||||
{
|
||||
id: string
|
||||
incarnationId: string
|
||||
terminalHandle: string
|
||||
worktreeId: string
|
||||
cwd: string
|
||||
title: string
|
||||
wslDistro: null
|
||||
}[]
|
||||
>()
|
||||
const newInventory =
|
||||
deferred<typeof oldInventory.promise extends Promise<infer T> ? T : never>()
|
||||
const listProcesses = vi
|
||||
.fn()
|
||||
.mockImplementationOnce(() => oldInventory.promise)
|
||||
.mockImplementationOnce(() => newInventory.promise)
|
||||
runtime.setPtyController({
|
||||
write: () => true,
|
||||
kill: () => true,
|
||||
getForegroundProcess: async () => null,
|
||||
listProcesses
|
||||
})
|
||||
const internals = runtime as unknown as {
|
||||
refreshPtyWorktreeRecordsWithControllerInventory: (
|
||||
worktrees: [],
|
||||
targetWorktreeId: string | null,
|
||||
deadline: number | undefined,
|
||||
connectionId: string | null | undefined
|
||||
) => Promise<unknown>
|
||||
ptysById: Map<string, { incarnationId: string | null }>
|
||||
restoredOrchestrationAuthorityByPtyId: Map<string, unknown>
|
||||
}
|
||||
const host = runtime.registerOrchestrationCompatibilitySshAttachment(
|
||||
targetId,
|
||||
'connection-incarnation'
|
||||
)
|
||||
|
||||
const staleRefresh = internals.refreshPtyWorktreeRecordsWithControllerInventory(
|
||||
[],
|
||||
null,
|
||||
undefined,
|
||||
undefined
|
||||
)
|
||||
const currentRefresh = internals.refreshPtyWorktreeRecordsWithControllerInventory(
|
||||
[],
|
||||
null,
|
||||
undefined,
|
||||
targetId
|
||||
)
|
||||
newInventory.resolve([
|
||||
{
|
||||
id: ptyId,
|
||||
incarnationId: newIncarnation,
|
||||
terminalHandle: 'term_new_process',
|
||||
worktreeId: TEST_WORKTREE_ID,
|
||||
cwd: TEST_WORKTREE_PATH,
|
||||
title: 'Replacement',
|
||||
wslDistro: null
|
||||
}
|
||||
])
|
||||
await expect(currentRefresh).resolves.not.toBeNull()
|
||||
oldInventory.resolve([
|
||||
{
|
||||
id: ptyId,
|
||||
incarnationId: oldIncarnation,
|
||||
terminalHandle: 'term_old_process',
|
||||
worktreeId: TEST_WORKTREE_ID,
|
||||
cwd: TEST_WORKTREE_PATH,
|
||||
title: 'Retained coordinator',
|
||||
wslDistro: null
|
||||
}
|
||||
])
|
||||
await expect(staleRefresh).resolves.toBeNull()
|
||||
|
||||
expect(internals.ptysById.get(ptyId)?.incarnationId).toBe(newIncarnation)
|
||||
expect(internals.restoredOrchestrationAuthorityByPtyId.has(ptyId)).toBe(false)
|
||||
expect(
|
||||
runtime.verifyOrchestrationCompatibilityCaller({
|
||||
terminalHandle: 'term_old_process',
|
||||
paneKey,
|
||||
launchToken: RESTORED_AUTHORITY_TOKEN,
|
||||
host
|
||||
})
|
||||
).toBeNull()
|
||||
})
|
||||
})
|
||||
+7
-7
@@ -1,15 +1,15 @@
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import './runtime-test-module-registration.spec'
|
||||
import './orca-runtime-test-lifecycle.spec'
|
||||
import { OrcaRuntimeService } from '../orca-runtime'
|
||||
import { OrchestrationDb } from '../orchestration/db/orchestration-db'
|
||||
import { withDurableRuntimeStore } from './runtime-durable-store-fixture'
|
||||
import '../../construction/test-context/runtime-test-module-registration.spec'
|
||||
import '../../construction/test-context/orca-runtime-test-lifecycle.spec'
|
||||
import { OrcaRuntimeService } from '../../orca-runtime'
|
||||
import { OrchestrationDb } from '../db/orchestration-db'
|
||||
import { withDurableRuntimeStore } from '../../construction/test-context/runtime-durable-store-fixture'
|
||||
import {
|
||||
TEST_WORKTREE_ID,
|
||||
makeRuntimeStoreWithWorkspaceSession,
|
||||
makeWorkspaceSessionWithHeadlessTerminal
|
||||
} from './orca-runtime-test-fixtures.spec'
|
||||
import type { AgentStatusIpcPayload } from '../../../shared/agent-status/contracts/agent-status-ipc-payload'
|
||||
} from '../../construction/test-context/orca-runtime-test-fixtures.spec'
|
||||
import type { AgentStatusIpcPayload } from '../../../../shared/agent-status/contracts/agent-status-ipc-payload'
|
||||
|
||||
const SESSION = { key: 'session_id', id: 'grok-session-1' } as const
|
||||
const DEAD_PANE_KEY = 'crashed-reopen-tab:44444444-4444-4444-8444-444444444444'
|
||||
+1
-1
@@ -4,7 +4,7 @@ import { makePaneKey } from '../../../../../shared/workspace-layout/stable-pane-
|
||||
import {
|
||||
createTranscriptPane,
|
||||
TRANSCRIPT_PANE_PTY_ID
|
||||
} from '../../../orca-runtime-tests/agent-transcript-pane-test-harness'
|
||||
} from '../../../terminal/wait/agent-transcript-pane-test-harness'
|
||||
import { OrchestrationDb } from '../../db/orchestration-db'
|
||||
import '../../db/contract-constants'
|
||||
import '../../db/messages/mailbox-routing-page'
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import '../../../../shared/worktree/host-qualified-identity'
|
||||
import '../../construction/test-context/runtime-test-module-registration.spec'
|
||||
import '../../orca-runtime-test-mocks/setup.spec'
|
||||
import { OrcaRuntimeService } from '../../orca-runtime'
|
||||
import '../../../git/worktrees/catalog/worktree-scan-cache'
|
||||
|
||||
import '../../session-lifecycle/close/mobile-session-tab-close-outcome'
|
||||
import {
|
||||
TEST_WORKTREE_ID,
|
||||
store
|
||||
} from '../../construction/test-context/orca-runtime-test-fixtures.spec'
|
||||
|
||||
describe('OrcaRuntimeService', () => {
|
||||
it('isolates a throwing subscriber across runtime listener fan-out', () => {
|
||||
const runtime = new OrcaRuntimeService(store)
|
||||
const delivered: number[] = []
|
||||
// Sibling notification fan-outs must also isolate throwing subscribers.
|
||||
runtime.onNotificationDispatched(() => {
|
||||
throw new Error('subscriber_send_failed')
|
||||
})
|
||||
runtime.onNotificationDispatched((event) => {
|
||||
delivered.push(event.notificationSeq ?? -1)
|
||||
})
|
||||
|
||||
expect(() =>
|
||||
runtime.dispatchMobileNotification({
|
||||
type: 'notification',
|
||||
source: 'test',
|
||||
title: 'Test',
|
||||
body: 'Body',
|
||||
worktreeId: TEST_WORKTREE_ID
|
||||
})
|
||||
).not.toThrow()
|
||||
|
||||
expect(delivered).toHaveLength(1)
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,156 @@
|
||||
import { realpathSync } from 'node:fs'
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import '../construction/test-context/runtime-test-module-registration.spec'
|
||||
import { OrcaRuntimeService } from '../orca-runtime'
|
||||
import { execFileSync } from 'node:child_process'
|
||||
import * as forkMetadata from '../../github/client/fetch/repo-slug-upstream'
|
||||
import { join } from 'node:path'
|
||||
import { mkdtemp, rm } from 'node:fs/promises'
|
||||
import { projectHostSetupProjectionFromRepos } from '../../../shared/project/host-setup/project-host-setup-projection'
|
||||
import { tmpdir } from 'node:os'
|
||||
import { store } from '../construction/test-context/orca-runtime-test-fixtures.spec'
|
||||
import type { Repo } from '../../../shared/repository/repo-types'
|
||||
import type { RuntimeStore } from '../construction/runtime-store-contract'
|
||||
|
||||
const parentProbe = vi.spyOn(forkMetadata, 'probeRepoUpstream')
|
||||
beforeEach(() => {
|
||||
parentProbe.mockReset().mockResolvedValue({ upstream: undefined, origin: null })
|
||||
})
|
||||
|
||||
function createRuntime(repos: Repo[]): OrcaRuntimeService {
|
||||
const runtimeStore: RuntimeStore = {
|
||||
...store,
|
||||
getRepos: () => [...repos],
|
||||
addRepo: (repo: Repo) => {
|
||||
repos.push(repo)
|
||||
},
|
||||
getRepo: (id: string) => repos.find((repo) => repo.id === id),
|
||||
updateRepo: ({ id }, updates) => {
|
||||
const repo = repos.find((entry) => entry.id === id)
|
||||
if (!repo) {
|
||||
return null
|
||||
}
|
||||
Object.assign(repo, updates)
|
||||
return { ...repo }
|
||||
},
|
||||
removeProjectForHost: ({ id }: { id: string }) => {
|
||||
const index = repos.findIndex((repo) => repo.id === id)
|
||||
if (index !== -1) {
|
||||
repos.splice(index, 1)
|
||||
}
|
||||
},
|
||||
getProjects: () => [...projectHostSetupProjectionFromRepos(repos).projects],
|
||||
getProjectHostSetups: () => [...projectHostSetupProjectionFromRepos(repos).setups]
|
||||
}
|
||||
return new OrcaRuntimeService(runtimeStore)
|
||||
}
|
||||
|
||||
async function withGitFolder(
|
||||
remotes: Record<string, string>,
|
||||
run: (path: string) => Promise<void>
|
||||
): Promise<void> {
|
||||
const tempRoot = await mkdtemp(join(tmpdir(), 'orca-runtime-folder-remote-'))
|
||||
try {
|
||||
execFileSync('git', ['init'], { cwd: tempRoot, stdio: 'ignore' })
|
||||
for (const [name, url] of Object.entries(remotes)) {
|
||||
execFileSync('git', ['remote', 'add', name, url], { cwd: tempRoot, stdio: 'ignore' })
|
||||
}
|
||||
await run(tempRoot)
|
||||
} finally {
|
||||
await rm(tempRoot, { recursive: true, force: true })
|
||||
}
|
||||
}
|
||||
|
||||
const repoA = { provider: 'github' as const, owner: 'acme', repo: 'repo-a' }
|
||||
|
||||
describe('OrcaRuntimeService project setup of an existing folder (#30663)', () => {
|
||||
it('refuses to relabel a folder whose own GitHub remote names another repository', async () => {
|
||||
const repos: Repo[] = []
|
||||
const runtime = createRuntime(repos)
|
||||
|
||||
await withGitFolder({ origin: 'https://github.com/acme/repo-b.git' }, async (path) => {
|
||||
await expect(
|
||||
runtime.setupProjectExistingFolder({
|
||||
projectId: 'github:acme/repo-a',
|
||||
projectProviderIdentity: repoA,
|
||||
hostId: 'runtime:env-1',
|
||||
path,
|
||||
kind: 'git'
|
||||
})
|
||||
).rejects.toThrow(/points at acme\/repo-b, not acme\/repo-a/)
|
||||
})
|
||||
|
||||
expect(repos).toHaveLength(0)
|
||||
})
|
||||
|
||||
it('judges an already-registered folder by its current remotes, not the stored ones', async () => {
|
||||
const repos: Repo[] = []
|
||||
const runtime = createRuntime(repos)
|
||||
|
||||
await withGitFolder(
|
||||
{
|
||||
origin: 'https://github.com/me/repo-a-fork.git',
|
||||
upstream: 'https://github.com/acme/repo-a.git'
|
||||
},
|
||||
async (path) => {
|
||||
// Registered before the user added the `upstream` remote the refusal recommends.
|
||||
repos.push({
|
||||
id: 'repo-registered',
|
||||
path: realpathSync(path),
|
||||
displayName: 'repo-a-fork',
|
||||
badgeColor: '#000000',
|
||||
addedAt: 1,
|
||||
kind: 'git',
|
||||
executionHostId: 'runtime:env-1',
|
||||
upstream: null,
|
||||
gitRemoteIdentity: {
|
||||
canonicalKey: 'github.com/me/repo-a-fork',
|
||||
remoteName: 'origin',
|
||||
remoteUrl: 'https://github.com/me/repo-a-fork.git'
|
||||
}
|
||||
})
|
||||
const result = await runtime.setupProjectExistingFolder({
|
||||
projectId: 'github:acme/repo-a',
|
||||
projectProviderIdentity: repoA,
|
||||
hostId: 'runtime:env-1',
|
||||
path,
|
||||
kind: 'git'
|
||||
})
|
||||
expect(result.project.id).toBe('github:acme/repo-a')
|
||||
expect(result.repo.id).toBe('repo-registered')
|
||||
}
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
it('retains matching null authority when a nonfork result settles during setup', async () => {
|
||||
await withGitFolder({ origin: 'https://github.com/me/repo-a.git' }, async (path) => {
|
||||
const repos: Repo[] = []
|
||||
const runtime = createRuntime(repos)
|
||||
const gate = Promise.withResolvers<forkMetadata.RepoUpstreamProbe>()
|
||||
const started = Promise.withResolvers<void>()
|
||||
parentProbe.mockImplementationOnce(() => {
|
||||
started.resolve()
|
||||
return gate.promise
|
||||
})
|
||||
const setup = runtime.setupProjectExistingFolder({
|
||||
projectId: 'github:me/repo-a',
|
||||
projectProviderIdentity: { provider: 'github', owner: 'me', repo: 'repo-a' },
|
||||
hostId: 'runtime:env-1',
|
||||
path,
|
||||
kind: 'git'
|
||||
})
|
||||
await started.promise
|
||||
execFileSync('git', ['remote', 'set-url', 'origin', 'https://github.com/other/repo-a.git'], {
|
||||
cwd: path,
|
||||
stdio: 'ignore'
|
||||
})
|
||||
gate.resolve({ upstream: null, origin: { owner: 'me', repo: 'repo-a' } })
|
||||
const result = await setup
|
||||
expect(result.project.id).toBe('github:me/repo-a')
|
||||
expect(result.repo.upstream).toBeNull()
|
||||
expect(
|
||||
projectHostSetupProjectionFromRepos(JSON.parse(JSON.stringify(repos))).setups[0].projectId
|
||||
).toBe('github:me/repo-a')
|
||||
})
|
||||
})
|
||||
@@ -1,6 +1,6 @@
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import type { Repo } from '../../../shared/repository/repo-types'
|
||||
import { partialRuntimeStore } from '../orca-runtime-tests/runtime-store-partial-fixture'
|
||||
import { partialRuntimeStore } from '../construction/test-context/runtime-store-partial-fixture'
|
||||
import {
|
||||
probeRepoUpstream,
|
||||
type RepoUpstreamProbe
|
||||
|
||||
+2
-29
@@ -1,7 +1,7 @@
|
||||
import * as gitSpawn from '../../git/command-runner/git-spawn'
|
||||
import { realpath, lstat, mkdir, mkdtemp, rm, writeFile } from 'node:fs/promises'
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import './runtime-test-module-registration.spec'
|
||||
import '../construction/test-context/runtime-test-module-registration.spec'
|
||||
import '../../../shared/repository/appearance/repo-badge-color'
|
||||
import { EventEmitter } from 'node:events'
|
||||
import { OrcaRuntimeService } from '../orca-runtime'
|
||||
@@ -15,7 +15,7 @@ import { join } from 'node:path'
|
||||
import 'node:fs'
|
||||
import '../../../shared/project/host-setup/project-host-setup-projection'
|
||||
import { tmpdir } from 'node:os'
|
||||
import { createRuntime, store } from './orca-runtime-test-fixtures.spec'
|
||||
import { createRuntime, store } from '../construction/test-context/orca-runtime-test-fixtures.spec'
|
||||
import '../../../shared/file-access/cross-platform-path'
|
||||
|
||||
// Clone and create register resolved paths (macOS tmpdir is a /var symlink).
|
||||
@@ -61,33 +61,6 @@ describe('OrcaRuntimeService', () => {
|
||||
}
|
||||
})
|
||||
|
||||
it('removes an owned runtime clone target when git exits unsuccessfully', async () => {
|
||||
const spawnSpy = vi.spyOn(gitSpawn, 'gitSpawnAfterWindowsEnvironmentReady')
|
||||
const proc = new EventEmitter() as EventEmitter & { stderr: EventEmitter }
|
||||
proc.stderr = new EventEmitter()
|
||||
spawnSpy.mockResolvedValue(proc as never)
|
||||
const runtime = createRuntime()
|
||||
const destination = await mkdtempReal(join(tmpdir(), 'orca-runtime-clone-'))
|
||||
const clonePath = join(destination, 'repo-badge-color')
|
||||
|
||||
try {
|
||||
const clonePromise = runtime.cloneRepo(
|
||||
'https://example.com/repo-badge-color.git',
|
||||
destination
|
||||
)
|
||||
await vi.waitFor(() => expect(spawnSpy).toHaveBeenCalledTimes(1))
|
||||
await writeFile(join(clonePath, 'partial.txt'), 'git wrote this before failing')
|
||||
proc.stderr.emit('data', Buffer.from('fatal: repository not found\n'))
|
||||
proc.emit('close', 128, null)
|
||||
|
||||
await expect(clonePromise).rejects.toThrow('Clone failed: fatal: repository not found')
|
||||
await expect(lstat(clonePath)).rejects.toThrow()
|
||||
} finally {
|
||||
spawnSpy.mockRestore()
|
||||
await rm(destination, { recursive: true, force: true })
|
||||
}
|
||||
})
|
||||
|
||||
it('preserves an existing runtime clone target when git exits unsuccessfully', async () => {
|
||||
const spawnSpy = vi.spyOn(gitSpawn, 'gitSpawnAfterWindowsEnvironmentReady')
|
||||
const proc = new EventEmitter() as EventEmitter & { stderr: EventEmitter }
|
||||
@@ -5,7 +5,7 @@ import { OrcaRuntimeService } from '../orca-runtime'
|
||||
import { findRepoRowForHostScopedWrite } from '../../persistence/tracking-repos/repo-update-operations'
|
||||
import { getRepoExecutionHostId } from '../../../shared/execution-host/execution-host'
|
||||
import type { RepoHostTarget } from '../../../shared/repository/repo-host-identity'
|
||||
import { partialRuntimeStore } from '../orca-runtime-tests/runtime-store-partial-fixture'
|
||||
import { partialRuntimeStore } from '../construction/test-context/runtime-store-partial-fixture'
|
||||
import { withProjectWorktreeCreate } from '../../workspaces/creation/worktree-create-in-flight'
|
||||
|
||||
function registerRuntimeRemoveProjectHostScopeTests(): void {
|
||||
|
||||
@@ -6,7 +6,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import '../../../shared/file-access/cross-platform-path'
|
||||
import type { Repo } from '../../../shared/repository/repo-types'
|
||||
import { RuntimeRepositoryRegistrationController } from './runtime-repository-registration-controller'
|
||||
import { partialRuntimeStore } from '../orca-runtime-tests/runtime-store-partial-fixture'
|
||||
import { partialRuntimeStore } from '../construction/test-context/runtime-store-partial-fixture'
|
||||
|
||||
vi.mock('../../repository-icons/repo-icon-autodetect', () => ({
|
||||
detectRepoLocalMetadata: vi.fn().mockResolvedValue({})
|
||||
|
||||
@@ -7,7 +7,7 @@ import type { WorktreeLineage } from '../../../../../shared/worktree/lineage-typ
|
||||
import type { Repo } from '../../../../../shared/repository/repo-types'
|
||||
import type { WorktreeMeta } from '../../../../../shared/worktree/meta-types'
|
||||
import type { AgentSessionRecordStore } from '../../../agent-session/records/agent-session-record-store'
|
||||
import '../../../orca-runtime-tests/runtime-test-module-registration.spec'
|
||||
import '../../../construction/test-context/runtime-test-module-registration.spec'
|
||||
import { OrcaRuntimeService } from '../../../orca-runtime'
|
||||
import { addWorktree } from '../../../../git/worktrees/creation/worktree-add'
|
||||
import {
|
||||
@@ -18,8 +18,8 @@ import { listWorktrees } from '../../../../git/worktrees/catalog/worktree-scan-c
|
||||
import {
|
||||
store,
|
||||
makeWorktreeMeta
|
||||
} from '../../../orca-runtime-tests/orca-runtime-test-fixtures.spec'
|
||||
import { registerLivePty } from '../../../orca-runtime-tests/bind-first-pane.test-fixture'
|
||||
} from '../../../construction/test-context/orca-runtime-test-fixtures.spec'
|
||||
import { registerLivePty } from '../../../terminal/layout/bind-first-pane.test-fixture'
|
||||
import type { HostWorktreeTarget } from '../../../../../shared/worktree/host-qualified-identity'
|
||||
import { mergeWorktreeMetaForWrite } from '../../../../persistence/loading-store/worktree-metadata/worktree-meta-write-normalization'
|
||||
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { OrcaRuntimeService } from '../../../orca-runtime'
|
||||
import { MACHINE_NAME_PUBLISH_WAIT_MS } from '../../../hosts/platform-probe/runtime-machine-name'
|
||||
import { STATUS_METHODS } from './status'
|
||||
import { partialRuntimeStore } from '../../../orca-runtime-tests/runtime-store-partial-fixture'
|
||||
import { partialRuntimeStore } from '../../../construction/test-context/runtime-store-partial-fixture'
|
||||
|
||||
// Use a fresh process before its memoized scutil lookup completes; control completion to exercise the publish deadline.
|
||||
const runProcessMock = vi.hoisted(() => vi.fn())
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ import '../../../../orchestration/db/dispatch-row-writer'
|
||||
import '../../../../orchestration/db/attempt-outcome-projection'
|
||||
import { ORCHESTRATION_METHODS } from '../orchestration'
|
||||
import { isStreamingMethod, eraseRpcMethods } from '../../../core'
|
||||
import { registerBoundPty } from '../../../../orca-runtime-tests/bind-first-pane.test-fixture'
|
||||
import { registerBoundPty } from '../../../../terminal/layout/bind-first-pane.test-fixture'
|
||||
|
||||
// Host contact loss never proves worker exit; relay only confirmed stops as settled.
|
||||
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ import type { AgentSessionLease } from '../../../../../../shared/agent-session/l
|
||||
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { setStructuredAgentSessionHost } from '../../../../../native-chat/agent-session-wire/host/structured-agent-session-registry'
|
||||
import { partialRuntimeStore } from '../../../../orca-runtime-tests/runtime-store-partial-fixture'
|
||||
import { partialRuntimeStore } from '../../../../construction/test-context/runtime-store-partial-fixture'
|
||||
import { OrcaRuntimeService } from '../../../../orca-runtime'
|
||||
|
||||
import {
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { createOrchestrationWorkerReleaseHarness } from '../testing/worker-release.test-support'
|
||||
import { makePaneKey } from '../../../../../../../shared/workspace-layout/stable-pane-id'
|
||||
import { registerBoundPty } from '../../../../../orca-runtime-tests/bind-first-pane.test-fixture'
|
||||
import { registerBoundPty } from '../../../../../terminal/layout/bind-first-pane.test-fixture'
|
||||
|
||||
export function registerWorkerReleaseRuntimeIncarnationTests(): void {
|
||||
const PTY_ID = 'runtime_test:term_worker'
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ import { STRUCTURED_AGENT_SESSION_METHODS } from './structured-agent-session'
|
||||
import { stopStructuredAgentSessionRuntime } from '../../../agent-session/installation/structured-agent-session-runtime'
|
||||
import { ensureTestStructuredAgentSessionHost as ensureStructuredAgentSessionHost } from '../../../agent-session/records/agent-session-record-store-test-harness'
|
||||
import { createStructuredAgentSessionLogger } from '../../../../native-chat/agent-session-wire/host/structured-agent-session-logger'
|
||||
import { scriptedCodexTransport } from '../../../orca-runtime-tests/scripted-codex-transport.test-fixture'
|
||||
import { scriptedCodexTransport } from '../../../agent-session/testing/scripted-codex-transport.test-fixture'
|
||||
|
||||
export const SESSION = 'session-integration-1'
|
||||
export const THREAD = 'thread-integration'
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
partialRuntimeStore,
|
||||
storeRepo,
|
||||
storeWorktreeMeta
|
||||
} from '../../../orca-runtime-tests/runtime-store-partial-fixture'
|
||||
} from '../../../construction/test-context/runtime-store-partial-fixture'
|
||||
import type { WorktreeMeta } from '../../../../../shared/worktree/meta-types'
|
||||
import type { Repo } from '../../../../../shared/repository/repo-types'
|
||||
import type { HostWorktreeTarget } from '../../../../../shared/worktree/host-qualified-identity'
|
||||
|
||||
@@ -24,7 +24,7 @@ import {
|
||||
waitForWsClose
|
||||
} from '../runtime-rpc-mobile-ws-test-harness'
|
||||
import { makeStore } from '../runtime-rpc-worktree-store-fixtures'
|
||||
import { partialRuntimeStore } from '../../../orca-runtime-tests/runtime-store-partial-fixture'
|
||||
import { partialRuntimeStore } from '../../../construction/test-context/runtime-store-partial-fixture'
|
||||
|
||||
vi.mock('../../../../git/worktrees/catalog/worktree-scan-cache', async (importOriginal) => {
|
||||
const facade = getWorktreeListingMocks()
|
||||
|
||||
@@ -28,7 +28,7 @@ import {
|
||||
createEncryptedWsResponseReader
|
||||
} from './runtime-rpc-mobile-ws-test-harness'
|
||||
import { makeStore } from './runtime-rpc-worktree-store-fixtures'
|
||||
import { committingSpawn } from '../../orca-runtime-tests/bind-first-pane.test-fixture'
|
||||
import { committingSpawn } from '../../terminal/layout/bind-first-pane.test-fixture'
|
||||
|
||||
vi.mock('../../../git/worktrees/catalog/worktree-scan-cache', async (importOriginal) => {
|
||||
const listings = getWorktreeListingMocks()
|
||||
|
||||
+3
-3
@@ -1,16 +1,16 @@
|
||||
import '../../../shared/workspace-layout/layout-owner-switch'
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import './runtime-test-module-registration.spec'
|
||||
import '../construction/test-context/runtime-test-module-registration.spec'
|
||||
import { HEADLESS_RUNTIME_WINDOW_ID } from '../../../shared/remote-runtime/session-graph/runtime-session-contracts'
|
||||
import '../orca-runtime'
|
||||
import { RUNTIME_GRAPH_RELOAD_TIMEOUT_MS } from '../session-graph/runtime-graph-reload-lifecycle'
|
||||
import { RUNTIME_GRAPH_RELOAD_TIMEOUT_MS } from './runtime-graph-reload-lifecycle'
|
||||
import '../orca-runtime-test-mocks/setup.spec'
|
||||
import {
|
||||
HEADLESS_LEAF_ID,
|
||||
TEST_WINDOW_ID,
|
||||
TEST_WORKTREE_ID,
|
||||
createRuntime
|
||||
} from './orca-runtime-test-fixtures.spec'
|
||||
} from '../construction/test-context/orca-runtime-test-fixtures.spec'
|
||||
|
||||
describe('OrcaRuntimeService', () => {
|
||||
it('keeps an earlier committed reload fenced when a later reload is cancelled', async () => {
|
||||
+13
-13
@@ -1,24 +1,24 @@
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import '../../../shared/workspace-layout/layout-owner-switch'
|
||||
import './runtime-test-module-registration.spec'
|
||||
import { OrcaRuntimeService } from '../orca-runtime'
|
||||
import { electronMocks } from '../orca-runtime-test-mocks/setup.spec'
|
||||
import type { SleepingAgentSessionRecord } from '../../../shared/agent-session/lifecycle/agent-session-resume'
|
||||
import '../../../../shared/workspace-layout/layout-owner-switch'
|
||||
import '../../construction/test-context/runtime-test-module-registration.spec'
|
||||
import { OrcaRuntimeService } from '../../orca-runtime'
|
||||
import { electronMocks } from '../../orca-runtime-test-mocks/setup.spec'
|
||||
import type { SleepingAgentSessionRecord } from '../../../../shared/agent-session/lifecycle/agent-session-resume'
|
||||
import {
|
||||
HEADLESS_LEAF_ID,
|
||||
TEST_WINDOW_ID,
|
||||
TEST_WORKTREE_ID,
|
||||
makeRuntimeStoreWithWorkspaceSession,
|
||||
makeWorkspaceSessionWithHeadlessTerminal
|
||||
} from './orca-runtime-test-fixtures.spec'
|
||||
import type { AgentStatusIpcPayload } from '../../../shared/agent-status/contracts/agent-status-ipc-payload'
|
||||
import type { PtyProcessInfo } from '../../providers/pty/process-info'
|
||||
import { deterministicAgentSessionUuid } from '../terminal/launch/runtime-agent-launch-resolution'
|
||||
import { deriveRemoteRuntimeTerminalCreateHandle } from '../terminal/identity/remote-runtime-terminal-create-identity'
|
||||
import type { RuntimePtyController } from '../terminal/lifecycle/runtime-pty-controller-contract'
|
||||
import '../../ipc/pty/host-env/saved-resume-admission'
|
||||
} from '../../construction/test-context/orca-runtime-test-fixtures.spec'
|
||||
import type { AgentStatusIpcPayload } from '../../../../shared/agent-status/contracts/agent-status-ipc-payload'
|
||||
import type { PtyProcessInfo } from '../../../providers/pty/process-info'
|
||||
import { deterministicAgentSessionUuid } from '../../terminal/launch/runtime-agent-launch-resolution'
|
||||
import { deriveRemoteRuntimeTerminalCreateHandle } from '../../terminal/identity/remote-runtime-terminal-create-identity'
|
||||
import type { RuntimePtyController } from '../../terminal/lifecycle/runtime-pty-controller-contract'
|
||||
import '../../../ipc/pty/host-env/saved-resume-admission'
|
||||
import { resumeSpawns } from './agent-resume-spawn-commands.test-fixture'
|
||||
import { agentProviderSessionsEqual } from '../../../shared/agent-session/lifecycle/resume/agent-provider-session-equality'
|
||||
import { agentProviderSessionsEqual } from '../../../../shared/agent-session/lifecycle/resume/agent-provider-session-equality'
|
||||
|
||||
const PANE_KEY = `host-tab:${HEADLESS_LEAF_ID}`
|
||||
const SESSION = { key: 'session_id', id: 'provider-session-1' } as const
|
||||
+3
-3
@@ -28,11 +28,11 @@ vi.mock('../../files/chat-scratch-file-root', async (importOriginal) => ({
|
||||
resolveRuntimeAuthorizedPath: async (path: string) => path
|
||||
}))
|
||||
|
||||
await import('../../orca-runtime-tests/runtime-test-module-registration.spec')
|
||||
await import('../../construction/test-context/runtime-test-module-registration.spec')
|
||||
const { OrcaRuntimeService } = await import('../../orca-runtime')
|
||||
await import('../../orca-runtime-tests/orca-runtime-test-lifecycle.spec')
|
||||
await import('../../construction/test-context/orca-runtime-test-lifecycle.spec')
|
||||
const { TEST_REPO_ID, TEST_WORKTREE_ID, makeRuntimeStoreWithWorkspaceSession, store } =
|
||||
await import('../../orca-runtime-tests/orca-runtime-test-fixtures.spec')
|
||||
await import('../../construction/test-context/orca-runtime-test-fixtures.spec')
|
||||
|
||||
type Runtime = InstanceType<typeof OrcaRuntimeService>
|
||||
|
||||
|
||||
+4
-4
@@ -1,14 +1,14 @@
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import './runtime-test-module-registration.spec'
|
||||
import { OrcaRuntimeService } from '../orca-runtime'
|
||||
import '../../construction/test-context/runtime-test-module-registration.spec'
|
||||
import { OrcaRuntimeService } from '../../orca-runtime'
|
||||
import {
|
||||
HEADLESS_LEAF_ID,
|
||||
TEST_WORKTREE_ID,
|
||||
makeHeadlessTerminalLayout,
|
||||
makeRuntimeStoreWithWorkspaceSession,
|
||||
makeWorkspaceSessionWithHeadlessTerminal
|
||||
} from './orca-runtime-test-fixtures.spec'
|
||||
import { getRuntimeBrowserPageRegistry } from '../browser/client-pages/runtime-browser-page-registry'
|
||||
} from '../../construction/test-context/orca-runtime-test-fixtures.spec'
|
||||
import { getRuntimeBrowserPageRegistry } from '../../browser/client-pages/runtime-browser-page-registry'
|
||||
|
||||
// #25900: empty windowless snapshots hid persisted live agents and stranded clients on Reconnecting.
|
||||
|
||||
+10
-7
@@ -1,12 +1,15 @@
|
||||
import { ORCA_LAYOUT_OWNER_IS_MAIN } from '../../../shared/workspace-layout/layout-owner-switch'
|
||||
import { ORCA_LAYOUT_OWNER_IS_MAIN } from '../../../../shared/workspace-layout/layout-owner-switch'
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import { bindPaneFirst, registerBoundPty } from './bind-first-pane.test-fixture'
|
||||
import './runtime-test-module-registration.spec'
|
||||
import { OrcaRuntimeService } from '../orca-runtime'
|
||||
import { electronMocks } from '../orca-runtime-test-mocks/setup.spec'
|
||||
import { bindPaneFirst, registerBoundPty } from '../../terminal/layout/bind-first-pane.test-fixture'
|
||||
import '../../construction/test-context/runtime-test-module-registration.spec'
|
||||
import { OrcaRuntimeService } from '../../orca-runtime'
|
||||
import { electronMocks } from '../../orca-runtime-test-mocks/setup.spec'
|
||||
import { ipcMain } from 'electron'
|
||||
import { TEST_WORKTREE_ID, store } from './orca-runtime-test-fixtures.spec'
|
||||
import { createMobileCreateTestNotifier } from './orca-runtime-test-scenario-builders.spec'
|
||||
import {
|
||||
TEST_WORKTREE_ID,
|
||||
store
|
||||
} from '../../construction/test-context/orca-runtime-test-fixtures.spec'
|
||||
import { createMobileCreateTestNotifier } from '../../construction/test-context/orca-runtime-test-scenario-builders.spec'
|
||||
|
||||
describe('OrcaRuntimeService', () => {
|
||||
it('does not re-deliver the agent launch command when the adopted renderer PTY spawned with one', async () => {
|
||||
+13
-9
@@ -1,14 +1,18 @@
|
||||
import '../../../shared/workspace-layout/layout-owner-switch'
|
||||
import '../../../../shared/workspace-layout/layout-owner-switch'
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import './bind-first-pane.test-fixture'
|
||||
import './runtime-test-module-registration.spec'
|
||||
import { MOCK_GIT_WORKTREES, electronMocks } from '../orca-runtime-test-mocks/setup.spec'
|
||||
import { OrcaRuntimeService } from '../orca-runtime'
|
||||
import '../browser/client-pages/runtime-browser-page-registry'
|
||||
import '../../terminal/layout/bind-first-pane.test-fixture'
|
||||
import '../../construction/test-context/runtime-test-module-registration.spec'
|
||||
import { MOCK_GIT_WORKTREES, electronMocks } from '../../orca-runtime-test-mocks/setup.spec'
|
||||
import { OrcaRuntimeService } from '../../orca-runtime'
|
||||
import '../../browser/client-pages/runtime-browser-page-registry'
|
||||
import 'electron'
|
||||
import { listWorktrees } from '../../git/worktrees/catalog/worktree-scan-cache'
|
||||
import { TEST_WORKTREE_ID, deferred, store } from './orca-runtime-test-fixtures.spec'
|
||||
import '../../../shared/orca-profiles/constants'
|
||||
import { listWorktrees } from '../../../git/worktrees/catalog/worktree-scan-cache'
|
||||
import {
|
||||
TEST_WORKTREE_ID,
|
||||
deferred,
|
||||
store
|
||||
} from '../../construction/test-context/orca-runtime-test-fixtures.spec'
|
||||
import '../../../../shared/orca-profiles/constants'
|
||||
import './split-placement-session.test-fixture'
|
||||
|
||||
describe('OrcaRuntimeService', () => {
|
||||
+6
-172
@@ -1,16 +1,16 @@
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import { bindPaneFirst, registerBoundPty } from './bind-first-pane.test-fixture'
|
||||
import './runtime-test-module-registration.spec'
|
||||
import { OrcaRuntimeService } from '../orca-runtime'
|
||||
import { electronMocks } from '../orca-runtime-test-mocks/setup.spec'
|
||||
import { bindPaneFirst, registerBoundPty } from '../../terminal/layout/bind-first-pane.test-fixture'
|
||||
import '../../construction/test-context/runtime-test-module-registration.spec'
|
||||
import { OrcaRuntimeService } from '../../orca-runtime'
|
||||
import { electronMocks } from '../../orca-runtime-test-mocks/setup.spec'
|
||||
import { ipcMain } from 'electron'
|
||||
import { ORCA_LAYOUT_OWNER_IS_MAIN } from '../../../shared/workspace-layout/layout-owner-switch'
|
||||
import { ORCA_LAYOUT_OWNER_IS_MAIN } from '../../../../shared/workspace-layout/layout-owner-switch'
|
||||
import {
|
||||
HEADLESS_LEAF_ID,
|
||||
HEADLESS_SECOND_LEAF_ID,
|
||||
TEST_WORKTREE_ID,
|
||||
store
|
||||
} from './orca-runtime-test-fixtures.spec'
|
||||
} from '../../construction/test-context/orca-runtime-test-fixtures.spec'
|
||||
|
||||
describe('OrcaRuntimeService', () => {
|
||||
it('forwards inactive mobile terminal creation to the renderer without focusing it', async () => {
|
||||
@@ -205,170 +205,4 @@ describe('OrcaRuntimeService', () => {
|
||||
: []
|
||||
)
|
||||
})
|
||||
|
||||
it('dedupes concurrent mobile terminal creates that share a clientMutationId', async () => {
|
||||
const runtime = new OrcaRuntimeService(store)
|
||||
runtime.setNotifier({
|
||||
focusTerminal: vi.fn(),
|
||||
worktreesChanged: vi.fn(),
|
||||
reposChanged: vi.fn(),
|
||||
activateWorktree: vi.fn(),
|
||||
createTerminal: vi.fn(),
|
||||
revealTerminalSession: vi.fn(),
|
||||
splitTerminal: vi.fn(),
|
||||
renameTerminal: vi.fn(),
|
||||
closeTerminal: vi.fn(),
|
||||
closeSessionTab: vi.fn(),
|
||||
terminalFitOverrideChanged: vi.fn(),
|
||||
terminalDriverChanged: vi.fn()
|
||||
})
|
||||
const webContents = { send: vi.fn() }
|
||||
const send = vi.fn(async (_channel: string, payload: { requestId: string }) => {
|
||||
await runtime.syncWindowGraph(1, {
|
||||
tabs: [],
|
||||
leaves: [
|
||||
{
|
||||
tabId: 'tab-renderer',
|
||||
worktreeId: TEST_WORKTREE_ID,
|
||||
leafId: 'pane:1',
|
||||
paneRuntimeId: 1,
|
||||
ptyId: 'pty-renderer',
|
||||
paneTitle: null
|
||||
}
|
||||
],
|
||||
mobileSessionTabs: [
|
||||
{
|
||||
worktree: TEST_WORKTREE_ID,
|
||||
publicationEpoch: 'epoch-1',
|
||||
snapshotVersion: 1,
|
||||
activeGroupId: 'group-1',
|
||||
activeTabId: null,
|
||||
activeTabType: null,
|
||||
tabs: [
|
||||
{
|
||||
type: 'terminal',
|
||||
id: 'tab-renderer::pane:1',
|
||||
parentTabId: 'tab-renderer',
|
||||
leafId: 'pane:1',
|
||||
title: 'Terminal',
|
||||
isActive: false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
})
|
||||
ipcMain.emit(
|
||||
'terminal:tabCreateReply',
|
||||
{ sender: webContents },
|
||||
{ requestId: payload.requestId, tabId: 'tab-renderer', title: 'Terminal' }
|
||||
)
|
||||
})
|
||||
webContents.send = send
|
||||
runtime.attachWindow(1)
|
||||
await runtime.syncWindowGraph(1, { tabs: [], leaves: [] })
|
||||
electronMocks.BrowserWindow.fromId.mockReturnValue({
|
||||
isDestroyed: () => false,
|
||||
webContents
|
||||
})
|
||||
|
||||
const [first, second] = await Promise.all([
|
||||
runtime.createMobileSessionTerminal(`id:${TEST_WORKTREE_ID}`, {
|
||||
activate: false,
|
||||
clientMutationId: 'mutation-1'
|
||||
}),
|
||||
runtime.createMobileSessionTerminal(`id:${TEST_WORKTREE_ID}`, {
|
||||
activate: false,
|
||||
clientMutationId: 'mutation-1'
|
||||
})
|
||||
])
|
||||
|
||||
const createRequests = send.mock.calls.filter(
|
||||
([channel]) => channel === 'terminal:requestTabCreate'
|
||||
)
|
||||
expect(createRequests).toHaveLength(1)
|
||||
expect(second).toBe(first)
|
||||
expect(first.tab).toMatchObject({ parentTabId: 'tab-renderer' })
|
||||
})
|
||||
|
||||
it('returns the settled success for a retried clientMutationId whose response was lost', async () => {
|
||||
const runtime = new OrcaRuntimeService(store)
|
||||
runtime.setNotifier({
|
||||
focusTerminal: vi.fn(),
|
||||
worktreesChanged: vi.fn(),
|
||||
reposChanged: vi.fn(),
|
||||
activateWorktree: vi.fn(),
|
||||
createTerminal: vi.fn(),
|
||||
revealTerminalSession: vi.fn(),
|
||||
splitTerminal: vi.fn(),
|
||||
renameTerminal: vi.fn(),
|
||||
closeTerminal: vi.fn(),
|
||||
closeSessionTab: vi.fn(),
|
||||
terminalFitOverrideChanged: vi.fn(),
|
||||
terminalDriverChanged: vi.fn()
|
||||
})
|
||||
const webContents = { send: vi.fn() }
|
||||
const send = vi.fn(async (_channel: string, payload: { requestId: string }) => {
|
||||
await runtime.syncWindowGraph(1, {
|
||||
tabs: [],
|
||||
leaves: [
|
||||
{
|
||||
tabId: 'tab-renderer',
|
||||
worktreeId: TEST_WORKTREE_ID,
|
||||
leafId: 'pane:1',
|
||||
paneRuntimeId: 1,
|
||||
ptyId: 'pty-renderer',
|
||||
paneTitle: null
|
||||
}
|
||||
],
|
||||
mobileSessionTabs: [
|
||||
{
|
||||
worktree: TEST_WORKTREE_ID,
|
||||
publicationEpoch: 'epoch-1',
|
||||
snapshotVersion: 1,
|
||||
activeGroupId: 'group-1',
|
||||
activeTabId: null,
|
||||
activeTabType: null,
|
||||
tabs: [
|
||||
{
|
||||
type: 'terminal',
|
||||
id: 'tab-renderer::pane:1',
|
||||
parentTabId: 'tab-renderer',
|
||||
leafId: 'pane:1',
|
||||
title: 'Terminal',
|
||||
isActive: false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
})
|
||||
ipcMain.emit(
|
||||
'terminal:tabCreateReply',
|
||||
{ sender: webContents },
|
||||
{ requestId: payload.requestId, tabId: 'tab-renderer', title: 'Terminal' }
|
||||
)
|
||||
})
|
||||
webContents.send = send
|
||||
runtime.attachWindow(1)
|
||||
await runtime.syncWindowGraph(1, { tabs: [], leaves: [] })
|
||||
electronMocks.BrowserWindow.fromId.mockReturnValue({
|
||||
isDestroyed: () => false,
|
||||
webContents
|
||||
})
|
||||
|
||||
const first = await runtime.createMobileSessionTerminal(`id:${TEST_WORKTREE_ID}`, {
|
||||
activate: false,
|
||||
clientMutationId: 'mutation-lost-response'
|
||||
})
|
||||
// A retry within the retention window must reuse the terminal when its create reply was lost.
|
||||
const retried = await runtime.createMobileSessionTerminal(`id:${TEST_WORKTREE_ID}`, {
|
||||
activate: false,
|
||||
clientMutationId: 'mutation-lost-response'
|
||||
})
|
||||
|
||||
const createRequests = send.mock.calls.filter(
|
||||
([channel]) => channel === 'terminal:requestTabCreate'
|
||||
)
|
||||
expect(createRequests).toHaveLength(1)
|
||||
expect(retried).toBe(first)
|
||||
})
|
||||
})
|
||||
+10
-7
@@ -1,18 +1,21 @@
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import { committingSpawn, registerBoundPty } from './bind-first-pane.test-fixture'
|
||||
import './runtime-test-module-registration.spec'
|
||||
import { MOCK_GIT_WORKTREES, electronMocks } from '../orca-runtime-test-mocks/setup.spec'
|
||||
import { OrcaRuntimeService } from '../orca-runtime'
|
||||
import {
|
||||
committingSpawn,
|
||||
registerBoundPty
|
||||
} from '../../terminal/layout/bind-first-pane.test-fixture'
|
||||
import '../../construction/test-context/runtime-test-module-registration.spec'
|
||||
import { MOCK_GIT_WORKTREES, electronMocks } from '../../orca-runtime-test-mocks/setup.spec'
|
||||
import { OrcaRuntimeService } from '../../orca-runtime'
|
||||
import { ipcMain } from 'electron'
|
||||
import { listWorktrees } from '../../git/worktrees/catalog/worktree-scan-cache'
|
||||
import { listWorktrees } from '../../../git/worktrees/catalog/worktree-scan-cache'
|
||||
import {
|
||||
TEST_REPO_ID,
|
||||
TEST_WORKTREE_ID,
|
||||
TEST_WORKTREE_PATH,
|
||||
makeWorktreeMeta,
|
||||
store
|
||||
} from './orca-runtime-test-fixtures.spec'
|
||||
import { createMobileCreateTestNotifier } from './orca-runtime-test-scenario-builders.spec'
|
||||
} from '../../construction/test-context/orca-runtime-test-fixtures.spec'
|
||||
import { createMobileCreateTestNotifier } from '../../construction/test-context/orca-runtime-test-scenario-builders.spec'
|
||||
|
||||
describe('OrcaRuntimeService', () => {
|
||||
it('does not dedupe mobile terminal creates across worktrees with the same clientMutationId', async () => {
|
||||
@@ -0,0 +1,145 @@
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import { bindPaneFirst, registerBoundPty } from '../../terminal/layout/bind-first-pane.test-fixture'
|
||||
import { ORCA_LAYOUT_OWNER_IS_MAIN } from '../../../../shared/workspace-layout/layout-owner-switch'
|
||||
import '../../construction/test-context/runtime-test-module-registration.spec'
|
||||
import { electronMocks } from '../../orca-runtime-test-mocks/setup.spec'
|
||||
import { OrcaRuntimeService } from '../../orca-runtime'
|
||||
import '../../../browser/agent-browser/agent-browser-bridge'
|
||||
|
||||
import '../../../git/worktrees/removal/worktree-removal-preflight'
|
||||
import { ipcMain } from 'electron'
|
||||
import '../../../git/worktrees/catalog/worktree-scan-cache'
|
||||
import '../../../git/worktrees/removal/worktree-removal'
|
||||
import {
|
||||
TEST_WORKTREE_ID,
|
||||
store
|
||||
} from '../../construction/test-context/orca-runtime-test-fixtures.spec'
|
||||
import { createMobileCreateTestNotifier } from '../../construction/test-context/orca-runtime-test-scenario-builders.spec'
|
||||
|
||||
describe('OrcaRuntimeService', () => {
|
||||
describe('mobile terminal create resilience (#7718)', () => {
|
||||
it('cancels the surface wait without rolling back when the client connection dies', async () => {
|
||||
vi.useFakeTimers()
|
||||
try {
|
||||
const closeTerminal = vi.fn()
|
||||
const runtime = new OrcaRuntimeService(store)
|
||||
runtime.setNotifier(createMobileCreateTestNotifier(closeTerminal))
|
||||
const abort = new AbortController()
|
||||
const webContents = { send: vi.fn() }
|
||||
const send = vi.fn((_channel: string, payload: { requestId: string }) => {
|
||||
ipcMain.emit(
|
||||
'terminal:tabCreateReply',
|
||||
{ sender: webContents },
|
||||
{ requestId: payload.requestId, tabId: 'tab-abort', title: 'Terminal' }
|
||||
)
|
||||
})
|
||||
webContents.send = send
|
||||
runtime.attachWindow(1)
|
||||
await runtime.syncWindowGraph(1, { tabs: [], leaves: [] })
|
||||
electronMocks.BrowserWindow.fromId.mockReturnValue({
|
||||
isDestroyed: () => false,
|
||||
webContents
|
||||
})
|
||||
|
||||
const create = runtime.createMobileSessionTerminal(`id:${TEST_WORKTREE_ID}`, {
|
||||
activate: false,
|
||||
signal: abort.signal
|
||||
})
|
||||
const settled = create.then(
|
||||
() => ({ ok: true as const }),
|
||||
(error: Error) => ({ ok: false as const, error })
|
||||
)
|
||||
await vi.waitFor(() => expect(send).toHaveBeenCalledTimes(1))
|
||||
|
||||
// Disconnect must settle promptly without closing the real terminal.
|
||||
abort.abort()
|
||||
await vi.advanceTimersByTimeAsync(0)
|
||||
const outcome = await settled
|
||||
|
||||
expect(outcome.ok).toBe(false)
|
||||
if (outcome.ok === false) {
|
||||
expect(outcome.error.message).toBe('client_disconnected')
|
||||
}
|
||||
expect(closeTerminal).not.toHaveBeenCalled()
|
||||
} finally {
|
||||
vi.useRealTimers()
|
||||
}
|
||||
})
|
||||
|
||||
it('keeps a mobile-created terminal alive when its live shell has no registered pane key', async () => {
|
||||
vi.useFakeTimers()
|
||||
try {
|
||||
const closeTerminal = vi.fn()
|
||||
const runtime = new OrcaRuntimeService(store)
|
||||
runtime.setNotifier(createMobileCreateTestNotifier(closeTerminal))
|
||||
const webContents = { send: vi.fn() }
|
||||
const send = vi.fn((_channel: string, payload: { requestId: string }) => {
|
||||
ipcMain.emit(
|
||||
'terminal:tabCreateReply',
|
||||
{ sender: webContents },
|
||||
{ requestId: payload.requestId, tabId: 'tab-stall', title: 'Terminal' }
|
||||
)
|
||||
})
|
||||
webContents.send = send
|
||||
runtime.attachWindow(1)
|
||||
await runtime.syncWindowGraph(1, { tabs: [], leaves: [] })
|
||||
electronMocks.BrowserWindow.fromId.mockReturnValue({
|
||||
isDestroyed: () => false,
|
||||
webContents
|
||||
})
|
||||
|
||||
const create = runtime.createMobileSessionTerminal(`id:${TEST_WORKTREE_ID}`, {
|
||||
activate: false
|
||||
})
|
||||
const settled = create.then(
|
||||
() => ({ ok: true as const }),
|
||||
(error: Error) => ({ ok: false as const, error })
|
||||
)
|
||||
await vi.waitFor(() => expect(send).toHaveBeenCalledTimes(1))
|
||||
|
||||
// Main-owned layouts require the spawn's binding; a renderer leaf cannot vouch for a live PTY.
|
||||
if (ORCA_LAYOUT_OWNER_IS_MAIN) {
|
||||
registerBoundPty(runtime, 'pty-stall', TEST_WORKTREE_ID, null, {
|
||||
tabId: 'tab-stall',
|
||||
leafId: '88888888-8888-4888-8888-888888888888'
|
||||
})
|
||||
await vi.advanceTimersByTimeAsync(50)
|
||||
expect(await settled).toEqual({ ok: true })
|
||||
expect(closeTerminal).not.toHaveBeenCalled()
|
||||
return
|
||||
}
|
||||
// A live shell exists, but stalled renderer publication never registered its pane key.
|
||||
bindPaneFirst(runtime, {
|
||||
worktreeId: TEST_WORKTREE_ID,
|
||||
tabId: 'tab-stall',
|
||||
leafId: 'pane:1',
|
||||
ptyId: 'pty-stall'
|
||||
})
|
||||
await runtime.syncWindowGraph(1, {
|
||||
tabs: [],
|
||||
leaves: [
|
||||
{
|
||||
tabId: 'tab-stall',
|
||||
worktreeId: TEST_WORKTREE_ID,
|
||||
leafId: 'pane:1',
|
||||
paneRuntimeId: 1,
|
||||
ptyId: 'pty-stall',
|
||||
paneTitle: null
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
await vi.advanceTimersByTimeAsync(11_000)
|
||||
const outcome = await settled
|
||||
|
||||
expect(outcome.ok).toBe(false)
|
||||
if (outcome.ok === false) {
|
||||
expect(outcome.error.message).toContain('Timed out')
|
||||
}
|
||||
expect(closeTerminal).not.toHaveBeenCalled()
|
||||
} finally {
|
||||
vi.useRealTimers()
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
import { getDefaultWorkspaceSession } from '../../../shared/orca-profiles/constants'
|
||||
import { getDefaultWorkspaceSession } from '../../../../shared/orca-profiles/constants'
|
||||
import {
|
||||
TEST_WORKTREE_ID,
|
||||
makeRuntimeStoreWithWorkspaceSession
|
||||
} from './orca-runtime-test-fixtures.spec'
|
||||
} from '../../construction/test-context/orca-runtime-test-fixtures.spec'
|
||||
|
||||
export const LEFT_LEAF = '51515151-5151-4151-8151-515151515151'
|
||||
export const RIGHT_LEAF = '52525252-5252-4252-8252-525252525252'
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
import { expect, vi } from 'vitest'
|
||||
import type { RuntimeMobileSessionTabsResult } from '../../../shared/remote-runtime/session-graph/runtime-session-contracts'
|
||||
import type { RuntimeMobileSessionTabsResult } from '../../../../shared/remote-runtime/session-graph/runtime-session-contracts'
|
||||
|
||||
export async function waitForMobileSessionTabsEvents(
|
||||
events: RuntimeMobileSessionTabsResult[],
|
||||
+9
-6
@@ -1,11 +1,14 @@
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import { committingSpawn } from './bind-first-pane.test-fixture'
|
||||
import './runtime-test-module-registration.spec'
|
||||
import { OrcaRuntimeService } from '../orca-runtime'
|
||||
import '../orca-runtime-test-mocks/setup.spec'
|
||||
import { committingSpawn } from '../../terminal/layout/bind-first-pane.test-fixture'
|
||||
import '../../construction/test-context/runtime-test-module-registration.spec'
|
||||
import { OrcaRuntimeService } from '../../orca-runtime'
|
||||
import '../../orca-runtime-test-mocks/setup.spec'
|
||||
import { waitForMobileSessionTabsEvents } from './mobile-session-tab-event-wait'
|
||||
import type { RuntimeMobileSessionTabsResult } from '../../../shared/remote-runtime/session-graph/runtime-session-contracts'
|
||||
import { TEST_WORKTREE_ID, store } from './orca-runtime-test-fixtures.spec'
|
||||
import type { RuntimeMobileSessionTabsResult } from '../../../../shared/remote-runtime/session-graph/runtime-session-contracts'
|
||||
import {
|
||||
TEST_WORKTREE_ID,
|
||||
store
|
||||
} from '../../construction/test-context/orca-runtime-test-fixtures.spec'
|
||||
|
||||
describe('OrcaRuntimeService', () => {
|
||||
it('keeps the activated headless tab active across PTY republishes (serve focus-jump regression)', async () => {
|
||||
+12
-9
@@ -1,14 +1,17 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import './bind-first-pane.test-fixture'
|
||||
import '../terminal/layout/profile-session-store.test-fixture'
|
||||
import '../__fixtures__/main-layout-close-fixture'
|
||||
import './runtime-test-module-registration.spec'
|
||||
import { OrcaRuntimeService } from '../orca-runtime'
|
||||
import '../orca-runtime-test-mocks/setup.spec'
|
||||
import '../../../shared/orca-profiles/constants'
|
||||
import '../../terminal/layout/bind-first-pane.test-fixture'
|
||||
import '../../terminal/layout/profile-session-store.test-fixture'
|
||||
import '../../__fixtures__/main-layout-close-fixture'
|
||||
import '../../construction/test-context/runtime-test-module-registration.spec'
|
||||
import { OrcaRuntimeService } from '../../orca-runtime'
|
||||
import '../../orca-runtime-test-mocks/setup.spec'
|
||||
import '../../../../shared/orca-profiles/constants'
|
||||
|
||||
import { TEST_WORKTREE_ID, store } from './orca-runtime-test-fixtures.spec'
|
||||
import '../../../shared/worktree/host-qualified-identity'
|
||||
import {
|
||||
TEST_WORKTREE_ID,
|
||||
store
|
||||
} from '../../construction/test-context/orca-runtime-test-fixtures.spec'
|
||||
import '../../../../shared/worktree/host-qualified-identity'
|
||||
|
||||
describe('OrcaRuntimeService', () => {
|
||||
it('keeps published mobile terminal handles usable across renderer graph epochs', async () => {
|
||||
+6
-6
@@ -1,8 +1,8 @@
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import './runtime-test-module-registration.spec'
|
||||
import { OrcaRuntimeService } from '../orca-runtime'
|
||||
import '../orca-runtime-test-mocks/setup.spec'
|
||||
import '../../../shared/orca-profiles/constants'
|
||||
import '../../construction/test-context/runtime-test-module-registration.spec'
|
||||
import { OrcaRuntimeService } from '../../orca-runtime'
|
||||
import '../../orca-runtime-test-mocks/setup.spec'
|
||||
import '../../../../shared/orca-profiles/constants'
|
||||
|
||||
import {
|
||||
HEADLESS_LEAF_ID,
|
||||
@@ -10,8 +10,8 @@ import {
|
||||
makeHeadlessTerminalLayout,
|
||||
makeRuntimeStoreWithWorkspaceSession,
|
||||
makeWorkspaceSessionWithHeadlessTerminal
|
||||
} from './orca-runtime-test-fixtures.spec'
|
||||
import '../../../shared/worktree/host-qualified-identity'
|
||||
} from '../../construction/test-context/orca-runtime-test-fixtures.spec'
|
||||
import '../../../../shared/worktree/host-qualified-identity'
|
||||
|
||||
describe('OrcaRuntimeService', () => {
|
||||
it('refreshes stale daemon liveness before phone-local terminal materialization', async () => {
|
||||
+10
-10
@@ -1,9 +1,9 @@
|
||||
import type { RuntimeMobileSessionTabsResult } from '../../../shared/remote-runtime/session-graph/runtime-session-contracts'
|
||||
import type { RuntimeMobileSessionTabsResult } from '../../../../shared/remote-runtime/session-graph/runtime-session-contracts'
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import './runtime-test-module-registration.spec'
|
||||
import { OrcaRuntimeService } from '../orca-runtime'
|
||||
import '../orca-runtime-test-mocks/setup.spec'
|
||||
import { getDefaultWorkspaceSession } from '../../../shared/orca-profiles/constants'
|
||||
import '../../construction/test-context/runtime-test-module-registration.spec'
|
||||
import { OrcaRuntimeService } from '../../orca-runtime'
|
||||
import '../../orca-runtime-test-mocks/setup.spec'
|
||||
import { getDefaultWorkspaceSession } from '../../../../shared/orca-profiles/constants'
|
||||
|
||||
import {
|
||||
HEADLESS_LEAF_ID,
|
||||
@@ -13,11 +13,11 @@ import {
|
||||
makeHeadlessTerminalLayout,
|
||||
makeWorkspaceSessionWithHeadlessTerminal,
|
||||
store
|
||||
} from './orca-runtime-test-fixtures.spec'
|
||||
import './orca-runtime-test-scenario-builders.spec'
|
||||
import '../../agent-launch/agent-launch-pane-attachment'
|
||||
import '../../../shared/workspace-layout/stable-pane-id'
|
||||
import '../../../shared/workspace-layout/layout-owner-switch'
|
||||
} from '../../construction/test-context/orca-runtime-test-fixtures.spec'
|
||||
import '../../construction/test-context/orca-runtime-test-scenario-builders.spec'
|
||||
import '../../../agent-launch/agent-launch-pane-attachment'
|
||||
import '../../../../shared/workspace-layout/stable-pane-id'
|
||||
import '../../../../shared/workspace-layout/layout-owner-switch'
|
||||
|
||||
describe('OrcaRuntimeService', () => {
|
||||
it('publishes a recovered SSH pane when its relay becomes ready after an empty restart replay', async () => {
|
||||
+9
-9
@@ -1,12 +1,12 @@
|
||||
import './runtime-durable-store-fixture'
|
||||
import '../../construction/test-context/runtime-durable-store-fixture'
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import '../__fixtures__/main-layout-close-fixture'
|
||||
import { ORCA_LAYOUT_OWNER_IS_MAIN } from '../../../shared/workspace-layout/layout-owner-switch'
|
||||
import './bind-first-pane.test-fixture'
|
||||
import '../../__fixtures__/main-layout-close-fixture'
|
||||
import { ORCA_LAYOUT_OWNER_IS_MAIN } from '../../../../shared/workspace-layout/layout-owner-switch'
|
||||
import '../../terminal/layout/bind-first-pane.test-fixture'
|
||||
|
||||
import './runtime-test-module-registration.spec'
|
||||
import { OrcaRuntimeService } from '../orca-runtime'
|
||||
import { electronMocks } from '../orca-runtime-test-mocks/setup.spec'
|
||||
import '../../construction/test-context/runtime-test-module-registration.spec'
|
||||
import { OrcaRuntimeService } from '../../orca-runtime'
|
||||
import { electronMocks } from '../../orca-runtime-test-mocks/setup.spec'
|
||||
import {
|
||||
HEADLESS_LEAF_ID,
|
||||
HEADLESS_SECOND_LEAF_ID,
|
||||
@@ -15,8 +15,8 @@ import {
|
||||
makeHeadlessTerminalLayout,
|
||||
makeRuntimeStoreWithWorkspaceSession,
|
||||
makeWorkspaceSessionWithHeadlessTerminal
|
||||
} from './orca-runtime-test-fixtures.spec'
|
||||
import { makePendingAgentTabActivationRuntime } from './orca-runtime-test-scenario-builders.spec'
|
||||
} from '../../construction/test-context/orca-runtime-test-fixtures.spec'
|
||||
import { makePendingAgentTabActivationRuntime } from '../../construction/test-context/orca-runtime-test-scenario-builders.spec'
|
||||
|
||||
describe('OrcaRuntimeService', () => {
|
||||
it('falls back to a plain shell when the pending tab agent is disabled', async () => {
|
||||
+6
-49
@@ -1,16 +1,16 @@
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import './runtime-test-module-registration.spec'
|
||||
import { OrcaRuntimeService } from '../orca-runtime'
|
||||
import { electronMocks } from '../orca-runtime-test-mocks/setup.spec'
|
||||
import type { SleepingAgentSessionRecord } from '../../../shared/agent-session/lifecycle/agent-session-resume'
|
||||
import '../../construction/test-context/runtime-test-module-registration.spec'
|
||||
import { OrcaRuntimeService } from '../../orca-runtime'
|
||||
import { electronMocks } from '../../orca-runtime-test-mocks/setup.spec'
|
||||
import type { SleepingAgentSessionRecord } from '../../../../shared/agent-session/lifecycle/agent-session-resume'
|
||||
import {
|
||||
HEADLESS_LEAF_ID,
|
||||
TEST_WINDOW_ID,
|
||||
TEST_WORKTREE_ID,
|
||||
makeRuntimeStoreWithWorkspaceSession,
|
||||
makeWorkspaceSessionWithHeadlessTerminal
|
||||
} from './orca-runtime-test-fixtures.spec'
|
||||
import type { RuntimeStore } from '../construction/runtime-store-contract'
|
||||
} from '../../construction/test-context/orca-runtime-test-fixtures.spec'
|
||||
import type { RuntimeStore } from '../../construction/runtime-store-contract'
|
||||
|
||||
const PANE_KEY = `host-tab:${HEADLESS_LEAF_ID}`
|
||||
// Pane-owned captures must not be resumed twice (#11598).
|
||||
@@ -44,15 +44,6 @@ function makeWorkingSleepStore(overrides: Partial<SleepingAgentSessionRecord> =
|
||||
return fixture
|
||||
}
|
||||
|
||||
function withClaudeLaunchedTab(fixture: ReturnType<typeof makeWorkingSleepStore>): void {
|
||||
const session = structuredClone(fixture.getSession())
|
||||
const tab = session.tabsByWorktree[TEST_WORKTREE_ID]?.[0]
|
||||
if (tab) {
|
||||
tab.launchAgent = 'claude'
|
||||
}
|
||||
fixture.setSession(session)
|
||||
}
|
||||
|
||||
async function openPane(
|
||||
runtimeStore: RuntimeStore,
|
||||
windowStatus: 'blocked' | 'openable',
|
||||
@@ -107,40 +98,6 @@ function spawnedCommand(spawn: ReturnType<typeof vi.fn>, call = 0): string {
|
||||
|
||||
describe('opening a workspace-slept running agent on a host with no window', () => {
|
||||
// A restart that loses the PTY still needs the saved resume flags.
|
||||
it('still resumes with the recorded flags after a host restart loses the PTY', async () => {
|
||||
const fixture = makeWorkingSleepStore({
|
||||
launchConfig: { agentArgs: '--permission-mode plan', agentEnv: {} }
|
||||
})
|
||||
withClaudeLaunchedTab(fixture)
|
||||
await (
|
||||
await openPane(fixture.runtimeStore, 'openable')
|
||||
).opened
|
||||
|
||||
const restarted = await openPane(fixture.runtimeStore, 'openable')
|
||||
await restarted.opened
|
||||
const command = spawnedCommand(restarted.spawn)
|
||||
expect(command).toContain('provider-session-1')
|
||||
expect(command).toMatch(/--permission-mode'? '?plan/)
|
||||
expect(command).not.toContain('--dangerously-skip-permissions')
|
||||
})
|
||||
|
||||
it('resumes from both of two overlapping opens of the pane, never a plain shell', async () => {
|
||||
const fixture = makeWorkingSleepStore()
|
||||
withClaudeLaunchedTab(fixture)
|
||||
const { opened, spawn, runtime } = await openPane(fixture.runtimeStore, 'openable')
|
||||
const second = runtime.activateMobileSessionTab(
|
||||
`id:${TEST_WORKTREE_ID}`,
|
||||
'host-tab',
|
||||
HEADLESS_LEAF_ID,
|
||||
{ notifyClients: false, navigation: 'caller', intent: 'user' }
|
||||
)
|
||||
|
||||
await Promise.allSettled([opened, second])
|
||||
expect(spawn).toHaveBeenCalled()
|
||||
for (let call = 0; call < spawn.mock.calls.length; call += 1) {
|
||||
expect(spawnedCommand(spawn, call)).toContain('provider-session-1')
|
||||
}
|
||||
})
|
||||
|
||||
it('keeps the record for the next open when the pane resume fails to spawn', async () => {
|
||||
const fixture = makeWorkingSleepStore()
|
||||
+4
-4
@@ -1,7 +1,7 @@
|
||||
import type { AdoptStablePaneArgs } from '../../ipc/pty/ipc/spawn-types'
|
||||
import type { AdoptStablePaneArgs } from '../../../ipc/pty/ipc/spawn-types'
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import './runtime-test-module-registration.spec'
|
||||
import { OrcaRuntimeService } from '../orca-runtime'
|
||||
import '../../construction/test-context/runtime-test-module-registration.spec'
|
||||
import { OrcaRuntimeService } from '../../orca-runtime'
|
||||
import {
|
||||
HEADLESS_LEAF_ID,
|
||||
HEADLESS_SECOND_LEAF_ID,
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
makeHeadlessTerminalLayout,
|
||||
makeRuntimeStoreWithWorkspaceSession,
|
||||
makeWorkspaceSessionWithHeadlessTerminal
|
||||
} from './orca-runtime-test-fixtures.spec'
|
||||
} from '../../construction/test-context/orca-runtime-test-fixtures.spec'
|
||||
|
||||
async function startSplitHost() {
|
||||
const { runtimeStore, getSession } = makeRuntimeStoreWithWorkspaceSession(
|
||||
+9
-9
@@ -1,11 +1,11 @@
|
||||
import './runtime-durable-store-fixture'
|
||||
import '../../construction/test-context/runtime-durable-store-fixture'
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import './bind-first-pane.test-fixture'
|
||||
import './runtime-test-module-registration.spec'
|
||||
import { OrcaRuntimeService } from '../orca-runtime'
|
||||
import { electronMocks } from '../orca-runtime-test-mocks/setup.spec'
|
||||
import './mobile-session-tab-event-wait'
|
||||
import { getDefaultWorkspaceSession } from '../../../shared/orca-profiles/constants'
|
||||
import '../../terminal/layout/bind-first-pane.test-fixture'
|
||||
import '../../construction/test-context/runtime-test-module-registration.spec'
|
||||
import { OrcaRuntimeService } from '../../orca-runtime'
|
||||
import { electronMocks } from '../../orca-runtime-test-mocks/setup.spec'
|
||||
import '../publication/mobile-session-tab-event-wait'
|
||||
import { getDefaultWorkspaceSession } from '../../../../shared/orca-profiles/constants'
|
||||
import 'node:path'
|
||||
import 'node:fs/promises'
|
||||
import 'node:os'
|
||||
@@ -17,8 +17,8 @@ import {
|
||||
TEST_WORKTREE_PATH,
|
||||
makeHeadlessTerminalLayout,
|
||||
makeRuntimeStoreWithWorkspaceSession
|
||||
} from './orca-runtime-test-fixtures.spec'
|
||||
import '../terminal/launch/spawned-pty-env-fixtures'
|
||||
} from '../../construction/test-context/orca-runtime-test-fixtures.spec'
|
||||
import '../../terminal/launch/spawned-pty-env-fixtures'
|
||||
|
||||
describe('OrcaRuntimeService', () => {
|
||||
it('keeps a live headed runtime-owned tab until its explicit close', async () => {
|
||||
+12
-9
@@ -1,12 +1,15 @@
|
||||
import { withDurableRuntimeStore } from './runtime-durable-store-fixture'
|
||||
import '../__fixtures__/main-layout-close-fixture'
|
||||
import { withDurableRuntimeStore } from '../../construction/test-context/runtime-durable-store-fixture'
|
||||
import '../../__fixtures__/main-layout-close-fixture'
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import { ORCA_LAYOUT_OWNER_IS_MAIN } from '../../../shared/workspace-layout/layout-owner-switch'
|
||||
import { committingSpawn, registerLivePty } from './bind-first-pane.test-fixture'
|
||||
import './runtime-test-module-registration.spec'
|
||||
import { OrcaRuntimeService } from '../orca-runtime'
|
||||
import { electronMocks } from '../orca-runtime-test-mocks/setup.spec'
|
||||
import type { RuntimeMobileSessionTabsResult } from '../../../shared/remote-runtime/session-graph/runtime-session-contracts'
|
||||
import { ORCA_LAYOUT_OWNER_IS_MAIN } from '../../../../shared/workspace-layout/layout-owner-switch'
|
||||
import {
|
||||
committingSpawn,
|
||||
registerLivePty
|
||||
} from '../../terminal/layout/bind-first-pane.test-fixture'
|
||||
import '../../construction/test-context/runtime-test-module-registration.spec'
|
||||
import { OrcaRuntimeService } from '../../orca-runtime'
|
||||
import { electronMocks } from '../../orca-runtime-test-mocks/setup.spec'
|
||||
import type { RuntimeMobileSessionTabsResult } from '../../../../shared/remote-runtime/session-graph/runtime-session-contracts'
|
||||
import {
|
||||
HEADLESS_LEAF_ID,
|
||||
TEST_WORKTREE_ID,
|
||||
@@ -14,7 +17,7 @@ import {
|
||||
makeRuntimeStoreWithWorkspaceSession,
|
||||
makeWorkspaceSessionWithHeadlessTerminal,
|
||||
store
|
||||
} from './orca-runtime-test-fixtures.spec'
|
||||
} from '../../construction/test-context/orca-runtime-test-fixtures.spec'
|
||||
|
||||
describe('OrcaRuntimeService', () => {
|
||||
it('uses fresh PTY management titles over stale mobile snapshot and OSC titles', async () => {
|
||||
+6
-6
@@ -1,12 +1,12 @@
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import { registerLivePty } from './bind-first-pane.test-fixture'
|
||||
import './runtime-test-module-registration.spec'
|
||||
import { OrcaRuntimeService } from '../orca-runtime'
|
||||
import { ORCA_LAYOUT_OWNER_IS_MAIN } from '../../../shared/workspace-layout/layout-owner-switch'
|
||||
import { registerLivePty } from '../../terminal/layout/bind-first-pane.test-fixture'
|
||||
import '../../construction/test-context/runtime-test-module-registration.spec'
|
||||
import { OrcaRuntimeService } from '../../orca-runtime'
|
||||
import { ORCA_LAYOUT_OWNER_IS_MAIN } from '../../../../shared/workspace-layout/layout-owner-switch'
|
||||
import {
|
||||
expectDesktopDropsPane,
|
||||
expectDesktopDropsTab
|
||||
} from '../__fixtures__/main-layout-close-fixture'
|
||||
} from '../../__fixtures__/main-layout-close-fixture'
|
||||
import {
|
||||
HEADLESS_LEAF_ID,
|
||||
HEADLESS_SECOND_LEAF_ID,
|
||||
@@ -14,7 +14,7 @@ import {
|
||||
makeHeadlessTerminalLayout,
|
||||
makeRuntimeStoreWithWorkspaceSession,
|
||||
makeWorkspaceSessionWithHeadlessTerminal
|
||||
} from './orca-runtime-test-fixtures.spec'
|
||||
} from '../../construction/test-context/orca-runtime-test-fixtures.spec'
|
||||
|
||||
describe('OrcaRuntimeService', () => {
|
||||
it('rejects missing requested split leaves instead of activating a sibling', async () => {
|
||||
+6
-19
@@ -1,9 +1,9 @@
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import { ORCA_LAYOUT_OWNER_IS_MAIN } from '../../../shared/workspace-layout/layout-owner-switch'
|
||||
import { registerLivePty } from './bind-first-pane.test-fixture'
|
||||
import './runtime-test-module-registration.spec'
|
||||
import { OrcaRuntimeService } from '../orca-runtime'
|
||||
import type { WorkspaceSessionState } from '../../../shared/workspace-session/workspace-session-state-types'
|
||||
import { ORCA_LAYOUT_OWNER_IS_MAIN } from '../../../../shared/workspace-layout/layout-owner-switch'
|
||||
import { registerLivePty } from '../../terminal/layout/bind-first-pane.test-fixture'
|
||||
import '../../construction/test-context/runtime-test-module-registration.spec'
|
||||
import { OrcaRuntimeService } from '../../orca-runtime'
|
||||
import type { WorkspaceSessionState } from '../../../../shared/workspace-session/workspace-session-state-types'
|
||||
import {
|
||||
HEADLESS_LEAF_ID,
|
||||
HEADLESS_SECOND_LEAF_ID,
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
makeHeadlessTerminalLayout,
|
||||
makeRuntimeStoreWithWorkspaceSession,
|
||||
makeWorkspaceSessionWithHeadlessTerminal
|
||||
} from './orca-runtime-test-fixtures.spec'
|
||||
} from '../../construction/test-context/orca-runtime-test-fixtures.spec'
|
||||
|
||||
describe('OrcaRuntimeService', () => {
|
||||
describe('close intent adjudication', () => {
|
||||
@@ -377,19 +377,6 @@ describe('OrcaRuntimeService', () => {
|
||||
expect(getSession().terminalLayoutsByTabId['host-tab']).toBeDefined()
|
||||
})
|
||||
|
||||
it('still kills a live split leaf for an explicit user close', async () => {
|
||||
const { runtime, kill } = await makeSplitLeafRuntime()
|
||||
|
||||
await runtime.closeMobileSessionTab(
|
||||
`id:${TEST_WORKTREE_ID}`,
|
||||
`host-tab::${HEADLESS_SECOND_LEAF_ID}`,
|
||||
{ reason: 'user' }
|
||||
)
|
||||
|
||||
expect(kill).toHaveBeenCalledWith('serve-right')
|
||||
expect(kill).not.toHaveBeenCalledWith('serve-left')
|
||||
})
|
||||
|
||||
it('refuses without republishing when the echoed leaf is dead but a sibling is live', async () => {
|
||||
// Refusing a dead split leaf must not republish it into a refuse/republish/echo loop.
|
||||
const { runtime, getSession, kill, closeTerminal, exitShell } = await makeSplitLeafRuntime()
|
||||
@@ -17,7 +17,7 @@ import {
|
||||
storeRepo,
|
||||
storeWorktreeMeta,
|
||||
type PartialRuntimeStore
|
||||
} from '../../orca-runtime-tests/runtime-store-partial-fixture'
|
||||
} from '../../construction/test-context/runtime-store-partial-fixture'
|
||||
import type { WorktreeMeta } from '../../../../shared/worktree/meta-types'
|
||||
import type { FolderWorkspace } from '../../../../shared/folder-workspaces/folder-workspace-types'
|
||||
|
||||
|
||||
+9
-9
@@ -1,12 +1,12 @@
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import './bind-first-pane.test-fixture'
|
||||
import { makeAgentStatusStoreWiring } from '../terminal/identity/agent-status-store-wiring.test-fixture'
|
||||
import './runtime-test-module-registration.spec'
|
||||
import '../../../shared/agent-status/contracts/agent-status-freshness'
|
||||
import { MOCK_GIT_WORKTREES } from '../orca-runtime-test-mocks/setup.spec'
|
||||
import { OrcaRuntimeService } from '../orca-runtime'
|
||||
import { getDefaultWorkspaceSession } from '../../../shared/orca-profiles/constants'
|
||||
import { listWorktrees } from '../../git/worktrees/catalog/worktree-scan-cache'
|
||||
import '../../terminal/layout/bind-first-pane.test-fixture'
|
||||
import { makeAgentStatusStoreWiring } from '../../terminal/identity/agent-status-store-wiring.test-fixture'
|
||||
import '../../construction/test-context/runtime-test-module-registration.spec'
|
||||
import '../../../../shared/agent-status/contracts/agent-status-freshness'
|
||||
import { MOCK_GIT_WORKTREES } from '../../orca-runtime-test-mocks/setup.spec'
|
||||
import { OrcaRuntimeService } from '../../orca-runtime'
|
||||
import { getDefaultWorkspaceSession } from '../../../../shared/orca-profiles/constants'
|
||||
import { listWorktrees } from '../../../git/worktrees/catalog/worktree-scan-cache'
|
||||
import {
|
||||
HEADLESS_LEAF_ID,
|
||||
TEST_REPO_ID,
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
makeWorkspaceSessionWithHeadlessTerminal,
|
||||
makeWorktreeMeta,
|
||||
store
|
||||
} from './orca-runtime-test-fixtures.spec'
|
||||
} from '../../construction/test-context/orca-runtime-test-fixtures.spec'
|
||||
|
||||
describe('OrcaRuntimeService', () => {
|
||||
it('suppresses restored-unconfirmed hook rows from worktree.ps', async () => {
|
||||
+9
-9
@@ -1,19 +1,19 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import './bind-first-pane.test-fixture'
|
||||
import '../terminal/identity/agent-status-store-wiring.test-fixture'
|
||||
import './runtime-test-module-registration.spec'
|
||||
import { OrcaRuntimeService } from '../orca-runtime'
|
||||
import { getDefaultWorkspaceSession } from '../../../shared/orca-profiles/constants'
|
||||
import '../orca-runtime-test-mocks/setup.spec'
|
||||
import '../../terminal/layout/bind-first-pane.test-fixture'
|
||||
import '../../terminal/identity/agent-status-store-wiring.test-fixture'
|
||||
import '../../construction/test-context/runtime-test-module-registration.spec'
|
||||
import { OrcaRuntimeService } from '../../orca-runtime'
|
||||
import { getDefaultWorkspaceSession } from '../../../../shared/orca-profiles/constants'
|
||||
import '../../orca-runtime-test-mocks/setup.spec'
|
||||
import 'node:path'
|
||||
import '../../workspaces/catalog/worktree-path-comparison-key'
|
||||
import type { WorktreeMeta } from '../../../shared/worktree/meta-types'
|
||||
import '../../../workspaces/catalog/worktree-path-comparison-key'
|
||||
import type { WorktreeMeta } from '../../../../shared/worktree/meta-types'
|
||||
import {
|
||||
TEST_WORKTREE_ID,
|
||||
makeRuntimeStoreWithWorkspaceSession,
|
||||
makeWorktreeMeta,
|
||||
store
|
||||
} from './orca-runtime-test-fixtures.spec'
|
||||
} from '../../construction/test-context/orca-runtime-test-fixtures.spec'
|
||||
|
||||
// No SSH Git provider is installed, so these fixtures use stored rows.
|
||||
function storedWorktreeMeta(
|
||||
@@ -0,0 +1,59 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import '../../construction/test-context/runtime-test-module-registration.spec'
|
||||
import { OrcaRuntimeService } from '../../orca-runtime'
|
||||
import '../../orca-runtime-test-mocks/setup.spec'
|
||||
import '../../../workspaces/catalog/worktree-path-comparison-key'
|
||||
|
||||
import {
|
||||
store,
|
||||
syncSinglePty
|
||||
} from '../../construction/test-context/orca-runtime-test-fixtures.spec'
|
||||
|
||||
describe('OrcaRuntimeService', () => {
|
||||
it('clears stale working status after the agent exits and the shell takes over the title', async () => {
|
||||
// Recompute from the live title so retained agent status cannot strand a working spinner (#1437).
|
||||
const runtime = new OrcaRuntimeService(store)
|
||||
|
||||
runtime.attachWindow(1)
|
||||
await runtime.syncWindowGraph(1, {
|
||||
tabs: [
|
||||
{
|
||||
tabId: 'tab-1',
|
||||
worktreeId: 'repo-1::/tmp/worktree-a',
|
||||
title: 'Codex working',
|
||||
activeLeafId: 'pane:1',
|
||||
layout: null
|
||||
}
|
||||
],
|
||||
leaves: [
|
||||
{
|
||||
tabId: 'tab-1',
|
||||
worktreeId: 'repo-1::/tmp/worktree-a',
|
||||
leafId: 'pane:1',
|
||||
paneRuntimeId: 1,
|
||||
ptyId: 'pty-1'
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
runtime.onPtyData('pty-1', '\x1b]0;Codex working\x07', 100)
|
||||
const working = await runtime.getWorktreePs()
|
||||
expect(working.worktrees[0].status).toBe('working')
|
||||
|
||||
runtime.onPtyData('pty-1', '\x1b]0;bash\x07', 200)
|
||||
const afterExit = await runtime.getWorktreePs()
|
||||
expect(afterExit.worktrees[0].status).toBe('active')
|
||||
})
|
||||
|
||||
it('shows worktree.ps active when the current pane is the Claude agents screen', async () => {
|
||||
const runtime = new OrcaRuntimeService(store)
|
||||
|
||||
await syncSinglePty(runtime, 'pty-1', { paneTitle: 'claude working' })
|
||||
runtime.onPtyData('pty-1', '\x1b]0;claude working\x07', 100)
|
||||
await syncSinglePty(runtime, 'pty-1', { paneTitle: 'claude agents' })
|
||||
|
||||
const summary = await runtime.getWorktreePs()
|
||||
|
||||
expect(summary.worktrees[0].status).toBe('active')
|
||||
})
|
||||
})
|
||||
+4
-4
@@ -1,7 +1,7 @@
|
||||
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 { makeAgentStatusStoreWiring } from '../../terminal/identity/agent-status-store-wiring.test-fixture'
|
||||
import '../../construction/test-context/runtime-test-module-registration.spec'
|
||||
import { OrcaRuntimeService } from '../../orca-runtime'
|
||||
import {
|
||||
HEADLESS_LEAF_ID,
|
||||
TEST_REPO_ID,
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
makeRuntimeStoreWithWorkspaceSession,
|
||||
makeWorkspaceSessionWithHeadlessTerminal,
|
||||
store
|
||||
} from './orca-runtime-test-fixtures.spec'
|
||||
} from '../../construction/test-context/orca-runtime-test-fixtures.spec'
|
||||
|
||||
describe('OrcaRuntimeService', () => {
|
||||
it('prefers migrated layout ownership over a worktree id frozen in the PTY id', async () => {
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user