The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): Enter on a focused clarify choice reaches activateActive
brooklyn!d371e21d078a
diff --git a/apps/desktop/src/components/assistant-ui/clarify-tool.test.tsx b/apps/desktop/src/components/assistant-ui/clarify-tool.test.tsxindex 805c34a7792..c5b8ed44864 100644--- a/apps/desktop/src/components/assistant-ui/clarify-tool.test.tsx+++ b/apps/desktop/src/components/assistant-ui/clarify-tool.test.tsx@@ -486,6 +486,68 @@ describe('ClarifyTool keyboard navigation', () => {expect(fireEvent.keyDown(window, { key: 'ArrowDown' })).toBe(true)expect(respond).not.toHaveBeenCalled()})++ it('confirms a clicked choice with Enter while the choice button keeps focus', async () => {+ const { respond } = renderLiveClarify()+ const production = screen.getByRole('button', { name: /production/ })++ // Click selects the choice; in a real browser the option button keeps+ // focus afterwards. jsdom's fireEvent.click does not move focus, so+ // focus it explicitly to reproduce the reported bug.+ fireEvent.click(production)+ production.focus()+ expect(production.getAttribute('aria-pressed')).toBe('true')+ expect(document.activeElement).toBe(production)++ fireEvent.keyDown(window, { key: 'Enter' })++ await waitFor(() => {+ expect(respond).toHaveBeenCalledWith({ answer: 'production' })+ })+ })++ it('confirms the highlighted choice with Enter when a choice button is focused but not clicked', async () => {+ const { respond } = renderLiveClarify()+ const production = screen.getByRole('button', { name: /production/ })++ // Tabbing onto a choice does not stage it. Enter still belongs to+ // activateActive, which confirms the highlighted row (staging by default)+ // rather than falling through as a hands-off keypress.+ production.focus()+ expect(production.getAttribute('aria-pressed')).toBe('false')+ expect(document.activeElement).toBe(production)++ fireEvent.keyDown(window, { key: 'Enter' })++ await waitFor(() => {+ expect(respond).toHaveBeenCalledWith({ answer: 'staging' })+ })+ })++ it('toggles a focused multi-select row with Enter and confirms the set with Continue', async () => {+ const { respond } = renderLiveClarify({ multiSelect: true })+ const staging = screen.getByRole('button', { name: /staging/ })+ const production = screen.getByRole('button', { name: /production/ })++ fireEvent.click(staging)+ fireEvent.click(production)+ production.focus()+ expect(document.activeElement).toBe(production)+ expect(staging.getAttribute('aria-pressed')).toBe('true')+ expect(production.getAttribute('aria-pressed')).toBe('true')++ fireEvent.keyDown(window, { key: 'Enter' })++ expect(production.getAttribute('aria-pressed')).toBe('false')+ expect(staging.getAttribute('aria-pressed')).toBe('true')+ expect(respond).not.toHaveBeenCalled()++ fireEvent.click(screen.getByRole('button', { name: /Continue/ }))++ await waitFor(() => {+ expect(respond).toHaveBeenCalledWith({ answer: JSON.stringify(['staging']) })+ })+ })})describe('ClarifyTool recommended option', () => {diff --git a/apps/desktop/src/components/assistant-ui/clarify-tool.tsx b/apps/desktop/src/components/assistant-ui/clarify-tool.tsxindex d3b62ddcf57..a7542f1ddfc 100644--- a/apps/desktop/src/components/assistant-ui/clarify-tool.tsx+++ b/apps/desktop/src/components/assistant-ui/clarify-tool.tsx@@ -608,11 +608,12 @@ function ClarifyToolSinglePending({)// Arrow keys move a visual cursor, 1-9 and A/B/C… pick directly, and Enter- // confirms the current answer (or acts on the highlighted row). Stands down- // whenever a focusable control (a field, a choice button, the action bar) is- // focused, so it never eats keystrokes meant for the composer, the Other box,- // or a button the user tabbed to — and whenever this card is not the visible- // one, since the binding is window-wide but the answer is session-specific.+ // confirms the current answer (or acts on the highlighted row). A focused+ // choice row stays in this handler so Enter reaches activateActive: that+ // submits a staged single-select answer and toggles a multi-select row.+ // Every other focused control (the Other box, Skip, Continue, the composer)+ // keeps its own keys. Inactive cards stand down too — the binding is+ // window-wide but the answer is session-specific.useEffect(() => {if (!ready || !hasChoices || submitting) {return@@ -638,7 +639,13 @@ function ClarifyToolSinglePending({if (active &&- (active.isContentEditable || active.matches('a[href], button, input, select, textarea, [role="button"]'))+ (active.isContentEditable ||+ (active.matches('a[href], button, input, select, textarea, [role="button"]') &&+ // Choice rows stay in this handler so Enter reaches activateActive.+ // That submits a staged single-select answer and toggles a+ // multi-select row. Skip, Continue, and the Other field stay+ // hands-off.+ !active.matches('button[data-choice]')))) {return}