Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/computer-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ on:
- '!src/main/daemon/daemon-init-test-harness.ts'
- '!src/main/daemon/daemon-init-fresh-import.ts'
- '!src/main/daemon/daemon-init-mock-types.ts'
- '!src/main/daemon/serialize-grid-roundtrip.ts'
- '!src/main/daemon/mock-descendant-sweep.ts'
- '!src/main/daemon/daemon-host-relocation.test-fixture.ts'
- '!src/main/daemon/daemon-endpoint-reachability-test-harness.ts'
- 'src/main/providers/local-pty-provider.ts'
- 'src/main/providers/windows-shell-args.ts'
- 'src/main/providers/windows-shell-preflight-runtime.windows.test.ts'
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/win-orcad-serve-switch-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ on:
paths:
- 'src/main/daemon/**'
- '!src/main/daemon/**/*.test.ts'
- '!src/main/daemon/serialize-grid-roundtrip.ts'
- '!src/main/daemon/mock-descendant-sweep.ts'
- '!src/main/daemon/daemon-host-relocation.test-fixture.ts'
- '!src/main/daemon/daemon-endpoint-reachability-test-harness.ts'
# D7 packages production entries; the unit jobs own these test roots.
- 'src/main/orcad/**'
- '!src/main/orcad/**/*.test.ts'
Expand Down
43 changes: 43 additions & 0 deletions config/scripts/orcad-e2e-change-scope.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ const workflows = {
),
wsl: parse(
readFileSync(new URL('../../.github/workflows/wsl-orcad-e2e.yml', import.meta.url), 'utf8')
),
computer: parse(
readFileSync(new URL('../../.github/workflows/computer-e2e.yml', import.meta.url), 'utf8')
)
}

Expand Down Expand Up @@ -97,6 +100,46 @@ for (const [lane, { excluded, retained, product }] of Object.entries(cases)) {
})
}

describe.each(['windows', 'computer'])('%s unit-support routing', (lane) => {
const paths = workflows[lane].on.pull_request.paths
const helpers = [
'src/main/daemon/serialize-grid-roundtrip.ts',
'src/main/daemon/mock-descendant-sweep.ts',
'src/main/daemon/daemon-host-relocation.test-fixture.ts',
'src/main/daemon/daemon-endpoint-reachability-test-harness.ts'
]
const product = 'src/main/daemon/daemon-entry.ts'
const renamed = 'src/main/daemon/serialize-grid-runtime.ts'

it.each(helpers)('leaves known unit support to its suites: %s', (helper) => {
expect(workflowIncludes(paths, [helper])).toBe(false)
expect(workflowIncludes(paths, [helper, 'docs/ci.md'])).toBe(false)
expect(workflowIncludes(paths, [helper, product])).toBe(true)
// Both names of a rename must retain the production workflow.
expect(workflowIncludes(paths, [helper, renamed])).toBe(true)
expect(workflowIncludes(paths, [renamed, helper])).toBe(true)
expect(workflowIncludes(paths, ['src/main/daemon/unknown-test-harness.ts'])).toBe(true)
})

it('keeps production selected when multiple unit fixtures change', () => {
expect(workflowIncludes(paths, helpers)).toBe(false)
expect(workflowIncludes(paths, [...helpers, product])).toBe(true)
})
})

it.each([
'config/scripts/daemon-boot-smoke.mjs',
'config/scripts/daemon-endpoint-handover-smoke.mjs',
'config/scripts/windows-daemon-workspace-close-repro.mjs',
'config/scripts/computer-use-smoke.test.mjs',
'src/main/providers/windows-shell-preflight-runtime.windows.test.ts',
'native/computer-use-macos/Sources/OrcaComputerUseMacOS/main.swift',
'src/cli/handlers/computer.ts',
'.github/workflows/computer-e2e.yml'
])('keeps the computer contract owner selected: %s', (file) => {
expect(workflowIncludes(workflows.computer.on.pull_request.paths, [file])).toBe(true)
})

it('re-includes the real WSL distro root after excluding unit tests', () => {
const paths = workflows.wsl.on.pull_request.paths
const exclude = paths.indexOf('!src/main/wsl/**/*.test.ts')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ async function createHost(name: string, partition: string, nativeControl = false
contextIsolation: true,
nodeIntegration: false,
sandbox: true,
// Hidden popup probes still need compositor frames for real CDP input.
backgroundThrottling: false,
webviewTag: true
}
})
Expand Down
9 changes: 7 additions & 2 deletions src/main/daemon/serialize-grid-roundtrip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
variantTrailingBackgroundRows
} from './serialize-grid-variant-scope'
import type { GridDiff } from './serialize-grid-cell-descriptors'
import { cellDescriptor, CLIPPED, compareBufferRows } from './serialize-grid-cell-descriptors'
import { compareBufferRows } from './serialize-grid-cell-descriptors'

export type NamedSerializer = { name: string; create: () => SerializeAddon }

Expand Down Expand Up @@ -202,7 +202,12 @@ function countClippedWideCells(terminal: Terminal): number {
const scratch = buffer.getNullCell()
let count = 0
for (let y = 0; y < buffer.length; y++) {
if (cellDescriptor(buffer.getLine(y), terminal.cols - 1, terminal.cols, scratch) === CLIPPED) {
const line = buffer.getLine(y)
if (
line &&
line.length > terminal.cols &&
(line.getCell(terminal.cols - 1, scratch)?.getWidth() ?? 0) > 1
) {
count++
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/ipc/mobile.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { registerMobileHandlers } from './mobile'
import { NETWORK_EXPOSURE_FAILED_GUIDANCE } from '../runtime/network-exposure-guidance'
import { OrcaRuntimeService } from '../runtime/orca-runtime'
import { createMobileRpcSurfaceRuntime } from '../runtime/runtime-rpc-mobile-method-allowlist-fixtures'
import { OrcaRuntimeRpcServer } from '../runtime/runtime-rpc'
import { WebSocketTransport } from '../runtime/rpc/ws-transport'

Expand Down Expand Up @@ -856,7 +856,7 @@ describe('runtime pairing bind host', () => {
const startServer = async (userDataPath: string): Promise<OrcaRuntimeRpcServer> => {
const server = new OrcaRuntimeRpcServer({
methods: [],
runtime: new OrcaRuntimeService(),
runtime: createMobileRpcSurfaceRuntime().runtime,
userDataPath,
enableWebSocket: true,
wsPort: 0
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { vi } from 'vitest'
import type { StructuredAgentSessionHost } from './structured-agent-session-host'

export function createStructuredSessionObservationClock(
getHost: () => StructuredAgentSessionHost,
sessionId: string
) {
function restore(): void {
vi.useRealTimers()
}

return {
start(): void {
vi.useFakeTimers({ toFake: ['Date', 'setTimeout', 'clearTimeout'] })
},
async observe(ms: number): Promise<void> {
await vi.advanceTimersByTimeAsync(ms)
const host = getHost()
await host.flushStreamedEvents(sessionId)
await host.collaboratorsForTests().serialize(sessionId, async () => {})
await new Promise<void>((resolve) => setImmediate(resolve))
await host.collaboratorsForTests().serialize(sessionId, async () => {})
},
restore,
async restoreBeforeCleanup(cleanup: () => Promise<void>): Promise<void> {
restore()
await cleanup()
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { afterEach, expect, it, vi } from 'vitest'
import { withTimeout } from '../../../shared/promise-timeout-fallback'
import { createStructuredSessionObservationClock } from './structured-agent-session-observation-clock.test-fixture'

const realSetTimeout = setTimeout
const realClearTimeout = clearTimeout

afterEach(() => vi.useRealTimers())

it('restores the clock before pending cleanup and propagates its real deadline failure', async () => {
const clock = createStructuredSessionObservationClock(() => {
throw new Error('cleanup must not access a session host')
}, 'cleanup-clock')
const phaseFailure = new Error('teardown phase timed out')
let releasePhase: () => void = () => {}
const pendingPhase = new Promise<void>((resolve) => {
releasePhase = resolve
})
let watchdog: ReturnType<typeof setTimeout> | undefined
let observationFired = false
clock.start()
setTimeout(() => {
observationFired = true
}, 1)

try {
const cleanup = clock.restoreBeforeCleanup(async () => {
const outcome = await withTimeout<void | null>(pendingPhase, 10, null)
if (outcome === null) {
throw phaseFailure
}
})
const guardedCleanup = Promise.race([
cleanup,
new Promise<never>((_, reject) => {
watchdog = realSetTimeout(() => reject(new Error('cleanup deadline stayed frozen')), 1_000)
})
])
expect(vi.isFakeTimers()).toBe(false)
await expect(guardedCleanup).rejects.toBe(phaseFailure)
expect(vi.isFakeTimers()).toBe(false)
expect(observationFired).toBe(false)
} finally {
clock.restore()
realClearTimeout(watchdog)
releasePhase()
}
})
Loading
Loading