From 19010487cb7355fe961e494b8d498a7a490271e0 Mon Sep 17 00:00:00 2001 From: Julius Olsson Date: Sat, 28 Nov 2026 02:58:42 -0800 Subject: [PATCH 1/4] docs(codex): plan the narrow terminal prompt correction --- .../2026-11-28-codex-terminal-root-prompt.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 docs/plans/2026-11-28-codex-terminal-root-prompt.md diff --git a/docs/plans/2026-11-28-codex-terminal-root-prompt.md b/docs/plans/2026-11-28-codex-terminal-root-prompt.md new file mode 100644 index 000000000..cea923a79 --- /dev/null +++ b/docs/plans/2026-11-28-codex-terminal-root-prompt.md @@ -0,0 +1,17 @@ +# Deliver to an empty native Codex pane at narrow widths + +## Reproduction and source + +The same installed 0.172.0 PTY at 40 columns refuses delivery before writing. +An empty 120-column pane accepts one transport write. Both refuse a typed draft. +The app uses the same provider delivery code for both display modes. Terminal +view fits the PTY to the tile. In the verified narrow footer the CLI retains +its agents shortcut and omits its shortcuts label. + +## Changes and checks + +1. Protect the observed empty and drafted footer shapes at the parser boundary. +2. Update the pinned parser with only the verified dedicated-footer rule. +3. Exercise normal provider delivery with a disposable native CLI and local-only + model endpoint. Check writes, readback and draft preservation. +4. Keep caller, transport, modal and settled-frame guards intact. From 2dcfe1e4db2c98ed25d2cf73bc9982a93e25ea03 Mon Sep 17 00:00:00 2001 From: Julius Olsson Date: Sat, 28 Nov 2026 03:00:02 -0800 Subject: [PATCH 2/4] fix(codex): allow Root Management delivery to empty narrow panes Pin the focused provider correction that recognizes the native compact footer hint. Both Root Management and orchestration keep the same reserved delivery path and draft checks. Refs #1568 --- docs/plans/2026-11-28-codex-terminal-root-prompt.md | 9 +++++++++ packages/codex-headless | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/docs/plans/2026-11-28-codex-terminal-root-prompt.md b/docs/plans/2026-11-28-codex-terminal-root-prompt.md index cea923a79..8b89bc6b4 100644 --- a/docs/plans/2026-11-28-codex-terminal-root-prompt.md +++ b/docs/plans/2026-11-28-codex-terminal-root-prompt.md @@ -15,3 +15,12 @@ its agents shortcut and omits its shortcuts label. 3. Exercise normal provider delivery with a disposable native CLI and local-only model endpoint. Check writes, readback and draft preservation. 4. Keep caller, transport, modal and settled-frame guards intact. + +## Verified mechanism + +On the same local fixture, 20–56 columns showed the agents-only hint and +64, 80 and 120 columns showed both hints. At 40 columns the baseline returned +occupied with zero writes, while the wide empty control accepted one write. +A typed draft, including the exact placeholder text, remained unsent. +The verified provider change is codex-headless commit 5e246e1. It uses +the CLI's empty-only agents-navigation contract and does not match status-line paths. diff --git a/packages/codex-headless b/packages/codex-headless index b225d4517..5e246e176 160000 --- a/packages/codex-headless +++ b/packages/codex-headless @@ -1 +1 @@ -Subproject commit b225d4517650c7271c42c4a43f01300a97a7d668 +Subproject commit 5e246e176b140f596d888c594e80fa8adc020b78 From adc432dfdce1a12a144a9f710827ca87076bc91d Mon Sep 17 00:00:00 2001 From: Julius Olsson Date: Sat, 28 Nov 2026 03:01:27 -0800 Subject: [PATCH 3/4] fix(codex): accept verified empty panes with a wrapped footer --- docs/plans/2026-11-28-codex-terminal-root-prompt.md | 7 ++++++- packages/codex-headless | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/plans/2026-11-28-codex-terminal-root-prompt.md b/docs/plans/2026-11-28-codex-terminal-root-prompt.md index 8b89bc6b4..26f8c6b52 100644 --- a/docs/plans/2026-11-28-codex-terminal-root-prompt.md +++ b/docs/plans/2026-11-28-codex-terminal-root-prompt.md @@ -22,5 +22,10 @@ On the same local fixture, 20–56 columns showed the agents-only hint and 64, 80 and 120 columns showed both hints. At 40 columns the baseline returned occupied with zero writes, while the wide empty control accepted one write. A typed draft, including the exact placeholder text, remained unsent. -The verified provider change is codex-headless commit 5e246e1. It uses +The verified provider change is codex-headless commit db20263. It uses the CLI's empty-only agents-navigation contract and does not match status-line paths. + +Independent review identified a second layout at 20–32 columns: the model and +path occupy two physical rows. Both recorded shapes initially failed. The +parser now validates both status fragments together and checks only the final +footer row for the shortcut. All 26 classifier tests pass. diff --git a/packages/codex-headless b/packages/codex-headless index 5e246e176..db2026371 160000 --- a/packages/codex-headless +++ b/packages/codex-headless @@ -1 +1 @@ -Subproject commit 5e246e176b140f596d888c594e80fa8adc020b78 +Subproject commit db20263718942dc64a5ea1ab64d5c8aae994b4ac From dad58125b19b163a986a10d8c71f3cb9d803ed86 Mon Sep 17 00:00:00 2001 From: Julius Olsson Date: Sat, 28 Nov 2026 03:02:17 -0800 Subject: [PATCH 4/4] test(codex): exercise Root Management delivery in real terminal panes --- testing/live/codex-root-prompt.test.ts | 92 ++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 testing/live/codex-root-prompt.test.ts diff --git a/testing/live/codex-root-prompt.test.ts b/testing/live/codex-root-prompt.test.ts new file mode 100644 index 000000000..c35791645 --- /dev/null +++ b/testing/live/codex-root-prompt.test.ts @@ -0,0 +1,92 @@ +import { mkdir, mkdtemp, readFile, readdir, realpath, rm, writeFile } from 'node:fs/promises' +import { tmpdir } from 'node:os' +import { join } from 'node:path' +import { expect, it, vi } from 'vitest' + +// Both views send Root Management prompts through the same SessionManager +// entry. The fitted Terminal view can give Codex 40 columns, whereas the +// headless Agent view usually gives it enough space for the full shortcut hint. +// Vitest runs in Node. SessionManager also resolves its bundled helpers at +// spawn, which requires Electron's app path even for a Codex-only fixture. +vi.mock('electron', () => ({ app: { getAppPath: () => process.cwd(), getPath: () => process.env.HOME } })) + +const live = it.skipIf(process.env.CODEX_ROOT_PROMPT_LIVE !== '1') + +live.each([24, 40, 120])('delivers into an empty %i-column native Codex pane and preserves a real draft', async cols => { + const home = await realpath(await mkdtemp(join(tmpdir(), 'codex-root-prompt-'))) + const config = join(home, '.codex') + const cwd = join(home, 'workspace') + const prompt = 'Root prompt local fixture' + let manager: import('@main/sessionManager').SessionManager | undefined + try { + vi.stubEnv('HOME', home) + vi.stubEnv('CODEX_HOME', config) + vi.stubEnv('CODEX_ROOT_PROMPT_FIXTURE_KEY', 'local-fixture') + await Promise.all([mkdir(cwd), mkdir(config)]) + await writeFile(join(config, 'config.toml'), [ + 'model = "gpt-6-sol"', 'model_provider = "local_fixture"', + '[model_providers.local_fixture]', 'name = "Local fixture"', 'base_url = "http://127.0.0.1:9/v1"', + 'wire_api = "responses"', 'env_key = "CODEX_ROOT_PROMPT_FIXTURE_KEY"', + `[projects.${JSON.stringify(cwd)}]`, 'trust_level = "trusted"', + ].join('\n')) + const { SessionManager } = await import('@main/sessionManager') + manager = new SessionManager() + const host = manager + function replyToTerminalQueries(sessionId: string, data: string) { + if (data.includes('\x1b[6n')) host.write(sessionId, '\x1b[1;1R') + if (data.includes('\x1b[c')) host.write(sessionId, '\x1b[?1;2c') + } + host.on('agent-pty-data', ({ sessionId, data }) => replyToTerminalQueries(sessionId, data)) + for (const hasDraft of [true, false]) { + const { sessionId } = await host.spawn({ kind: 'codex', cwd, cols, rows: 44, useProxy: false }) + replyToTerminalQueries(sessionId, host.attachAgentPty(sessionId) ?? '') + const screen = () => host.getScreenSnapshot(sessionId)?.plain ?? '' + await vi.waitFor(() => expect(screen()).toMatch(/^ ← for agents\b/m), { timeout: 15_000 }) + const placeholder = /^› (.+)$/m.exec(screen())?.[1]?.trim() + if (!placeholder) throw new Error('Expected the native Codex placeholder at the editor cursor') + if (hasDraft) { + // The same words can be either a dim suggestion or human-entered text. + // Wait for Codex's hint to leave so the subsequent receipt is decisive. + host.write(sessionId, placeholder) + await vi.waitFor(() => { + expect(screen()).toContain(`› ${placeholder}`) + expect(screen()).not.toMatch(/^ ← for agents\b/m) + }) + } + + const result = await host.deliverPromptToAgent(sessionId, prompt) + if (hasDraft) { + expect(result).toMatchObject({ + ok: false, stage: 'before-write', code: 'not-ready', disposition: 'retry-after-resolve', + promptWritten: false, enterWritten: false, + }) + expect(screen()).toContain(`› ${placeholder}`) + expect(screen()).not.toContain(prompt) + } else { + expect(result, JSON.stringify({ result, footer: screen().split('\n').filter(Boolean).slice(-4) })).toMatchObject({ ok: true, acceptance: { kind: 'transport' } }) + // A transport receipt alone cannot establish that Codex committed the + // text. Its local rollout does, independent of the fixture's closed + // endpoint and independent of Agent Code's transcript attachment. + const sessionsDir = join(config, 'sessions') + await vi.waitFor(async () => { + const names = await readdir(sessionsDir, { recursive: true }) + const records = await Promise.all(names.filter(name => name.endsWith('.jsonl')) + .map(name => readFile(join(sessionsDir, name), 'utf8'))) + expect(records.some(data => data.split('\n').some(line => { + if (!line.includes(prompt)) return false + try { + const row = JSON.parse(line) + return row.type === 'response_item' && row.payload?.role === 'user' && + row.payload.content?.some((block: { text?: string }) => block.text === prompt) + } catch { return false } + }))).toBe(true) + }, { timeout: 8_000 }) + } + await host.kill(sessionId) + } + } finally { + await manager?.killAll() + vi.unstubAllEnvs() + await rm(home, { recursive: true, force: true }) + } +}, 55_000)