Skip to content

The agent that grows with you

test(desktop-core): wait for message.complete before judging the DOM; explain stuck boots

teknium13d8dbad45eed
diff --git a/apps/desktop/e2e/core/README.md b/apps/desktop/e2e/core/README.md
index d3062a86774..8b811fbeb55 100644
--- a/apps/desktop/e2e/core/README.md
+++ b/apps/desktop/e2e/core/README.md
@@ -18,9 +18,9 @@ A small, deterministic Electron suite that guards three issue classes end to end
`reasoning.delta` equals what the provider streamed, and
`message.complete` equals the final completion.
- one live socket per backend process (#120006).
- `switch-back-race.spec.ts` forces both orders of "reply completes" vs "the
- switch-back REST hydrate resolves" with gates (no sleeps) under the same
- oracle.
+ `switch-back-race.spec.ts` forces both orders of "reply completes" vs "the
+ switch-back REST hydrate resolves" with gates (no sleeps) under the same
+ oracle.
- **C20 interactive prompts** — `interactive-prompts.spec.ts`: clarify (one
card; the clicked choice is exactly what the model receives), approval
Run once (the command runs only after the click) and Deny (never runs; the
diff --git a/apps/desktop/e2e/core/harness.ts b/apps/desktop/e2e/core/harness.ts
index 4037bfbb12e..a1e24a34a3e 100644
--- a/apps/desktop/e2e/core/harness.ts
+++ b/apps/desktop/e2e/core/harness.ts
@@ -154,11 +154,29 @@ export async function launchCoreApp(env: Record<string, string>): Promise<{ app:
cwd: DESKTOP_ROOT
})
+ // Keep the main process's stdout/stderr (backend supervisor lines included)
+ // so a boot that never becomes interactive fails with its own story.
+ const lines: string[] = []
+ const collect = (chunk: Buffer) => {
+ lines.push(...chunk.toString('utf8').split('\n').filter(Boolean))
+ lines.splice(0, Math.max(0, lines.length - 200))
+ }
+ app.process().stdout?.on('data', collect)
+ app.process().stderr?.on('data', collect)
+ APP_LOGS.set(app, lines)
+
const page = await app.firstWindow()
return { app, page }
}
+const APP_LOGS = new WeakMap<ElectronApplication, string[]>()
+
+/** Last main-process output lines of `app` (for failure messages). */
+export function appLogTail(app: ElectronApplication, n = 60): string {
+ return (APP_LOGS.get(app) ?? []).slice(-n).join('\n')
+}
+
// ─── Process census ─────────────────────────────────────────────────────
export interface ProcInfo {
@@ -427,35 +445,62 @@ export function composer(page: Page) {
/** Composer mounted, no full-viewport overlay above it, window visible. */
export async function waitForInteractive(app: ElectronApplication, page: Page, timeout = 180_000): Promise<void> {
- await expect(composer(page)).toBeVisible({ timeout })
- await page.waitForFunction(
- () => {
- const el = document.elementFromPoint(window.innerWidth / 2, window.innerHeight / 2)
- let node: Element | null = el
-
- if (!el) {
- return false
- }
+ try {
+ await expect(composer(page)).toBeVisible({ timeout })
+ await page.waitForFunction(
+ () => {
+ const el = document.elementFromPoint(window.innerWidth / 2, window.innerHeight / 2)
+ let node: Element | null = el
+
+ if (!el) {
+ return false
+ }
- while (node) {
- const cs = window.getComputedStyle(node)
+ while (node) {
+ const cs = window.getComputedStyle(node)
- if (cs.position === 'fixed') {
- const r = node.getBoundingClientRect()
+ if (cs.position === 'fixed') {
+ const r = node.getBoundingClientRect()
- if (r.left <= 0 && r.top <= 0 && r.right >= window.innerWidth && r.bottom >= window.innerHeight) {
- return false
+ if (r.left <= 0 && r.top <= 0 && r.right >= window.innerWidth && r.bottom >= window.innerHeight) {
+ return false
+ }
}
+
+ node = node.parentElement
}
- node = node.parentElement
- }
+ return true
+ },
+ undefined,
+ { timeout, polling: 250 }
+ )
+ } catch (error) {
+ const blocker = await page
+ .evaluate(() => {
+ let node: Element | null = document.elementFromPoint(window.innerWidth / 2, window.innerHeight / 2)
+ const chain: string[] = []
+
+ while (node && chain.length < 12) {
+ const slot = node.getAttribute('data-slot') ?? ''
+ const role = node.getAttribute('role') ?? ''
+ chain.push(
+ `${node.tagName.toLowerCase()}${slot ? `[data-slot=${slot}]` : ''}${role ? `[role=${role}]` : ''}${window.getComputedStyle(node).position === 'fixed' ? '{fixed}' : ''}`
+ )
+ node = node.parentElement
+ }
+
+ return { chain, route: location.hash, text: document.body.innerText.replace(/\s+/g, ' ').slice(0, 800) }
+ })
+ .catch(e => ({ chain: [], route: '', text: `evaluate failed: ${String(e)}` }))
+
+ throw new Error(
+ `app never became interactive: ${(error as Error).message.split('\n')[0]}\n` +
+ `route: ${blocker.route}\ncenter element chain: ${blocker.chain.join(' < ')}\nbody text: ${blocker.text}\n` +
+ `main-process log tail:\n${appLogTail(app)}`
+ )
+ }
- return true
- },
- undefined,
- { timeout, polling: 250 }
- )
await expect
.poll(
() =>
diff --git a/apps/desktop/e2e/core/oracle.ts b/apps/desktop/e2e/core/oracle.ts
index 09c5acc859a..357d7c32a98 100644
--- a/apps/desktop/e2e/core/oracle.ts
+++ b/apps/desktop/e2e/core/oracle.ts
@@ -439,6 +439,18 @@ export async function assertTranscriptOracle(
view: { text: '', userBubbles: [] }
}
+ // Wire first: wait until every expected turn's message.complete is on the
+ // wire (it can trail the persisted row under load), so the DOM check below
+ // also covers whatever the renderer does on completion. Duplicate/garbled
+ // frames never heal, so polling cannot mask them.
+ await expect
+ .poll(() => wireViolations(ws, provider, new Set(target.expectUserMarkers), new Set(target.lossyWire ?? [])), {
+ timeout: 60_000,
+ intervals: [250, 500, 1000],
+ message: `wire integrity [${label}]`
+ })
+ .toEqual([])
+
await expect
.poll(
async () => {
@@ -463,7 +475,4 @@ export async function assertTranscriptOracle(
expect(transient.violations, `transient duplicate render during [${label}] (${transient.samples} samples)`).toEqual(
[]
)
-
- const wire = wireViolations(ws, provider, new Set(target.expectUserMarkers), new Set(target.lossyWire ?? []))
- expect(wire, `wire integrity [${label}]`).toEqual([])
}