The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
fix(cli): avoid false Codex suggestion-menu holds (#1003)
Deea979e64cbad0
diff --git a/cli/e2e/composer.e2e.ts b/cli/e2e/composer.e2e.tsindex 3bbf86393..f35fa4108 100644--- a/cli/e2e/composer.e2e.ts+++ b/cli/e2e/composer.e2e.ts@@ -81,7 +81,7 @@ describe('a message goes only into the engine\'s own composer', () => {await until('the suggestions to be drawn', async () => (await d.capture(agent.tmuxPane)).includes('Set the AI model') || null, 15_000, 250)const refused = refusal(client, agent.id, 15_000)client.send('message', { agentId: agent.id, content: 'what changed?' })- expect(String((await refused).payload?.message)).toBe(`${name(engine)} has a list of suggestions open in its prompt, where Enter would pick one. Close it with Esc in its terminal, then send the message again.`)+ expect(String((await refused).payload?.message)).toBe(`${name(engine)} message not sent. Close suggestions with Esc in its terminal, then retry.`)await d.tmux.run('send-keys', '-t', agent.tmuxPane, 'Escape', 'BSpace', 'BSpace', 'BSpace')await until('the suggestions to be put away', async () => !(await d.capture(agent.tmuxPane)).includes('Set the AI model') || null, 15_000, 250)await turn(client, agent.id, 'what changed?')@@ -101,6 +101,19 @@ describe('a message goes only into the engine\'s own composer', () => {client.close()})+ it('codex: command examples in the conversation do not block a message appended to an ordinary draft', async () => {+ const d = await fresh()+ const client = await LocalClient.connect(d)+ const agent = await create(d, client, 'codex', 'command-example')+ await turn(client, agent.id, 'Explain this command:\n /model choose what model to use')+ await d.tmux.run('send-keys', '-t', agent.tmuxPane, '-l', 'look in /model')+ await until('the ordinary draft to be drawn', async () => (await d.capture(agent.tmuxPane)).includes('› look in /model') || null, 15_000, 250)+ const started = client.next(isTurn('turn_started', agent.id), 15_000, 'the appended message')+ client.send('message', { agentId: agent.id, content: '/notes' })+ expect((await started).payload?.userMessage).toBe('look in /model/notes')+ client.close()+ })+it.each(engines)('%s: a message in CJK and emoji goes through in a narrow pane', async (engine) => {const d = await fresh()const client = await LocalClient.connect(d)diff --git a/cli/e2e/harness/fakeEngine.mjs b/cli/e2e/harness/fakeEngine.mjsindex 354cc30c8..436b6acfd 100644--- a/cli/e2e/harness/fakeEngine.mjs+++ b/cli/e2e/harness/fakeEngine.mjs@@ -526,6 +526,9 @@ export async function run(engine, config = {}, { native = false } = {}) {const suggestions = (text) => {const token = text.split(/\s/).at(-1) ?? ''if (bottom || token === dismissed || !/^[/@]/.test(token)) return null+ // Codex only suggests a slash command at the beginning of its first line (sync_command_popup).+ // A path in ordinary prose must not open a menu just because it ends the draft.+ if (engine === 'codex' && token.startsWith('/') && !text.startsWith('/')) return nullconst found = token.startsWith('/')? COMMANDS.filter(([name]) => name.startsWith(token)): FILES.filter((file) => file.startsWith(token.slice(1))).map((file) => [file, ''])diff --git a/cli/src/lib/composerScreen.spec.ts b/cli/src/lib/composerScreen.spec.tsindex 933772d10..8df9bd2d9 100644--- a/cli/src/lib/composerScreen.spec.ts+++ b/cli/src/lib/composerScreen.spec.ts@@ -102,6 +102,17 @@ describe('Codex\'s composer', () => {expect(composerState('codex', codexComposer('ask @sa'))).toBe('ready')})+ it('does not mistake conversation text for a popup after suggestions were dismissed', () => {+ const commandExample = ' /model choose what model and reasoning effort to use'+ expect(composerState('codex', `${commandExample}\n${codexComposer('/m')}`)).toBe('ready')+ // A path at the end of ordinary prose cannot open Codex's initial /command menu.+ expect(composerState('codex', `${commandExample}\n${codexComposer('look in /model')}`)).toBe('ready')+ const oldMenu = ['\u001b[1;7m› /model choose what model\u001b[0m', '', '• The menu is closed.']+ expect(composerState('codex', [...oldMenu, codexComposer('/m')].join('\n'))).toBe('ready')+ const oldMention = [' enter/tab insert · esc close · ↑/↓ select · ←/→ filter', '', '• The menu is closed.']+ expect(composerState('codex', [...oldMention, codexComposer('look at @src')].join('\n'))).toBe('ready')+ })+it('is absent under its session picker, whose highlighted row is drawn two columns in', () => {// resume_picker/layout.rs renders the list at `list.x + 2`, the header and search one column in, a dim// rule over its footer; the selected row is `› ` in the selection style (resume_picker.rsdiff --git a/cli/src/lib/composerScreen.ts b/cli/src/lib/composerScreen.tsindex ab47fb131..d86903728 100644--- a/cli/src/lib/composerScreen.ts+++ b/cli/src/lib/composerScreen.ts@@ -104,10 +104,17 @@ function codexComposer(lines: string[], raw: string[]): ComposerState {while (end < lines.length && lines[end].trim()) end++const footer = lines.slice(end).filter((line) => line.trim())if (footer.length > 3) return 'absent'- const draft = [lines[composer].replace(/^›\s?/, ''), ...lines.slice(composer + 1, end).map((line) => line.trim())].join(' ').trim()+ const draft = [lines[composer].replace(/^[›»]\s?/, ''), ...lines.slice(composer + 1, end).map((line) => line.trim())].join(' ').trim()const token = typedToken(draft)- const above = lines.slice(Math.max(0, composer - 20), composer)- if (token.startsWith('/') && above.some((line) => /^(?:›\s*|\s+)\/[\w-]+\s{2,}\S/.test(line))) return 'popup'+ // A voice send was refused as popup_open even though the recording had transcribed. Looking through+ // twenty conversation rows also matched command examples and old menu hints. A popup is the block+ // immediately above the composer; a slash menu has a selected row and edits the initial /command.+ let popupEnd = composer - 1+ while (popupEnd >= 0 && !lines[popupEnd].trim()) popupEnd--+ let popupStart = popupEnd+ while (popupStart >= Math.max(0, composer - 20) && lines[popupStart].trim()) popupStart--+ const above = lines.slice(popupStart + 1, popupEnd + 1)+ if (draft.startsWith('/') && token.startsWith('/') && above.some((line) => /^›\s+\/[\w-]+(?:\s{2,}\S|$)/.test(line))) return 'popup'if (token.startsWith('@') && above.some((line) => /\benter\/tab insert · esc close\b/.test(line))) return 'popup'return 'ready'}diff --git a/cli/src/lib/messageHold.spec.ts b/cli/src/lib/messageHold.spec.tsindex f5a91c051..dccc207b9 100644--- a/cli/src/lib/messageHold.spec.ts+++ b/cli/src/lib/messageHold.spec.ts@@ -222,7 +222,7 @@ describe('what the person is told', () => {'Claude Code is asking whether to update. Answer it in its terminal, then send the message again.','Claude Code is asking whether to switch to a new model. Answer it in its terminal, then send the message again.','Claude Code is asking how to sign in. Sign in in its terminal, then send the message again.',- 'Claude Code has a list of suggestions open in its prompt, where Enter would pick one. Close it with Esc in its terminal, then send the message again.',+ 'Claude Code message not sent. Close suggestions with Esc in its terminal, then retry.','Claude Code isn\'t showing its prompt; finish what\'s on its screen in its terminal, then send the message again.','Claude Code\'s screen could not be read, so the message was not typed. Send it again in a moment.',])diff --git a/cli/src/lib/messageHold.ts b/cli/src/lib/messageHold.tsindex b2f0706d1..13806bb1b 100644--- a/cli/src/lib/messageHold.ts+++ b/cli/src/lib/messageHold.ts@@ -125,7 +125,7 @@ export function messageHoldText(engine: string, hold: MessageHold): string {case 'sign_in_open':return `${name} is asking how to sign in. Sign in in its terminal, then send the message again.`case 'popup_open':- return `${name} has a list of suggestions open in its prompt, where Enter would pick one. Close it with Esc in its terminal, then send the message again.`+ return `${name} message not sent. Close suggestions with Esc in its terminal, then retry.`case 'prompt_hidden':return `${name} isn't showing its prompt; finish what's on its screen in its terminal, then send the message again.`case 'screen_unreadable':