diff --git a/frontend/src/components/session/FormPrompt.test.tsx b/frontend/src/components/session/FormPrompt.test.tsx index b47b89e0..dbb41451 100644 --- a/frontend/src/components/session/FormPrompt.test.tsx +++ b/frontend/src/components/session/FormPrompt.test.tsx @@ -564,6 +564,30 @@ describe('FormPrompt', () => { }) }) + describe('side question button', () => { + it('opens the side question from the footer button', async () => { + const onAskSideQuestion = vi.fn() + render( + + ) + + await userEvent.click(screen.getByRole('button', { name: 'Ask a side question' })) + + expect(onAskSideQuestion).toHaveBeenCalledTimes(1) + }) + + it('omits the side question button when no handler is provided', () => { + render() + + expect(screen.queryByRole('button', { name: 'Ask a side question' })).not.toBeInTheDocument() + }) + }) + describe('conditional and external fields', () => { const conditionalForm: FormInfo = { id: 'form-conditional', diff --git a/frontend/src/components/session/FormPrompt.tsx b/frontend/src/components/session/FormPrompt.tsx index 6e7d0102..0cb9af6c 100644 --- a/frontend/src/components/session/FormPrompt.tsx +++ b/frontend/src/components/session/FormPrompt.tsx @@ -1,5 +1,5 @@ import { useCallback, useEffect, useId, useRef, useState, type ReactNode } from 'react' -import { X, ChevronDown, ChevronUp, Check, Loader2 } from 'lucide-react' +import { X, ChevronDown, ChevronUp, Check, Loader2, MessageCircleQuestion } from 'lucide-react' import { Button } from '@/components/ui/button' import { Textarea } from '@/components/ui/textarea' import { ExternalFieldCard } from '@/components/ui/external-field-card' @@ -62,9 +62,10 @@ interface FormPromptProps { onReply: (formID: string, answer: FormAnswer) => Promise onCancel: (formID: string) => Promise onMinimize?: () => void + onAskSideQuestion?: () => void } -export function FormPrompt({ form, onReply, onCancel, onMinimize }: FormPromptProps) { +export function FormPrompt({ form, onReply, onCancel, onMinimize, onAskSideQuestion }: FormPromptProps) { const candidateFields = form.fields.filter(isAnswerableField) const [state, setState] = useState(() => loadFormDraft(form.id) ?? buildInitialState(candidateFields)) const { answer, customValues, customDrafts } = state @@ -397,7 +398,7 @@ export function FormPrompt({ form, onReply, onCancel, onMinimize }: FormPromptPr )} -
+
+ {onAskSideQuestion && ( + + )} diff --git a/frontend/src/pages/SessionDetail.tsx b/frontend/src/pages/SessionDetail.tsx index 35a718ef..37573682 100644 --- a/frontend/src/pages/SessionDetail.tsx +++ b/frontend/src/pages/SessionDetail.tsx @@ -922,6 +922,7 @@ export function SessionDetail() { onReply={replyToForm} onCancel={cancelForm} onMinimize={() => handleMinimizeForm(currentForm)} + onAskSideQuestion={() => handleAskSideQuestion('')} /> )}