Skip to content
Merged
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
44 changes: 33 additions & 11 deletions src/main/runtime/terminal-interactive-wait-visibility.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import { readFileSync } from 'node:fs'
import { makeAgentStatusStoreWiring } from './agent-status-store-wiring.test-fixture'
import { join } from 'node:path'
import { describe, expect, it, vi } from 'vitest'
import { afterEach, describe, expect, it, vi } from 'vitest'
import { TERMINAL_INTERACTIVE_WAIT_PROBE_TIMEOUT_MS } from './orca-runtime-core'
import {
createTranscriptPane,
type TranscriptPaneOptions,
Expand Down Expand Up @@ -56,6 +57,8 @@ async function createPane(
// that as `working`; the title is identical whether it is running a command or waiting.
const CURSOR_TITLE = '⠇ Cursor Agent'

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

describe('terminal interactive-wait visibility (STA-4513, STA-3714)', () => {
describe('cursor-agent approval menu, the case no hook reports', () => {
it('names the pending approval on the pane a coordinator inspects', async () => {
Expand Down Expand Up @@ -374,13 +377,21 @@ describe('terminal interactive-wait visibility (STA-4513, STA-3714)', () => {
foregroundProbeHangs: true
})

await Promise.all([
runtime.getTerminalInteractiveWait(handle),
runtime.getTerminalInteractiveWait(handle),
runtime.getTerminalInteractiveWait(handle)
])

expect(probes).toBe(1)
vi.useFakeTimers({ toFake: ['Date', 'setTimeout', 'clearTimeout'] })
try {
const probing = Promise.all([
runtime.getTerminalInteractiveWait(handle),
runtime.getTerminalInteractiveWait(handle),
runtime.getTerminalInteractiveWait(handle)
])
void probing.catch(() => undefined)
await vi.advanceTimersByTimeAsync(TERMINAL_INTERACTIVE_WAIT_PROBE_TIMEOUT_MS)
await probing

expect(probes).toBe(1)
} finally {
vi.useRealTimers()
}
}, 20_000)

it('accepts a menu whose keys are rendered as glyphs', async () => {
Expand Down Expand Up @@ -419,9 +430,20 @@ describe('terminal interactive-wait visibility (STA-4513, STA-3714)', () => {
foregroundProbeHangs: true
})

await expect(runtime.getTerminalInteractiveWait(handle)).resolves.toBeUndefined()
const show = (await runtime.showTerminal(handle)) as Record<string, unknown>
expect('agentWait' in show).toBe(false)
vi.useFakeTimers({ toFake: ['Date', 'setTimeout', 'clearTimeout'] })
try {
const waiting = runtime.getTerminalInteractiveWait(handle)
void waiting.catch(() => undefined)
await vi.advanceTimersByTimeAsync(TERMINAL_INTERACTIVE_WAIT_PROBE_TIMEOUT_MS)
await expect(waiting).resolves.toBeUndefined()
const showing = runtime.showTerminal(handle)
void showing.catch(() => undefined)
await vi.advanceTimersByTimeAsync(TERMINAL_INTERACTIVE_WAIT_PROBE_TIMEOUT_MS)
const show = await showing
expect('agentWait' in show).toBe(false)
} finally {
vi.useRealTimers()
}
}, 15_000)

it('answers undefined rather than "not waiting" for a pane it cannot read', async () => {
Expand Down
Loading