The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix: multi-select clarify keeps the typed answer when picking a choice (review follow-up)
teknium13d1c00e1e8d3
diff --git a/apps/desktop/src/components/assistant-ui/clarify-tool.test.tsx b/apps/desktop/src/components/assistant-ui/clarify-tool.test.tsxindex c2317884a00..d6ae4174ae6 100644--- a/apps/desktop/src/components/assistant-ui/clarify-tool.test.tsx+++ b/apps/desktop/src/components/assistant-ui/clarify-tool.test.tsx@@ -239,6 +239,26 @@ describe('ClarifyTool choice selection', () => {})})+ it('keeps a typed multi-select custom answer when picking a choice after typing it', async () => {+ const { respond } = renderLiveClarify({ multiSelect: true })+ const staging = screen.getByRole('button', { name: /staging/ })+ const other = screen.getByPlaceholderText(/Other/)++ fireEvent.focus(other)+ fireEvent.change(other, { target: { value: 'something else' } })+ fireEvent.click(staging)++ // Picking a choice must not silently discard the text already typed.+ expect((other as HTMLInputElement).value).toBe('something else')+ expect(staging.getAttribute('aria-pressed')).toBe('true')++ fireEvent.click(screen.getByRole('button', { name: /Continue/ }))++ await waitFor(() => {+ expect(respond).toHaveBeenCalledWith({ answer: JSON.stringify(['staging', 'something else']) })+ })+ })+it('keeps single-select replacement and plain-string submission', async () => {const { respond } = renderLiveClarify()const staging = screen.getByRole('button', { name: /staging/ })@@ -819,6 +839,30 @@ describe('ClarifyTool batch card', () => {})})+ it('keeps a typed multi-select batch custom answer when picking a choice after typing it', async () => {+ const { request } = renderLiveBatch(undefined, true)+ const other = screen.getByPlaceholderText(/Other/)++ fireEvent.change(other, { target: { value: 'green' } })+ fireEvent.click(screen.getByRole('button', { name: /red/ }))++ // Picking a choice must not silently discard the text already typed.+ expect((other as HTMLInputElement).value).toBe('green')+ expect(screen.getByRole('button', { name: /red/ }).getAttribute('aria-pressed')).toBe('true')++ fireEvent.change(screen.getByPlaceholderText('Type your answer…'), { target: { value: 'packet' } })+ fireEvent.submit(document.querySelector('form') as HTMLFormElement)++ await waitFor(() => {+ expect(request).toHaveBeenCalledTimes(2)+ })+ expect(request).toHaveBeenNthCalledWith(1, 'clarify.lock', {+ answer: JSON.stringify(['red', 'green']),+ question_id: 'q0',+ request_id: 'request-batch'+ })+ })+it('pre-stages replayed locked answers from a reconnect', () => {renderLiveBatch({ q0: 'red' })diff --git a/apps/desktop/src/components/assistant-ui/clarify-tool.tsx b/apps/desktop/src/components/assistant-ui/clarify-tool.tsxindex dc68242fd67..7a529773829 100644--- a/apps/desktop/src/components/assistant-ui/clarify-tool.tsx+++ b/apps/desktop/src/components/assistant-ui/clarify-tool.tsx@@ -513,8 +513,12 @@ function ClarifyToolSinglePending({const selectChoice = useCallback((choice: string, index: number) => {- // Picking a choice and typing are mutually exclusive answers.- setDraft('')+ // Picking a choice and typing are mutually exclusive answers in+ // single-select; multi-select keeps the typed text as one more answer.+ if (!multiSelect) {+ setDraft('')+ }+setSelectedChoices(selected => {if (!multiSelect) {return [choice]@@ -537,11 +541,11 @@ function ClarifyToolSinglePending({const itemCount = choices.length + 1// Arrow navigation is a move, not a pick. Multi-select keeps staged- // choices while the cursor moves so the user can build a set; the- // single-select path retains its existing clear-on-navigation behaviour.- setDraft('')-+ // choices and the typed text while the cursor moves so the user can+ // build a set; the single-select path retains its existing+ // clear-on-navigation behaviour.if (!multiSelect) {+ setDraft('')setSelectedChoices([])}@@ -1110,7 +1114,9 @@ function ClarifyToolBatchPending({: [...stage.choices, choice]: [choice]- return { ...current, [question.qid]: { choices: next, draft: '' } }+ // Multi-select keeps the typed text alongside the toggled choices;+ // single-select stays mutually exclusive.+ return { ...current, [question.qid]: { choices: next, draft: question.multiSelect ? stage.draft : '' } }})}, [])