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
Read Codex's question dialog, so the dial can show it and close it
0xdiego2512a63a919e3e
diff --git a/cli/src/cable/cableSession.ts b/cli/src/cable/cableSession.tsindex f1ef7237b..7b547d8fa 100644--- a/cli/src/cable/cableSession.ts+++ b/cli/src/cable/cableSession.ts@@ -711,6 +711,7 @@ export class CableSession {this.greetedMac = macthis.greetedFw = fwthis.log(`cable: dial ${mac} ${returning ? 'back ' : ''}on fw ${fw} proto ${msg.proto}`)+ this.dialLog.greeted()this.host.onDialStatus?.({ attached: true, fw })// BEFORE the state push, not after: the push reads the selected machine, and for a remote one// that means an RPC over a lane this is what re-opens.diff --git a/cli/src/cable/dialLog.spec.ts b/cli/src/cable/dialLog.spec.tsindex 8e2113367..ddfd2e9db 100644--- a/cli/src/cable/dialLog.spec.ts+++ b/cli/src/cable/dialLog.spec.ts@@ -88,6 +88,19 @@ describe('DialLog', () => {expect(text).toMatch(/dial heartbeat back after 121s/)})+ it('restarts the watch when the dial greets again (a reboot on an open port)', async () => {+ const d = dir()+ const c = clock()+ const log = new DialLog(d, { now: c.now, heartbeatGapMs: 90_000 })+ log.device('I (60000) ui: alive up=60s')+ c.advance(80_000)+ log.greeted() // OTA reboot: hello arrives, ticks go back to zero+ c.advance(30_000)+ log.tick(true) // 110s since the last beat, but only 30s since the greeting+ await log.flush()+ expect(readFileSync(log.currentPath, 'utf8')).not.toMatch(/no dial heartbeat/)+ })+it('does not chase a heartbeat while the port is closed', async () => {const d = dir()const c = clock()diff --git a/cli/src/cable/dialLog.ts b/cli/src/cable/dialLog.tsindex 46687095a..c24d550f0 100644--- a/cli/src/cable/dialLog.ts+++ b/cli/src/cable/dialLog.ts@@ -98,6 +98,16 @@ export class DialLog {}}+ /**+ * The dial greeted — a fresh boot, or a reconnect. Its first `alive` comes a minute after boot, so the+ * watch restarts from now rather than from the last beat of the previous boot; without this an OTA+ * reboot (port never closed, ticks back to zero) read as "no heartbeat for 90s" every time.+ */+ greeted(): void {+ this.lastHeartbeat = this.now()+ this.gapMarked = false+ }+/** Every queued write has reached the file. */flush(): Promise<void> {return this.chaindiff --git a/cli/src/cli.ts b/cli/src/cli.tsindex d4164231a..5e9b5b983 100644--- a/cli/src/cli.ts+++ b/cli/src/cli.ts@@ -1418,6 +1418,7 @@ async function runForeground(session: AuthSession): Promise<void> {let emitSessionEvents = (sessionId: string,events: ReturnType<CursorNormalizer['ingest']>,+ _opts?: { resumed?: boolean },): void => {if (events.length) queuedSessionEvents.push({ sessionId, events })}@@ -1705,7 +1706,7 @@ async function runForeground(session: AuthSession): Promise<void> {const opened = historyEvents.findLast((event) => event.type === 'turn_started')if (opened) {console.log(`[agent] ${sid(session.agentId)} resumed the turn already open at attach`)- emitSessionEvents(session.sessionId, [opened])+ emitSessionEvents(session.sessionId, [opened], { resumed: true })}}// Watch this pane for a question from ATTACH, not only from the next turn_started.@@ -2039,7 +2040,7 @@ async function runForeground(session: AuthSession): Promise<void> {heartbeats.set(sessionId, timer)}- emitSessionEvents = (sessionId: string, events: ReturnType<CursorNormalizer['ingest']>): void => {+ emitSessionEvents = (sessionId: string, events: ReturnType<CursorNormalizer['ingest']>, opts?: { resumed?: boolean }): void => {if (!events.length || !registry.bySession(sessionId)?.active) returnfor (const event of events) {const agentId = agentIdFor(sessionId)@@ -2051,8 +2052,10 @@ async function runForeground(session: AuthSession): Promise<void> {autonomousDeviceService?.turnStarted(agentId)startHeartbeat(sessionId)questionWatcher.start(sessionId) // Claude opens its dialog INSIDE a turn- // ...and anything already drawn belongs to the turn BEFORE this one.- questionWatcher.noteTurnStart(sessionId)+ // ...and anything already drawn belongs to the turn BEFORE this one — unless this is a turn the+ // daemon is picking back up at attach: a dialog on the pane then is THIS turn's, still waiting,+ // and marking it pre-turn is how a restarted daemon never announced a question Codex had open.+ if (!opts?.resumed) questionWatcher.noteTurnStart(sessionId)} else if (event.type === 'turn_ended') {const startedAt = turnStartedAt.get(sessionId)turnStartedAt.delete(sessionId)diff --git a/cli/src/engines/codex/askQuestion.spec.ts b/cli/src/engines/codex/askQuestion.spec.tsnew file mode 100644index 000000000..d84a9202a--- /dev/null+++ b/cli/src/engines/codex/askQuestion.spec.ts@@ -0,0 +1,31 @@+import { describe, expect, it } from 'vitest'+import { readFileSync } from 'fs'+import { fileURLToPath } from 'url'+import { parseEngineQuestionPane } from '../../lib/askQuestion.js'++function fixture(name: string): string {+ return readFileSync(fileURLToPath(new URL(`../../lib/__fixtures__/${name}`, import.meta.url)), 'utf-8')+}++describe('Codex question dialog', () => {+ it('reads a request_user_input dialog and keeps only the option labels', () => {+ // Captured live (plan mode, 0.149): the footer is `enter to submit answer | esc to interrupt`, and+ // each row carries its description in an aligned column after the label.+ expect(parseEngineQuestionPane('codex', fixture('question-codex.txt'))).toMatchObject({+ kind: 'question',+ question: 'Which colour should the demo use?',+ rows: [+ { number: '1', label: 'Red' },+ { number: '2', label: 'Green' },+ ],+ multi: false,+ })+ })++ it('still reads the approval prompt, whose rows have no description column', () => {+ const view = parseEngineQuestionPane('codex', fixture('permission-codex.txt'))+ expect(view?.kind).toBe('question')+ if (view?.kind !== 'question') return+ expect(view.rows[0].label).toMatch(/^Yes/)+ })+})diff --git a/cli/src/lib/__fixtures__/question-codex.txt b/cli/src/lib/__fixtures__/question-codex.txtnew file mode 100644index 000000000..da4710b34--- /dev/null+++ b/cli/src/lib/__fixtures__/question-codex.txt@@ -0,0 +1,22 @@+ … +7 lines (ctrl + t to view transcript)+ cf-ray: a3b637453e6107b1-HKG+────────────────────────────────────────────────+• HTTP/2 200+────────────────────────────────────────────────+› I want a tiny plan for a demo page. Before+ planning, ask me ONE multiple-choice question+ with your request_user_input tool: "Which+ colour should the demo use?" with options+ red, green, blue. After my answer, write a 2-+ line plan mentioning the colour.+• I’ll lock the demo’s visual direction first.+• Working (1s • esc to interrupt)+› Ask Codex to do anything+ gpt-5.6-terra medium · ~/Working/… Plan mode+ Question 1/1 (1 unanswered)+ Which colour should the demo use?+ › 1. Red Creates a bold, high-contrast+ accent.+ 2. Green Creates a fresh, success-+ option 1/4 | tab to add notes+ enter to submit answer | esc to interruptdiff --git a/cli/src/lib/askQuestion.ts b/cli/src/lib/askQuestion.tsindex 00d6245d5..85bb906d9 100644--- a/cli/src/lib/askQuestion.ts+++ b/cli/src/lib/askQuestion.ts@@ -178,9 +178,25 @@ export function parseEngineQuestionPane(engine: AgentEngine, capture: string): Pconst plain = unframe(capture)return opencodeReview(plain) ?? parseQuestionPane(plain)}+ if (engine === 'codex') return withCodexLabels(parseQuestionPane(capture))return parseQuestionPane(capture)}+/**+ * Codex's request_user_input rows carry the option's description on the same line as its label, in+ * an aligned column — `1. Red Creates a bold, high-contrast` — and wrap the rest of the description+ * onto plain lines below. The label is the part before the column gap; the dial has an 80-byte option+ * buffer and a 466px face, and "Red" is what the person is choosing. The approval prompt's rows+ * (`Yes, proceed (y)`) have no such gap and pass through unchanged.+ */+function withCodexLabels(view: PaneView): PaneView {+ if (!view || view.kind !== 'question') return view+ return {+ ...view,+ rows: view.rows.map((r) => ({ ...r, label: r.label.split(/\s{2,}/)[0].trim() || r.label })),+ }+}+/*** Strip the box-drawing frame Hermes draws around its `clarify` dialog.*@@ -450,7 +466,11 @@ export function parseQuestionPane(capture: string): PaneView {// Each CLI words its own footer, and OpenCode rewords it PER SCREEN — `enter submit` on a single// question, `enter toggle` on a multi-select, `enter confirm` on a step of a multi-question. They all// mark the same thing: the bottom of a live dialog.- const footer = lines.findLastIndex((l) => /enter to (select|confirm)|enter\s+(submit|confirm|toggle)/i.test(l))+ // `enter to submit answer` is Codex's request_user_input dialog (plan mode; captured live in+ // __fixtures__/question-codex.txt). Without it that dialog was never a question at all here: the dial+ // showed nothing while the pane waited, and a question it DID show could never be closed, because+ // the watcher had no fingerprint to notice leaving.+ const footer = lines.findLastIndex((l) => /enter to (select|confirm|submit)|enter\s+(submit|confirm|toggle)/i.test(l))// The review screen paints no footer and puts its rows BELOW the prompt, so it needs its own anchor.// Whichever anchor is LOWER on screen is the live one (the other is scrollback from an earlier step).const review = lines.findLastIndex((l) => /Ready to submit your answers/i.test(l))