Skip to content

The agent that grows with you

fix(desktop): stage keyboard multi-select choices

Thomas Hudspith-Tatham1134d2c99816
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 4d33a176c26..5213b8b4a4f 100644
--- a/apps/desktop/src/components/assistant-ui/clarify-tool.test.tsx
+++ b/apps/desktop/src/components/assistant-ui/clarify-tool.test.tsx
@@ -323,6 +323,26 @@ describe('ClarifyTool keyboard navigation', () => {
})
})
+ it('stages a highlighted multi-select choice with Enter and submits it with Continue', async () => {
+ const request = renderLiveClarify({ multiSelect: true })
+ const production = screen.getByRole('button', { name: /production/ })
+
+ fireEvent.keyDown(window, { key: 'ArrowDown' })
+ fireEvent.keyDown(window, { key: 'Enter' })
+
+ expect(production.getAttribute('aria-pressed')).toBe('true')
+ expect(request).not.toHaveBeenCalled()
+
+ fireEvent.click(screen.getByRole('button', { name: /Continue/ }))
+
+ await waitFor(() => {
+ expect(request).toHaveBeenCalledWith('clarify.respond', {
+ answer: JSON.stringify(['production']),
+ request_id: 'request-1'
+ })
+ })
+ })
+
it('focuses Other when its number is pressed and leaves typing keys alone', () => {
renderLiveClarify()
diff --git a/apps/desktop/src/components/assistant-ui/clarify-tool.tsx b/apps/desktop/src/components/assistant-ui/clarify-tool.tsx
index 255729de780..27dd58fa537 100644
--- a/apps/desktop/src/components/assistant-ui/clarify-tool.tsx
+++ b/apps/desktop/src/components/assistant-ui/clarify-tool.tsx
@@ -447,6 +447,16 @@ function ClarifyToolPending({ args }: ToolCallMessagePartProps) {
}, [pendingAnswer, respond])
const activateActive = useCallback(() => {
+ const choice = choices[activeIndex]
+
+ // Multi-select Enter toggles the highlighted choice. The user confirms the
+ // staged set explicitly with Continue so this path never submits a scalar.
+ if (multiSelect && choice) {
+ selectChoice(choice, activeIndex)
+
+ return
+ }
+
// A staged answer (picked choice or typed text) wins — confirm it.
if (pendingAnswer) {
submitAnswer()
@@ -456,8 +466,6 @@ function ClarifyToolPending({ args }: ToolCallMessagePartProps) {
// Otherwise act on the highlighted row: a choice responds immediately, and
// the trailing "Other" row focuses the free-text field.
- const choice = choices[activeIndex]
-
if (choice) {
void respond(choice)
@@ -465,7 +473,7 @@ function ClarifyToolPending({ args }: ToolCallMessagePartProps) {
}
textareaRef.current?.focus()
- }, [activeIndex, choices, pendingAnswer, respond, submitAnswer])
+ }, [activeIndex, choices, multiSelect, pendingAnswer, respond, selectChoice, submitAnswer])
const handleTextareaKey = useCallback(
(event: KeyboardEvent<HTMLTextAreaElement>) => {