Skip to content

Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.

test: fix three timing races that fail CI under load

Fabricio Casalidcb19c891700
diff --git a/scripts/terminal-fit-layout.test.ts b/scripts/terminal-fit-layout.test.ts
index 74502023c..62e664d64 100644
--- a/scripts/terminal-fit-layout.test.ts
+++ b/scripts/terminal-fit-layout.test.ts
@@ -92,4 +92,4 @@ it.skipIf(!existsSync(chrome)).each([1, 1.25, 1.5, 2])('at DPR %s fits complete
} finally {
rmSync(dir, { recursive: true, force: true, maxRetries: 10, retryDelay: 100 })
}
-}, 40000)
+}, 90_000) // cold esbuild bundle + Chrome start, often beside another real-browser suite on CI
diff --git a/scripts/usage-layout.test.ts b/scripts/usage-layout.test.ts
index d7cf24c3b..4c674c04a 100644
--- a/scripts/usage-layout.test.ts
+++ b/scripts/usage-layout.test.ts
@@ -91,4 +91,4 @@ it.skipIf(!existsSync(chrome))('keeps refresh clickable beside/above the real do
} finally {
rmSync(dir, { recursive: true, force: true, maxRetries: 10, retryDelay: 100 })
}
-}, 40000)
+}, 90_000) // cold esbuild bundle + Chrome start, often beside another real-browser suite on CI
diff --git a/src/core/project-setup-runner-local.test.ts b/src/core/project-setup-runner-local.test.ts
index 3e13c70a8..0c80e0143 100644
--- a/src/core/project-setup-runner-local.test.ts
+++ b/src/core/project-setup-runner-local.test.ts
@@ -70,14 +70,26 @@ describe('makeLocalSetupRunner', () => {
})
it('caps combined output at SETUP_OUTPUT_CAP and appends exactly one truncation note', async () => {
- const { promise, chunks } = run('yes 0123456789abcdef0123456789abcdef 2>&1', { timeoutMs: 500 })
+ // Twice the cap, then the script exits by itself. It used to be an endless `yes` cut by a
+ // 500 ms timeout, which raced the login shell's startup: on a loaded CI runner the kill landed
+ // before 512KB were written, so there was nothing to truncate.
+ const { promise, chunks } = run(
+ `yes 0123456789abcdef0123456789abcdef | head -c ${SETUP_OUTPUT_CAP * 2}`
+ )
const result = await promise
const combined = chunks.join('')
// A generous margin over the cap: the last chunk that crosses the budget can carry a partial
// line plus the truncation note, but nothing appended AFTER truncation.
expect(Buffer.byteLength(combined, 'utf-8')).toBeLessThan(SETUP_OUTPUT_CAP + 200)
expect(combined.match(/truncated/g)?.length).toBe(1)
- // Killed by the timeout's SIGKILL (yes never exits on its own).
+ expect(result.exitCode).toBe(0)
+ }, 10_000)
+
+ it('the timeout kills a script that never exits', async () => {
+ const { promise } = run('sleep 30', { timeoutMs: 200 })
+ const start = Date.now()
+ const result = await promise
+ expect(Date.now() - start).toBeLessThan(5000)
expect(result.exitCode).not.toBe(0)
}, 10_000)
diff --git a/src/session-host/agent-ops-host.test.ts b/src/session-host/agent-ops-host.test.ts
index 16d567362..ee9e9bff0 100644
--- a/src/session-host/agent-ops-host.test.ts
+++ b/src/session-host/agent-ops-host.test.ts
@@ -11,6 +11,13 @@ import path from 'path'
import { build, type Plugin } from 'esbuild'
import { LineFramer, encodeFrame, type SessionHostFrame, type SessionHostResponse } from './protocol'
import { sessionHostPaths, type SessionHostState } from './paths'
+import { WINDOWS_PANE_PROBE_TIMEOUT_MS } from '../core/agents/pane-probe'
+
+/** On win32 `terminateOwnerV1` runs the real PowerShell owner probe: a cold worker may take its
+ * whole first-request deadline (6 s) and then the one-shot fallback (4 s). A 6 s wait here gave
+ * up exactly when the worker did, so the CI runner failed whenever PowerShell started slowly.
+ * Wait as long as the core does for the same probe. */
+const CALL_TIMEOUT_MS = WINDOWS_PANE_PROBE_TIMEOUT_MS
/** A fake shell that exits by itself (see fakePtyPlugin). */
const EXITING_SHELL = 'fake-exiting-shell'
@@ -128,7 +135,7 @@ function connect(endpoint: string): Promise<Conn> {
call: (body) => {
const id = nextId++
return new Promise<SessionHostResponse>((res, rej) => {
- const timer = setTimeout(() => rej(new Error(`no response to ${String(body.cmd)}`)), 6_000)
+ const timer = setTimeout(() => rej(new Error(`no response to ${String(body.cmd)}`)), CALL_TIMEOUT_MS)
waiters.set(id, (frame) => {
clearTimeout(timer)
res(frame)
@@ -199,5 +206,5 @@ describe('session-host agent-operation verbs', () => {
// The session survived and nothing was typed into it.
await expect(conn.call({ cmd: 'hasSession', name: 'nt-c' })).resolves.toMatchObject({ result: { exists: true } })
expect(host.writes()).toEqual([])
- }, 30_000)
+ }, 45_000) // two probe-bound calls, each up to CALL_TIMEOUT_MS on a cold win32 runner
})