Skip to content

Beautiful, AI-native markdown IDE and LLM wiki

Investigate Windows terminal primary prompt startup (#6428)

Nick Gomezd5611a8eada2
diff --git a/packages/desktop/tests/smoke/_helpers/smoke-test.ts b/packages/desktop/tests/smoke/_helpers/smoke-test.ts
index 47eccb96d..9cc519c9a 100644
--- a/packages/desktop/tests/smoke/_helpers/smoke-test.ts
+++ b/packages/desktop/tests/smoke/_helpers/smoke-test.ts
@@ -11,7 +11,6 @@ import {
attachCapturedStderr,
captureElectronStderr,
type ElectronStderrCapture,
- shouldAttachStderr,
} from './electron-stderr';
import { rememberLaunchHome } from './launch-readiness';
@@ -71,7 +70,9 @@ export const test = baseTest.extend<SmokeFixtures>({
console.warn(`[smoke-test] tmp-dir cleanup failed for ${dir}: ${reason}`);
}
}
- if (shouldAttachStderr(testInfo) || unclosed.length > 0) {
+ const attemptFailed =
+ testInfo.status !== 'skipped' && testInfo.status !== testInfo.expectedStatus;
+ if (attemptFailed || unclosed.length > 0) {
await attachCapturedStderr(testInfo, captures);
}
if (unclosed.length > 0) {
diff --git a/packages/desktop/tests/smoke/_helpers/terminal-ready.test.ts b/packages/desktop/tests/smoke/_helpers/terminal-ready.test.ts
index db33bd068..288f39bbc 100644
--- a/packages/desktop/tests/smoke/_helpers/terminal-ready.test.ts
+++ b/packages/desktop/tests/smoke/_helpers/terminal-ready.test.ts
@@ -1,5 +1,14 @@
-import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
-import { waitForShellReady, waitForTerminalOutput } from './terminal-ready';
+import { mkdirSync, writeFileSync } from 'node:fs';
+import { join } from 'node:path';
+import { afterAll, afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
+import { createTempDirFactory } from '../../../../../test-support/temp-dir.test-helper.ts';
+import { bootLogDirFor, readBootLog } from './launch-readiness';
+import type { DiagnosticAttachment, TerminalDomText } from './terminal-ready';
+import {
+ captureTerminalStartupDiagnostics,
+ waitForShellReady,
+ waitForTerminalOutput,
+} from './terminal-ready';
import { numberedScrollLine } from './terminal-scrollback';
import { terminalSmokeShellCommands } from './terminal-smoke-shell';
@@ -30,6 +39,8 @@ const XTERM_CURSOR_CELL = ' ';
const PROMPTED_POLL = { interval: 10, timeout: 5_000 };
const LONG_BLANK_POLL = { interval: 25, timeout: 5_000 };
const NEVER_READY_POLL = { interval: 10, timeout: 600 };
+const DIAGNOSTIC_CAPTURE_FAILURE =
+ 'page.screenshot: Target page, context or browser has been closed';
type TerminalReader = 'accessibility-then-rows' | 'rows-inner-text';
@@ -269,10 +280,12 @@ async function settleOnTheFakeClock(wait: Promise<unknown>): Promise<void> {
async function runWindowsReadiness(
shell: ScriptedPowerShell,
poll: { readonly interval: number; readonly timeout: number },
+ onPrimaryPromptFailure?: () => Promise<void>,
): Promise<ReadinessHandover> {
const handover = waitForShellReady(shell.read, shell.send, {
...poll,
platform: 'win32',
+ onPrimaryPromptFailure,
}).then(
() => shell.handover('resolved'),
() => shell.handover('rejected'),
@@ -354,6 +367,42 @@ describe('terminal smoke shell readiness', () => {
},
);
+ test('runs the primary-prompt diagnostic callback at the failed wait boundary', async () => {
+ const shell = scriptedPowerShell({ ...screen, firstPromptAtRead: null });
+ const failures: number[] = [];
+
+ const handover = await runWindowsReadiness(shell, NEVER_READY_POLL, async () => {
+ failures.push(1);
+ });
+
+ expect(handover.outcome).toBe('rejected');
+ expect(failures).toHaveLength(1);
+ });
+
+ test('keeps the primary-prompt failure and reports why its diagnostic capture failed when the capture rejects', async () => {
+ const warn = vi.spyOn(console, 'warn').mockImplementation(() => {});
+
+ try {
+ const shell = scriptedPowerShell({ ...screen, firstPromptAtRead: null });
+ const readiness = waitForShellReady(shell.read, shell.send, {
+ ...NEVER_READY_POLL,
+ platform: 'win32',
+ onPrimaryPromptFailure: () => Promise.reject(new Error(DIAGNOSTIC_CAPTURE_FAILURE)),
+ });
+ await settleOnTheFakeClock(readiness);
+ const message = await readiness.then(
+ () => '',
+ (error: unknown) => (error instanceof Error ? error.message : String(error)),
+ );
+
+ expect(message).toContain('PowerShell primary prompt');
+ expect(message).not.toContain(DIAGNOSTIC_CAPTURE_FAILURE);
+ expect(warn).toHaveBeenCalledWith(expect.stringContaining(DIAGNOSTIC_CAPTURE_FAILURE));
+ } finally {
+ warn.mockRestore();
+ }
+ });
+
test.each([2, 5])(
'writes no reset and no second probe while the Windows shell is still evaluating the first (evaluation trails the echo by %i reads)',
async (evaluationLagReads) => {
@@ -1003,3 +1052,205 @@ describe('terminal output wait', () => {
});
});
});
+
+const DIAGNOSTIC_ATTACHMENT_CAP_BYTES = 128 * 1024;
+const BOOT_LOG_FINAL_LINE_MARK = 'final-boot-line-5d81';
+const BOOT_LOG_LAST_EVENT = 'terminal prompt wait pending 3c07';
+const A11Y_FINAL_ROW_MARK = 'a11y-final-row-c41d';
+const ROWS_FINAL_ROW_MARK = 'rows-final-row-9e2b';
+const POWERSHELL_SCROLLBACK_ROW = `${POWERSHELL_PROMPT}Write-Output tick\n`;
+const JPEG_START_OF_IMAGE = Buffer.from([0xff, 0xd8, 0xff, 0xe0]);
+const JPEG_END_OF_IMAGE = Buffer.from([0xff, 0xd9]);
+const SMALL_SCREEN_BYTES = 4 * 1024;
+const USUAL_SCREEN_QUALITY = 60;
+const SMALL_TERMINAL_DOM: TerminalDomText = {
+ a11y: [POWERSHELL_PROMPT],
+ rows: [POWERSHELL_PROMPT],
+};
+
+const makeDiagnosticsHome = createTempDirFactory(afterAll);
+
+interface RecordedAttachment extends DiagnosticAttachment {
+ readonly name: string;
+}
+
+interface CapturedScreen {
+ readonly quality: number;
+ readonly image: Buffer;
+}
+
+interface StartupDiagnosticsFixture {
+ readonly bootLogLines: readonly string[];
+ readonly terminalDom?: TerminalDomText;
+ readonly screenBytesAtQuality?: (quality: number) => number;
+}
+
+function seedBootLog(lines: readonly string[]): string {
+ const home = makeDiagnosticsHome('ok-terminal-diagnostics-');
+ const dir = bootLogDirFor(home);
+ mkdirSync(dir, { recursive: true });
+ writeFileSync(join(dir, 'desktop.2026-10-14.log'), `${lines.join('\n')}\n`, 'utf8');
+ return home;
+}
+
+function ptyPhaseLines(count: number): string[] {
+ return Array.from({ length: count }, (_, sequence) =>
+ JSON.stringify({
+ level: 30,
+ event: 'pty-phase',
+ producer: 'main',
+ phase: 'pty-first-output',
+ edge: 'point',
+ sequence,
+ pad: 'x'.repeat(96),
+ }),
+ );
+}
+
+function linesNamingNoEvent(count: number): string[] {
+ return Array.from({ length: count }, (_, chunk) =>
+ JSON.stringify({ level: 30, ptyId: 'pty-1', chunk, bytes: 512, pad: 'y'.repeat(96) }),
+ );
+}
+
+function jpegOfBytes(totalBytes: number, fill: number): Buffer {
+ const fillBytes = totalBytes - JPEG_START_OF_IMAGE.length - JPEG_END_OF_IMAGE.length;
+ return Buffer.concat([JPEG_START_OF_IMAGE, Buffer.alloc(fillBytes, fill), JPEG_END_OF_IMAGE]);
+}
+
+function textOf(attachment: RecordedAttachment): string {
+ return typeof attachment.body === 'string' ? attachment.body : attachment.body.toString('utf8');
+}
+
+function attachmentNamed(
+ attachments: readonly RecordedAttachment[],
+ name: string,
+): RecordedAttachment {
+ const match = attachments.find((attachment) => attachment.name === name);
+ if (match === undefined) throw new Error(`no ${name} attachment was recorded`);
+ return match;
+}
+
+async function captureStartupDiagnostics({
+ bootLogLines,
+ terminalDom = SMALL_TERMINAL_DOM,
+ screenBytesAtQuality = () => SMALL_SCREEN_BYTES,
+}: StartupDiagnosticsFixture): Promise<{
+ home: string;
+ attachments: RecordedAttachment[];
+ screens: CapturedScreen[];
+}> {
+ const home = seedBootLog(bootLogLines);
+ const attachments: RecordedAttachment[] = [];
+ const screens: CapturedScreen[] = [];
+ await captureTerminalStartupDiagnostics({
+ readBootLog: () => readBootLog(home),
+ readTerminalDom: async () => terminalDom,
+ captureScreen: async ({ quality }) => {
+ const image = jpegOfBytes(screenBytesAtQuality(quality), quality);
+ screens.push({ quality, image });
+ return image;
+ },
+ attach: async (name, attachment) => {
+ attachments.push({ name, ...attachment });
+ },
+ });
+ return { home, attachments, screens };
+}
+
+describe('terminal startup diagnostics', () => {
+ test('keeps the final lines of a boot log over the attachment cap, marked as truncated, within the cap', async () => {
+ const finalLine = JSON.stringify({ level: 30, event: BOOT_LOG_FINAL_LINE_MARK });
+ const { attachments } = await captureStartupDiagnostics({
+ bootLogLines: [...ptyPhaseLines(1200), finalLine],
+ });
+
+ const bootLog = textOf(attachmentNamed(attachments, 'terminal-startup-boot-log'));
+
+ expect({
+ withinCap: Buffer.byteLength(bootLog) <= DIAGNOSTIC_ATTACHMENT_CAP_BYTES,
+ markedTruncated: (JSON.parse(bootLog) as { truncated?: unknown }).truncated,
+ keepsFinalLine: bootLog.includes(BOOT_LOG_FINAL_LINE_MARK),
+ }).toEqual({ withinCap: true, markedTruncated: true, keepsFinalLine: true });
+ });
+
+ test('keeps the last event of a boot log over the attachment cap whose final lines name no event', async () => {
+ const lastEventLine = JSON.stringify({ level: 30, msg: BOOT_LOG_LAST_EVENT });
+ const { home, attachments } = await captureStartupDiagnostics({
+ bootLogLines: [...ptyPhaseLines(900), lastEventLine, ...linesNamingNoEvent(900)],
+ });
+
+ const bootLog = textOf(attachmentNamed(attachments, 'terminal-startup-boot-log'));
+
+ expect(readBootLog(home).lastEvent).toBe(BOOT_LOG_LAST_EVENT);
+ expect({
+ withinCap: Buffer.byteLength(bootLog) <= DIAGNOSTIC_ATTACHMENT_CAP_BYTES,
+ keepsLastEvent: bootLog.includes(BOOT_LOG_LAST_EVENT),
+ }).toEqual({ withinCap: true, keepsLastEvent: true });
+ });
+
+ test('keeps the end of extracted terminal text over the attachment cap, marked as truncated, within the cap', async () => {
+ const { attachments } = await captureStartupDiagnostics({
+ bootLogLines: ptyPhaseLines(3),
+ terminalDom: {
+ a11y: [`${POWERSHELL_SCROLLBACK_ROW.repeat(3000)}${A11Y_FINAL_ROW_MARK}`],
+ rows: [`${POWERSHELL_SCROLLBACK_ROW.repeat(30)}${ROWS_FINAL_ROW_MARK}`],
+ },
+ });
+
+ const terminalText = textOf(attachmentNamed(attachments, 'terminal-startup-dom'));
+
+ expect({
+ withinCap: Buffer.byteLength(terminalText) <= DIAGNOSTIC_ATTACHMENT_CAP_BYTES,
+ markedTruncated: (JSON.parse(terminalText) as { truncated?: unknown }).truncated,
+ keepsAccessibilityEnd: terminalText.includes(A11Y_FINAL_ROW_MARK),
+ keepsRowsEnd: terminalText.includes(ROWS_FINAL_ROW_MARK),
+ }).toEqual({
+ withinCap: true,
+ markedTruncated: true,
+ keepsAccessibilityEnd: true,
+ keepsRowsEnd: true,
+ });
+ });
+
+ test('attaches a whole screen image within the cap when the screen at the usual quality is over it', async () => {
+ const screenBytesAtQuality = (quality: number) =>
+ Math.round((quality / USUAL_SCREEN_QUALITY) * 1.5 * DIAGNOSTIC_ATTACHMENT_CAP_BYTES);
+ const { attachments, screens } = await captureStartupDiagnostics({
+ bootLogLines: ptyPhaseLines(3),
+ screenBytesAtQuality,
+ });
+
+ const screen = attachmentNamed(attachments, 'terminal-startup-screen');
+
+ expect(screenBytesAtQuality(USUAL_SCREEN_QUALITY)).toBeGreaterThan(
+ DIAGNOSTIC_ATTACHMENT_CAP_BYTES,
+ );
+ expect({
+ contentType: screen.contentType,
+ withinCap: Buffer.byteLength(screen.body) <= DIAGNOSTIC_ATTACHMENT_CAP_BYTES,
+ wholeCapturedImage: screens.some(({ image }) => image.equals(Buffer.from(screen.body))),
+ }).toEqual({ contentType: 'image/jpeg', withinCap: true, wholeCapturedImage: true });
+ });
+
+ test('attaches a boot log, terminal text and screen under the cap whole', async () => {
+ const { home, attachments, screens } = await captureStartupDiagnostics({
+ bootLogLines: ptyPhaseLines(3),
+ });
+
+ const screen = attachmentNamed(attachments, 'terminal-startup-screen');
+
+ expect({
+ bootLog: JSON.parse(textOf(attachmentNamed(attachments, 'terminal-startup-boot-log'))),
+ terminalText: JSON.parse(textOf(attachmentNamed(attachments, 'terminal-startup-dom'))),
+ screen: { contentType: screen.contentType, body: screen.body },
+ }).toEqual({
+ bootLog: readBootLog(home),
+ terminalText: SMALL_TERMINAL_DOM,
+ screen: {
+ contentType: 'image/jpeg',
+ body: screens.find(({ quality }) => quality === USUAL_SCREEN_QUALITY)?.image,
+ },
+ });
+ });
+});
diff --git a/packages/desktop/tests/smoke/_helpers/terminal-ready.ts b/packages/desktop/tests/smoke/_helpers/terminal-ready.ts
index 49a80838f..8a7c0cede 100644
--- a/packages/desktop/tests/smoke/_helpers/terminal-ready.ts
+++ b/packages/desktop/tests/smoke/_helpers/terminal-ready.ts
@@ -1,10 +1,14 @@
import { expect } from '@playwright/test';
+import type { BootLogSnapshot } from './launch-readiness';
import {
buildInputReadyProbe,
WINDOWS_PRIMARY_PROMPT_AT_END,
windowsPrimaryPromptAfter,
} from './terminal-smoke-shell';
+const DIAGNOSTIC_ATTACHMENT_MAX_BYTES = 128 * 1024;
+const SCREEN_JPEG_QUALITIES = [60, 40, 20, 10] as const;
+
export async function waitForShellReady(
readTerminalText: () => Promise<string>,
sendTerminalCommand: (command: string) => Promise<void>,
@@ -13,17 +17,28 @@ export async function waitForShellReady(
quietPolls = 3,
interval = 250,
platform = process.platform,
+ onPrimaryPromptFailure,
}: WaitForShellReadyOptions = {},
): Promise<void> {
if (platform === 'win32') {
const startedAt = Date.now();
- await waitForTerminalText(
- readTerminalText,
- WINDOWS_PRIMARY_PROMPT_AT_END,
- 'PowerShell primary prompt',
- timeout,
- interval,
- );
+ try {
+ await waitForTerminalText(
+ readTerminalText,
+ WINDOWS_PRIMARY_PROMPT_AT_END,
+ 'PowerShell primary prompt',
+ timeout,
+ interval,
+ );
+ } catch (error) {
+ await onPrimaryPromptFailure?.().catch((captureError: unknown) => {
+ const reason = captureError instanceof Error ? captureError.message : String(captureError);
+ console.warn(
+ `[terminal-ready] could not capture the PowerShell primary-prompt diagnostics: ${reason}`,
+ );
+ });
+ throw error;
+ }
const firstPromptWaitMs = Date.now() - startedAt;
const { marker, command } = buildInputReadyProbe('win32');
await sendTerminalCommand(command);
@@ -48,6 +63,52 @@ export async function waitForShellReady(
await waitForQuietTerminalText(readTerminalText, timeout, quietPolls, interval);
}
+export async function captureTerminalStartupDiagnostics({
+ readBootLog,
+ readTerminalDom,
+ captureScreen,
+ attach,
+}: TerminalStartupDiagnosticSources): Promise<void> {
+ await attach('terminal-startup-boot-log', {
+ body: boundedJson(readBootLog()),
+ contentType: 'application/json',
+ });
+ await attach('terminal-startup-dom', {
+ body: boundedJson(await readTerminalDom()),
+ contentType: 'application/json',
+ });
+ let screen = await captureScreen({ quality: SCREEN_JPEG_QUALITIES[0] });
+ const originalBytes = screen.byteLength;
+ for (const quality of SCREEN_JPEG_QUALITIES.slice(1)) {
+ if (screen.byteLength <= DIAGNOSTIC_ATTACHMENT_MAX_BYTES) break;
+ screen = await captureScreen({ quality });
+ }
+ if (screen.byteLength <= DIAGNOSTIC_ATTACHMENT_MAX_BYTES) {
+ await attach('terminal-startup-screen', {
+ body: screen,
+ contentType: 'image/jpeg',
+ });
+ } else {
+ await attach('terminal-startup-screen', {
+ body: boundedJson({ truncated: true, originalBytes }),
+ contentType: 'application/json',
+ });
+ }
+}
+
+function boundedJson(value: unknown): string {
+ const source = JSON.stringify(value) ?? 'null';
+ const originalBytes = Buffer.byteLength(source, 'utf8');
+ if (originalBytes <= DIAGNOSTIC_ATTACHMENT_MAX_BYTES) return source;
+ let end = source.slice(-DIAGNOSTIC_ATTACHMENT_MAX_BYTES);
+ let body = JSON.stringify({ truncated: true, originalBytes, end });
+ while (Buffer.byteLength(body, 'utf8') > DIAGNOSTIC_ATTACHMENT_MAX_BYTES && end.length > 0) {
+ end = end.slice(1024);
+ body = JSON.stringify({ truncated: true, originalBytes, end });
+ }
+ return body;
+}
+
async function waitForTerminalText(
readTerminalText: () => Promise<string>,
pattern: RegExp,
@@ -121,8 +182,30 @@ export interface WaitForShellReadyOptions {
quietPolls?: number;
interval?: number;
platform?: NodeJS.Platform;
+ onPrimaryPromptFailure?: () => Promise<void>;
}
export interface WaitForTerminalOutputOptions {
stallMs: number;
}
+
+export interface TerminalDomText {
+ readonly a11y: readonly string[];
+ readonly rows: readonly string[];
+}
+
+export interface ScreenCaptureSetting {
+ readonly quality: number;
+}
+
+export interface DiagnosticAttachment {
+ readonly body: string | Buffer;
+ readonly contentType: string;
+}
+
+export interface TerminalStartupDiagnosticSources {
+ readonly readBootLog: () => BootLogSnapshot;
+ readonly readTerminalDom: () => Promise<TerminalDomText>;
+ readonly captureScreen: (setting: ScreenCaptureSetting) => Promise<Buffer>;
+ readonly attach: (name: string, attachment: DiagnosticAttachment) => Promise<void>;
+}
diff --git a/packages/desktop/tests/smoke/terminal-dock.e2e.ts b/packages/desktop/tests/smoke/terminal-dock.e2e.ts
index f735f68d4..fb814ff36 100644
--- a/packages/desktop/tests/smoke/terminal-dock.e2e.ts
+++ b/packages/desktop/tests/smoke/terminal-dock.e2e.ts
@@ -20,7 +20,7 @@ import {
watchForDockReveal,
} from './_helpers/dock-reveal-latency';
import { desktopLaunchOptions, resolveDesktopTarget } from './_helpers/launch-desktop';
-import { launchDesktopApp, waitForWindowByMode } from './_helpers/launch-readiness';
+import { launchDesktopApp, readBootLog, waitForWindowByMode } from './_helpers/launch-readiness';
import { sumOfDeclaredBoundsMs } from './_helpers/parse-timeouts';
import {
PTY_PLATFORM_SKIP_REASON,
@@ -35,7 +35,7 @@ import {
settleBudget,
} from './_helpers/settled-reading';
import { expect, test } from './_helpers/smoke-test';
-import { waitForShellReady } from './_helpers/terminal-ready';
+import { captureTerminalStartupDiagnostics, waitForShellReady } from './_helpers/terminal-ready';
import {
buildInputReadyProbe,
seedTerminalShellProfiles,
@@ -127,6 +127,7 @@ function seed(prefix: string, opts: SeedOpts = {}): Seed {
interface LaunchOpts {
restrictPath?: boolean;
connectionsAvailable?: boolean;
+ phaseTrace?: boolean;
}
async function launchApp(s: Seed, opts: LaunchOpts = {}): Promise<ElectronApplication> {
@@ -151,6 +152,7 @@ async function launchApp(s: Seed, opts: LaunchOpts = {}): Promise<ElectronApplic
restrictPath: opts.restrictPath,
}),
OK_DESKTOP_E2E_SMOKE: '1',
+ OK_PTY_PHASE_TRACE: opts.phaseTrace ? '1' : '',
OK_RECLAIM_DISABLE: opts.connectionsAvailable ? '0' : '1',
OK_M6B_FORCE: opts.connectionsAvailable ? '1' : '0',
},
@@ -355,7 +357,10 @@ async function waitForStatus(
page: Page,
status: string,
timeoutMs = 20_000,
- { foreground = 'shell' }: { foreground?: 'shell' | 'program' } = {},
+ {
+ foreground = 'shell',
+ onPrimaryPromptFailure,
+ }: { foreground?: 'shell' | 'program'; onPrimaryPromptFailure?: () => Promise<void> } = {},
): Promise<void> {
await expect(terminalStatus(page)).toHaveAttribute('data-terminal-status', status, {
timeout: timeoutMs,
@@ -364,10 +369,23 @@ async function waitForStatus(
await waitForShellReady(
() => readTerminalText(page),
(command) => typeInTerminal(page, `${command}\r`),
+ { onPrimaryPromptFailure },
);
}
}
+async function attachTerminalStartupDiagnostics(page: Page, home: string): Promise<void> {
+ await captureTerminalStartupDiagnostics({
+ readBootLog: () => readBootLog(home),
+ readTerminalDom: async () => ({
+ a11y: await page.locator('.xterm-accessibility').allTextContents(),
+ rows: await page.locator('.xterm-rows').allTextContents(),
+ }),
+ captureScreen: ({ quality }) => page.screenshot({ type: 'jpeg', quality }),
+ attach: (name, attachment) => test.info().attach(name, attachment),
+ });
+}
+
async function ensureBottomDock(page: Page): Promise<void> {
await expect(page.locator('#terminal-dock-panel')).toBeVisible({ timeout: 10_000 });
}
@@ -410,12 +428,14 @@ test.describe('Docked terminal — live Electron', () => {
test.setTimeout(sumOfDeclaredBoundsMs(test.info()));
const s = seed('default-on');
track(s.tmpHome, s.projectDir);
- const app = await launchApp(s, { restrictPath: true });
+ const app = await launchApp(s, { restrictPath: true, phaseTrace: true });
captureStderrFor(app, { home: s.tmpHome, cleanupDirs: [s.tmpHome, s.projectDir] });
const page = await findEditorWindow(app);
await configureDesktopGitRepositories(page, s.realProjectDir);
await openTerminal(app, page);
- await waitForStatus(page, 'running', 25_000);
+ await waitForStatus(page, 'running', 25_000, {
+ onPrimaryPromptFailure: () => attachTerminalStartupDiagnostics(page, s.tmpHome),
+ });
await expect(page.getByRole('dialog')).toHaveCount(0);
});
@@ -878,12 +898,14 @@ test.describe('Docked terminal — live Electron', () => {
test.setTimeout(sumOfDeclaredBoundsMs(test.info()));
const s = seed('ctrl-backtick', { consent: true });
track(s.tmpHome, s.projectDir);
- const app = await launchApp(s, { restrictPath: true });
+ const app = await launchApp(s, { restrictPath: true, phaseTrace: true });
captureStderrFor(app, { home: s.tmpHome, cleanupDirs: [s.tmpHome, s.projectDir] });
const page = await findEditorWindow(app);
await configureDesktopGitRepositories(page, s.realProjectDir);
await openTerminal(app, page);
- await waitForStatus(page, 'running', 25_000);
+ await waitForStatus(page, 'running', 25_000, {
+ onPrimaryPromptFailure: () => attachTerminalStartupDiagnostics(page, s.tmpHome),
+ });
const focusInTerminal = () =>
page.evaluate(() => {
diff --git a/packages/desktop/tests/unit/smoke-test-fixture-attach-conditional.test.ts b/packages/desktop/tests/unit/smoke-test-fixture-attach-conditional.test.ts
index 713e70b50..8c4ed26dc 100644
--- a/packages/desktop/tests/unit/smoke-test-fixture-attach-conditional.test.ts
+++ b/packages/desktop/tests/unit/smoke-test-fixture-attach-conditional.test.ts
@@ -2,7 +2,7 @@ import type { TestInfo } from '@playwright/test';
import { describe, expect, test } from 'vitest';
import { shouldAttachStderr } from '../smoke/_helpers/electron-stderr';
-describe('smoke-test fixture: shouldAttachStderr predicate', () => {
+describe('smoke-test fixture boot-log narration: shouldAttachStderr gate in emitBootGapLines', () => {
const ti = (status: TestInfo['status'], retry: number, retries: number): TestInfo =>
({
status,
@@ -76,13 +76,13 @@ describe('smoke-test fixture: shouldAttachStderr predicate', () => {
expect(shouldAttachStderr(noRetries)).toBe(true);
});
- test('flake-passed scenario from CI run 25616440454 — exact reproduction', () => {
+ test('flake-passed sequence: timed-out attempt then passing retry attaches no boot-log narration', () => {
expect(shouldAttachStderr(ti('timedOut', 0, 2))).toBe(false);
expect(shouldAttachStderr(ti('passed', 1, 2))).toBe(false);
});
- test('genuine failure scenario — final attempt failure surfaces stderr for triage', () => {
+ test('genuine failure sequence: only the final failing attempt attaches boot-log narration', () => {
expect(shouldAttachStderr(ti('timedOut', 0, 2))).toBe(false);
expect(shouldAttachStderr(ti('timedOut', 1, 2))).toBe(false);
expect(shouldAttachStderr(ti('timedOut', 2, 2))).toBe(true);