Skip to content

The agent that grows with you

fix(desktop): a batch clarify answered one card at a time stays answerable

teknium1b7167d18f550
diff --git a/apps/desktop/src/components/assistant-ui/clarify-tool.test.tsx b/apps/desktop/src/components/assistant-ui/clarify-tool.test.tsx
index 805c34a7792..010e16866d0 100644
--- a/apps/desktop/src/components/assistant-ui/clarify-tool.test.tsx
+++ b/apps/desktop/src/components/assistant-ui/clarify-tool.test.tsx
@@ -189,6 +189,28 @@ describe('ClarifyTool live card stays mounted across settle', () => {
expect(screen.queryByRole('status', { name: /loading question/i })).toBeNull()
expect(screen.getByRole('button', { name: /Continue/ }).hasAttribute('disabled')).toBe(true)
})
+
+ it('a batch tool call answered one card at a time by the shared gateway gets a live single card', () => {
+ // `gateway/run_turn_runner.py::_clarify_batch_sync` sends one single-question request per
+ // entry; the batch preview built from the tool args must not shadow it as a disabled form.
+ $activeSessionId.set('session-1')
+ $gateway.set({ request: vi.fn().mockResolvedValue({ ok: true }) } as never)
+ setClarifyRequest({
+ choices: ['staging', 'production'],
+ multiSelect: false,
+ question: 'Which deployment target?',
+ requestId: 'request-1',
+ sessionId: 'session-1'
+ })
+ const props = liveClarifyProps()
+ const args = { questions: [{ question: 'Which deployment target?', choices: ['staging', 'production'] }] }
+ renderClarify(<ClarifyTool {...props} args={args} argsText={JSON.stringify(args)} />)
+
+ const staging = screen.getByRole('button', { name: /staging/ })
+
+ expect(staging.hasAttribute('disabled')).toBe(false)
+ expect(screen.queryByRole('button', { name: /Confirm and continue/ })).toBeNull()
+ })
})
describe('ClarifyTool choice selection', () => {
diff --git a/apps/desktop/src/components/assistant-ui/clarify-tool.tsx b/apps/desktop/src/components/assistant-ui/clarify-tool.tsx
index d3b62ddcf57..522bdfe2f66 100644
--- a/apps/desktop/src/components/assistant-ui/clarify-tool.tsx
+++ b/apps/desktop/src/components/assistant-ui/clarify-tool.tsx
@@ -398,11 +398,22 @@ function ClarifyToolPending(props: ToolCallMessagePartProps) {
// request — but the question TEXT is already in the tool args, so paint a
// disabled preview immediately instead of a spinner (the single-question
// card does the same while request_id races the tool block).
- if (request?.questions?.length || fromArgs.questions) {
+ // The shared gateway answers a batch one card at a time (`_clarify_batch_sync`):
+ // its requests are single-question even when the tool args are a batch, so a
+ // live single-question request always drives the single card.
+ const singleLive = Boolean(request?.requestId) && !request?.questions?.length
+
+ if (!singleLive && (request?.questions?.length || fromArgs.questions)) {
return <ClarifyToolBatchPending fromArgs={fromArgs} onAnswered={() => setAnswered(true)} request={request} />
}
- return <ClarifyToolSinglePending fromArgs={fromArgs} onAnswered={() => setAnswered(true)} request={request} />
+ return (
+ <ClarifyToolSinglePending
+ fromArgs={singleLive && fromArgs.questions ? {} : fromArgs}
+ onAnswered={() => setAnswered(true)}
+ request={request}
+ />
+ )
}
function ClarifyToolSinglePending({