Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.
TypeScript adhdagent-orchestrationai-agentscanvasclaude-codecodexcoding-agentsdeveloper-toolselectrongeminilinuxmacosmultiplexeropencodeparallel-agentsterminalterminal-emulatorterminal-multiplexertmuxworkspace-manager
Quality-of-life improvements for Chat question card (#979)
Paul Robertsonc8c0cca7cfb0
diff --git a/docs/hook-reply-approvals.md b/docs/hook-reply-approvals.mdindex 51f26fc09..3ee77e9b5 100644--- a/docs/hook-reply-approvals.md+++ b/docs/hook-reply-approvals.md@@ -158,7 +158,11 @@ same order. That is why a held question also carries its texts (`held.questions`before edits", "Revise…" (feedback → `plan-revise`). Question: radio (single) / checkbox (multiSelect),an "Other" text field (the only input on a question with no options), Submit once every question isanswered; a multi-select "Other" joins the ticked labels and the text with `", "` as one free-text-answer. The ticket is re-checked against the store at send time; `false` (or a rejection) shows+answer, the text quoted (inner quotes escaped) when it contains a comma or a quote — Claude Code's own+picker format, MEASURED on 2.1.283 (`Red, Blue, "teal, sort of"`, `Red, teal`), so the model can tell+the user's words from the labels. "Chat about this" (`question-clarify`) declines the question: a deny+whose message is the native clarify text, built by core from the pending file's questions; no+`interrupt`, so Claude asks what to clarify and stops at the prompt. The ticket is re-checked against the store at send time; `false` (or a rejection) shows"Couldn't send — answer in the terminal (⌘M)" and leaves the controls usable — never a stuck "Sent".While controls are up, the composer placeholder and the status row point at the card(`chatComposerPlaceholder({answerOnCard})`). The kanban card modal mounts the same `ChatPanel`, so thediff --git a/src/core/agents/permission-decision.test.ts b/src/core/agents/permission-decision.test.tsindex 4820d2139..3101eae7f 100644--- a/src/core/agents/permission-decision.test.ts+++ b/src/core/agents/permission-decision.test.ts@@ -6,6 +6,7 @@ import {labelHeldForRevision,MIN_STRUCTURED_ANSWER_REVISION,buildPermissionDecision,+ clarifyMessage,isBoundedAnswerContent,parsePermissionAnswer,parsePendingRequest,@@ -183,6 +184,31 @@ const SURFACES = 'Which surfaces should get it?'const ANSWER_1 = { [QUESTION_TEXT]: 'Kim kimi okuyabilir (context)' }const ANSWER_2 = { [SURFACES]: ['Desktop'] }+describe('buildPermissionDecision — question-clarify ("Chat about this")', () => {+ it('parses from untrusted input', () => {+ expect(parsePermissionAnswer({ kind: 'question-clarify' })).toEqual({ kind: 'question-clarify' })+ })++ it('is a deny carrying Claude Code\'s own clarify message, listing the HELD request\'s questions', () => {+ const r = buildPermissionDecision(QUESTION_REQ, { kind: 'question-clarify' })+ if (!r.ok) throw new Error(r.reason)++ const d = decisionOf(r.content)+ expect(r.decision).toBe('deny')+ expect(d.behavior).toBe('deny')+ expect(d.message).toBe(clarifyMessage([QUESTION_TEXT, 'Which surfaces should get it?']))+ expect(d.message).toContain('Start by asking them what they would like to clarify.')+ expect(d.message).toContain(`- "${QUESTION_TEXT}"\n (No answer provided)`)+ // The turn continues: Claude asks what to clarify, then stops at the prompt.+ expect(d).not.toHaveProperty('interrupt')+ })++ it('refuses a hold that is not a question', () => {+ expect(buildPermissionDecision(PLAN_REQ, { kind: 'question-clarify' }).ok).toBe(false)+ expect(buildPermissionDecision(null, { kind: 'question-clarify' }).ok).toBe(false)+ })+})+describe('buildPermissionDecision — question', () => {it('echoes the PENDING request\'s questions verbatim and adds answers keyed by the exact question text', () => {const r = buildPermissionDecision(QUESTION_REQ, {diff --git a/src/core/agents/permission-decision.ts b/src/core/agents/permission-decision.tsindex 4951ceab8..4c4edc03a 100644--- a/src/core/agents/permission-decision.ts+++ b/src/core/agents/permission-decision.ts@@ -109,6 +109,8 @@ export function parsePermissionAnswer(v: unknown): PermissionAnswer | null {: nullcase 'plan-revise':return typeof v.message === 'string' ? { kind: 'plan-revise', message: v.message } : null+ case 'question-clarify':+ return { kind: 'question-clarify' }case 'question': {if (!isPlainObject(v.answers)) return nullconst answers: Record<string, string | string[]> = Object.create(null)@@ -160,6 +162,23 @@ function questionIndex(toolInput: Record<string, unknown>): Map<string, Questionreturn index}+/**+ * What Claude Code tells the model when the user picks "Chat about this" in its own question picker+ * — MEASURED verbatim on 2.1.283 (the tool result after the native choice), minus the template's+ * stray indentation. The question texts come from the PENDING FILE, never from the renderer.+ */+export function clarifyMessage(questions: readonly string[]): string {+ return [+ 'The user wants to clarify these questions.',+ 'This means they may have additional information, context or questions for you.',+ 'Take their response into account and then reformulate the questions if appropriate.',+ 'Start by asking them what they would like to clarify.',+ '',+ 'Questions asked:',+ ...questions.map((q) => `- "${q}"\n (No answer provided)`)+ ].join('\n')+}+function buildQuestionDecision(pending: PendingRequest,answers: Record<string, string | string[]>,@@ -252,6 +271,14 @@ export function buildPermissionDecision(pending: PendingRequest | null, answer:case 'question':if (pending?.toolName !== ASK_USER_QUESTION_TOOL) return { ok: false, reason: 'the held request is not a question' }return buildQuestionDecision(pending, answer.answers, answer.freeText)+ case 'question-clarify': {+ if (pending?.toolName !== ASK_USER_QUESTION_TOOL) return { ok: false, reason: 'the held request is not a question' }+ const index = questionIndex(pending.toolInput)+ if (!index) return { ok: false, reason: 'the held question has no readable questions' }+ // No `interrupt`: the turn continues and Claude asks what the user wants to clarify, then+ // stops at the prompt — exactly where the native "Chat about this" leaves it.+ return capped(decisionJson({ behavior: 'deny', message: clarifyMessage([...index.keys()]) }), 'deny')+ }default:return { ok: false, reason: 'unknown answer' }}diff --git a/src/renderer/lib/chatAnswer.test.ts b/src/renderer/lib/chatAnswer.test.tsindex 9802a3ce2..e99f73e70 100644--- a/src/renderer/lib/chatAnswer.test.ts+++ b/src/renderer/lib/chatAnswer.test.ts@@ -16,6 +16,7 @@ import {answerTooLong,planReviseAnswer,questionAnswerFrom,+ quoteCustomItem,toggleLabel} from './chatAnswer'@@ -116,6 +117,31 @@ describe('questionAnswerFrom — UI selection → the structured answer core valfreeText: ['Which surfaces?']})})+ it('quotes a typed "Other" containing a comma, so the model can tell it from the labels', () => {+ const sel = emptySelection([MULTI])+ sel[0].labels = ['Desktop', 'Phone']+ sel[0].other = true+ sel[0].otherText = 'teal, sort of'++ expect(questionAnswerFrom([MULTI], sel)?.answers['Which surfaces?']).toBe('Desktop, Phone, "teal, sort of"')+ })++ it('quotes a lone typed "Other" on a multi choice by the same rule', () => {+ const sel = emptySelection([MULTI])+ sel[0].other = true+ sel[0].otherText = 'a, b'++ expect(questionAnswerFrom([MULTI], sel)?.answers['Which surfaces?']).toBe('"a, b"')+ })++ it('never quotes a single choice\'s "Other": it is the whole answer', () => {+ const sel = emptySelection([SINGLE])+ sel[0].other = true+ sel[0].otherText = 'neither, really'++ expect(questionAnswerFrom([SINGLE], sel)?.answers['Pick one?']).toBe('neither, really')+ })+it('a question with no options is answered by its text field alone', () => {const sel = emptySelection([FREE])sel[0].otherText = 'Ada'@@ -271,3 +297,11 @@ describe('rebindRetryDelay', () => {])})})++describe('quoteCustomItem — Claude Code\'s own multi-select quoting (measured, 2.1.283)', () => {+ it('matches the native picker on every measured answer', () => {+ expect(quoteCustomItem('teal, sort of')).toBe('"teal, sort of"')+ expect(quoteCustomItem('say "hi"')).toBe('"say \\"hi\\""')+ expect(quoteCustomItem('teal')).toBe('teal')+ })+})diff --git a/src/renderer/lib/chatAnswer.ts b/src/renderer/lib/chatAnswer.tsindex 995efaf98..57db02157 100644--- a/src/renderer/lib/chatAnswer.ts+++ b/src/renderer/lib/chatAnswer.ts@@ -167,18 +167,30 @@ export function toggleLabel(labels: readonly string[], label: string, on: booleareturn on ? [...rest, label] : rest}+/**+ * The typed "Other" as one item of a multi-select answer, quoted the way Claude Code's own picker+ * quotes it — MEASURED on 2.1.283: `Red, Blue, "teal, sort of"`, `Green, "say \"hi\""`, but+ * `Red, teal`. Quoted (with the inner quotes escaped) only when it contains a comma or a quote, so+ * the model can always tell where the user's own words start and end in the joined list.+ */+export function quoteCustomItem(text: string): string {+ return /[,"]/.test(text) ? JSON.stringify(text) : text+}+/*** The free text a question's answer would carry, or null when it is not a free-text answer. ONE* definition, so the text that is capped is the text that is sent: on a multi choice with "Other" it- * is the ticked labels (in option order) plus the typed text, joined with ", " — the TUI's own- * multi-select format, and one string because core carries one free-text answer per question.- * Core caps THAT string, so capping only the typed part let a long answer through to a refusal.+ * is the ticked labels (in option order) plus the typed text (`quoteCustomItem`), joined with ", " —+ * the TUI's own multi-select format, and one string because core carries one free-text answer per+ * question. Core caps THAT string, so capping only the typed part let a long answer through to a+ * refusal. A single choice's "Other" is the typed text as-is: it is the whole answer.*/function freeTextOf(q: ChatQuestion, sel: QuestionSelection): string | null {if (!sel.other && q.options.length > 0) return nullconst typed = sel.otherText.trim()+ if (!q.multiSelect || typed === '') return typedconst labels = q.options.map((o) => o.label).filter((l) => sel.labels.includes(l))- return q.multiSelect && labels.length && typed ? [...labels, typed].join(', ') : typed+ return [...labels, quoteCustomItem(typed)].join(', ')}/** The first question whose free-text answer is over the shared cap (core would refuse it), or null.diff --git a/src/renderer/nodes/ChatAnswerControls.tsx b/src/renderer/nodes/ChatAnswerControls.tsxindex d19500cd3..e82072005 100644--- a/src/renderer/nodes/ChatAnswerControls.tsx+++ b/src/renderer/nodes/ChatAnswerControls.tsx@@ -256,6 +256,19 @@ export function QuestionAnswerControls({ questions, onSubmit, agentLabel, chip }>Submit</button>+ {/* Claude Code's own escape hatch: decline the question and talk it over instead — Claude+ asks what you want to clarify and waits at the prompt, where the composer takes over. */}+ <button+ type="button"+ className="term-chat__answer-btn"+ aria-disabled={busy}+ title={`Decline the question — ${agentLabel} will ask what you'd like to clarify`}+ onClick={() => {+ if (!busy) void submit({ kind: 'question-clarify' })+ }}+ >+ Chat about this+ </button></div>{tooLong && (// The only incomplete state that is not visible on its own: the ticked labels plus the typeddiff --git a/src/renderer/nodes/ChatPanel.answers.test.tsx b/src/renderer/nodes/ChatPanel.answers.test.tsxindex 8c1ca6ddc..7040a41fc 100644--- a/src/renderer/nodes/ChatPanel.answers.test.tsx+++ b/src/renderer/nodes/ChatPanel.answers.test.tsx@@ -240,6 +240,17 @@ describe('question card', () => {expect(sent().answer).toEqual({ kind: 'question', answers: { 'Pick one?': 'neither' }, freeText: ['Pick one?'] })})+ it('"Chat about this" declines the question without picking anything — available at once', async () => {+ await hold('waiting', held(['Pick one?']))+ await mount([askMsg(0, [SINGLE])])+ const chat = button(cards()[0], 'Chat about this')+ expect(off(chat)).toBe(false)++ await click(chat)++ expect(sent()).toEqual({ nodeId: NODE, pendingId: 'n-q-1', answer: { kind: 'question-clarify' } })+ })+it('several questions: Submit waits for all of them', async () => {await hold('waiting', held(['Pick one?', 'Which surfaces?']))await mount([askMsg(0, [SINGLE, MULTI])])diff --git a/src/shared/agents/permission-answer.ts b/src/shared/agents/permission-answer.tsindex 136e53ec2..133295e74 100644--- a/src/shared/agents/permission-answer.ts+++ b/src/shared/agents/permission-answer.ts@@ -33,6 +33,8 @@ export const INTERACTIVE_HOLD_TOOLS: readonly string[] = [EXIT_PLAN_MODE_TOOL, A* option label, a string[] is several labels of a multiSelect question. A key listed in* `freeText` carries typed text (the picker's "Other") instead of a label — that is the ONLY way* an answer may be something other than an existing label.+ * - `question-clarify` — "Chat about this": decline the question so the user can talk it over. A+ * deny whose message is Claude Code's own for that choice, built by core from the held request.*/export type PermissionAnswer =| { kind: 'allow' }@@ -40,6 +42,7 @@ export type PermissionAnswer =| { kind: 'plan'; mode: 'restore' | 'acceptEdits' | 'manual' }| { kind: 'plan-revise'; message: string }| { kind: 'question'; answers: Record<string, string | string[]>; freeText?: string[] }+ | { kind: 'question-clarify' }/** Typed text in an answer ("Revise…" feedback, a question's "Other"), in UTF-16 code units. ONE* definition: core refuses past it and the answer fields stop at it, so a field can never accept