diff --git a/docs/plans/2026-11-28-codex-readable-narrow-steps.md b/docs/plans/2026-11-28-codex-readable-narrow-steps.md new file mode 100644 index 000000000..329872aa7 --- /dev/null +++ b/docs/plans/2026-11-28-codex-readable-narrow-steps.md @@ -0,0 +1,26 @@ +# Readable Codex tool steps in narrow lanes + +## Evidence + +Chromium reproduced the B25 screenshot with a 175 CSS-pixel card. +The tool name and trailing status cannot shrink; the argument gets zero width. +A paired duration ends outside the card. A 340-pixel card has space for the same call. +The exact-output disclosure works at both widths. + +## Change + +Allow the existing tool label, argument and outcome to move onto additional lines when needed. +Keep the glyph attached to the tool name. Preserve the compact row where space permits. + +## Verification + +Measure element and text bounds in Chromium at 175 and 340 CSS pixels. +Cover the paired call and the unpaired layout visible in the report. +Run the existing Codex script-step renderer tests and the focused layout regression. + +## Results + +The Chromium regression failed on the original row and passed after reflow. +At 175px the unpaired argument grew from 0px to 161px. The paired duration now +stays inside the card. At 340px the paired argument remains 108px in the same +single-line layout. The exact-output disclosure opened at 175px after the change. diff --git a/src/providers/codex/renderer/components/script-steps/index.tsx b/src/providers/codex/renderer/components/script-steps/index.tsx index 324872642..950eef161 100644 --- a/src/providers/codex/renderer/components/script-steps/index.tsx +++ b/src/providers/codex/renderer/components/script-steps/index.tsx @@ -107,7 +107,7 @@ function mcpRefused(text: string): boolean { function Verdict({ result }: { result: ScriptResult | undefined }) { const badge = verdict(result) - return badge ? {badge.text} : null + return badge ? {badge.text} : null } /** @@ -161,10 +161,14 @@ function ResultBody({ result }: { result: ScriptResult }): ReactNode { function StepLine({ step, result, time }: { step: ScriptStep; result?: ScriptResult; time?: string | null }) { return (
-
- {GLYPH[step.kind]} - {step.kind !== 'command' && {step.title}} - {step.detail} + {/* Give the argument a few characters before wrapping. A zero basis let long MCP + names push the entire argument (including its hover target) and outcome offscreen. */} +
+ + {GLYPH[step.kind]} + {step.kind !== 'command' && {step.title}} + + {step.detail && {step.detail}} {time && {time}}
diff --git a/src/providers/codex/renderer/components/script-steps/layout.system.test.tsx b/src/providers/codex/renderer/components/script-steps/layout.system.test.tsx new file mode 100644 index 000000000..6a69c5cc8 --- /dev/null +++ b/src/providers/codex/renderer/components/script-steps/layout.system.test.tsx @@ -0,0 +1,52 @@ +import { readFile } from 'node:fs/promises' +import { createRequire } from 'node:module' +import { renderToStaticMarkup } from 'react-dom/server' +import { chromium } from 'playwright-core' +import { compile } from 'tailwindcss' +import { expect, it } from 'vitest' + +import { chromiumExecutable } from '@main/browserPocket/testing/chromiumHarness' +import { CodexScriptStepsRow } from './index' + +const require = createRequire(import.meta.url) + +it.skipIf(!chromiumExecutable)('keeps Codex tool identity, argument and outcome inside narrow cards', { timeout: 20_000 }, async () => { + const title = 'ac_agents_draft_get' + const detail = 'B25 selected session' + const html = renderToStaticMarkup() + + // jsdom cannot tell us that a hoverable argument is zero pixels wide. Use the + // real component's Tailwind utilities and Chromium layout, without an app build. + const theme = await readFile(require.resolve('tailwindcss/theme.css'), 'utf8') + const utilities = await compile(theme + '\n@tailwind utilities;') + const classes = Array.from(html.matchAll(/class="([^"]+)"/g), match => match[1]!).join(' ').split(/\s+/) + const browser = await chromium.launch({ executablePath: chromiumExecutable }) + try { + const page = await browser.newPage() + await page.setContent(`
${html}
`) + await page.addStyleTag({ content: utilities.build(classes) }) + + for (const width of [175, 340]) { + await page.locator('article').evaluate((card, w) => { card.style.width = w + 'px' }, width) + const card = (await page.locator('article').boundingBox())! + const parts = [ + page.getByText(title, { exact: true }), page.getByTitle(detail), page.getByLabel('failed'), page.getByText('15.2 s'), + ] + const boxes = await Promise.all(parts.map(async part => (await part.boundingBox())!)) + for (const box of boxes) { + expect(box.width).toBeGreaterThan(12) + expect(box.x).toBeGreaterThanOrEqual(card.x - 1) + expect(box.x + box.width).toBeLessThanOrEqual(card.x + width + 1) + } + // Wide rows retain the compact single-line presentation; narrow rows wrap. + const [name, , , duration] = boxes + if (width === 340) expect(Math.abs(name!.y - duration!.y)).toBeLessThan(5) + else expect(duration!.y).toBeGreaterThan(name!.y + 5) + } + } finally { + await browser.close() + } +})