Skip to content
Open
Show file tree
Hide file tree
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
26 changes: 26 additions & 0 deletions docs/plans/2026-11-28-codex-readable-narrow-steps.md
Original file line number Diff line number Diff line change
@@ -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.
14 changes: 9 additions & 5 deletions src/providers/codex/renderer/components/script-steps/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ function mcpRefused(text: string): boolean {

function Verdict({ result }: { result: ScriptResult | undefined }) {
const badge = verdict(result)
return badge ? <span className={`ml-auto shrink-0 font-code text-[11px] ${badge.tone}`} aria-label={badge.label}>{badge.text}</span> : null
return badge ? <span className={`ml-auto max-w-full shrink-0 wrap-anywhere font-code text-[11px] ${badge.tone}`} aria-label={badge.label}>{badge.text}</span> : null
}

/**
Expand Down Expand Up @@ -161,10 +161,14 @@ function ResultBody({ result }: { result: ScriptResult }): ReactNode {
function StepLine({ step, result, time }: { step: ScriptStep; result?: ScriptResult; time?: string | null }) {
return (
<div className="flex flex-col gap-0.5" data-script-step={step.kind}>
<div className="flex min-w-0 items-baseline gap-2 text-[12.5px]">
<span aria-hidden className="w-3 shrink-0 text-center font-code text-muted">{GLYPH[step.kind]}</span>
{step.kind !== 'command' && <span className="shrink-0 font-code text-ink">{step.title}</span>}
<span className={`min-w-0 truncate font-code ${step.kind === 'command' ? 'text-ink' : 'text-muted'}`} title={step.detail}>{step.detail}</span>
{/* 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. */}
<div className="flex min-w-0 flex-wrap items-baseline gap-x-2 gap-y-0.5 text-[12.5px]">
<span className="inline-flex max-w-full items-baseline gap-2">
<span aria-hidden className="w-3 shrink-0 text-center font-code text-muted">{GLYPH[step.kind]}</span>
{step.kind !== 'command' && <span className="min-w-0 wrap-anywhere font-code text-ink">{step.title}</span>}
</span>
{step.detail && <span className={`min-w-0 flex-[1_1_5ch] truncate font-code ${step.kind === 'command' ? 'text-ink' : 'text-muted'}`} title={step.detail}>{step.detail}</span>}
<Verdict result={result} />
{time && <span className="shrink-0 font-code text-[11px] text-muted">{time}</span>}
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -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(<CodexScriptStepsRow model={{
steps: [{ kind: 'mcp', title, detail }], results: [{ kind: 'mcp', text: '{}', isError: true, index: 0 }],
paired: true, wallSeconds: 15.2, status: 'completed', exactOutput: '{}', truncatedTokens: null,
}} />)

// 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(`<article style="font-family:monospace">${html}</article>`)
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()
}
})
Loading