Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
Merge upstream/main and stabilize question-card voice controls
zcinta05147bb4c86bdbf9
diff --cc apps/desktop/src/renderer/__tests__/askUserQuestionVoice.test.tsxindex 54054a7e7f,4d3150aae8..fb219998bf--- a/apps/desktop/src/renderer/__tests__/askUserQuestionVoice.test.tsx+++ b/apps/desktop/src/renderer/__tests__/askUserQuestionVoice.test.tsx@@@ -19,10 -17,10 +19,10 @@@ let idleBeforeStop = false// busy state, which is what disables question navigation.vi.mock('../components/new-chat/useAskUserDictation', () => ({useAskUserDictation: (target: { setText: (text: string) => void }) => {- const [state, setState] = useState<'idle' | 'listening' | 'done' | 'error'>('idle');+ const [state, setState] = useState<'idle' | 'listening'>('idle');return {state,- isBusy: state !== 'idle',+ isBusy: state === 'listening',liveText: null,lastError: null,start: () => {@@@ -119,7 -117,7 +119,7 @@@ describe('AskUserQuestion voice entry'const cluster = voice.parentElement!;// Sharing one container is what keeps the two on the same center line as the// answer grows; self-end pins the pair to the row's bottom edge.-- expect(within(cluster).getByText('提交').tagName).toBe('BUTTON');++ expect(within(cluster).getByRole('button', { name: '提交' }).tagName).toBe('BUTTON');expect(cluster.className).toContain('items-center');expect(cluster.className).toContain('self-end');});@@@ -129,7 -127,7 +129,7 @@@const voice = view.getByTestId('ask-user-voice');expect(voice).toBeTruthy();expect(view.getByPlaceholderText('请输入回答…')).toBeTruthy();-- expect(within(voice.parentElement!).getByText('提交').tagName).toBe('BUTTON');++ expect(within(voice.parentElement!).getByRole('button', { name: '提交' }).tagName).toBe('BUTTON');});it('bottom-pins the voice button in multi-select where the row has no send button', () => {@@@ -269,80 -267,43 +269,81 @@@expect((view.getByText('跳过').closest('button') as HTMLButtonElement).disabled).toBe(true);});- // Regression: recording disabled Send, and Enter only stopped capture. Unit- // coverage previously asserted the broken disabled state; defer the final- // transcript to prove submission uses it exactly once across all answer forms.- it.each(['free', 'custom', 'multi', 'enter'])(- 'finishes dictation and submits the final %s answer once', async (mode) => {- let finish!: (text: string) => void;- stop.mockImplementationOnce(() => new Promise((resolve) => { finish = resolve; }));- const { view, onAnswer } = renderAsk([{- question: '问题',- ...(mode === 'custom' || mode === 'multi' ? { options: [{ label: '甲' }] } : {}),- multiSelect: mode === 'multi',- }]);- if (mode === 'multi') fireEvent.click(view.getByText('甲'));- fireEvent.click(view.getByTestId('ask-user-voice'));- const send = view.getByRole('button', { name: '提交' }) as HTMLButtonElement;- expect(send.disabled).toBe(false);- if (mode === 'enter') fireEvent.keyDown(view.getByPlaceholderText('请输入回答…'), { key: 'Enter' });- else fireEvent.click(send);- fireEvent.click(send);- expect(onAnswer).not.toHaveBeenCalled();- await act(async () => finish('最后一句'));- expect(stop).toHaveBeenCalledOnce();- expect(onAnswer).toHaveBeenCalledExactlyOnceWith('req-voice', {- '问题': mode === 'multi' ? '["甲","最后一句"]' : '最后一句',- });- },- );-- it('keeps the existing answer when finishing dictation fails', async () => {- const { view, onAnswer } = renderAsk([{ question: '问题' }]);- fireEvent.change(view.getByPlaceholderText('请输入回答…'), { target: { value: '已有草稿' } });+ // #6785: the old card disabled submit until the user stopped the mic.+ // Unit: real card actions must wait for the final transcript, submit once,+ // and leave failures editable. Existing cases only tested the voice entry.- it.each(['click', 'enter'] as const)('stops and submits the final answer once via %s', async (action) => {++ it.each(['click', 'enter', 'custom'] as const)('stops and submits the final answer once via %s', async (action) => {+ let finish!: (ok: boolean) => void;+ stop.mockImplementationOnce(() => new Promise<boolean>((resolve) => { finish = resolve; }));- const { view, onAnswer } = renderAsk([{ question: '补充一句' }]);++ const { view, onAnswer } = renderAsk([{ question: '补充一句', ...(action === 'custom' ? { options: [{ label: '甲' }] } : {}) }]);+ fireEvent.click(view.getByTestId('ask-user-voice'));+ const submit = view.getByText('提交').closest('button')!;+ expect(submit.disabled).toBe(false);- if (action === 'click') fireEvent.click(submit);++ if (action !== 'enter') fireEvent.click(submit);+ else fireEvent.keyDown(view.getByPlaceholderText('请输入回答…'), { key: 'Enter' });+ fireEvent.click(submit);+ expect(stop).toHaveBeenCalledOnce();++ expect(view.getByRole('button', { name: '提交' }).getAttribute('aria-busy')).toBe('true');+ expect(onAnswer).not.toHaveBeenCalled();+ await act(async () => finish(true));+ expect(onAnswer).toHaveBeenCalledExactlyOnceWith('req-voice', { '补充一句': '完整回答' });+ });++ it('keeps navigation locked after done until stop finishes restoring audio', async () => {+ idleBeforeStop = true;+ let finish!: (ok: boolean) => void;+ stop.mockImplementationOnce(() => new Promise<boolean>((resolve) => { finish = resolve; }));+ const { view, onAnswer } = renderAsk([{ question: '选哪些?', multiSelect: true, options: [{ label: '甲' }, { label: '乙' }] }]);+ fireEvent.click(view.getByTestId('ask-user-voice'));+ fireEvent.click(view.getByText('提交'));+ const submit = view.getByRole('button', { name: '提交' });+ expect(submit.getAttribute('aria-busy')).toBe('true');+ expect((view.getByText('跳过').closest('button') as HTMLButtonElement).disabled).toBe(true);+ fireEvent.click(view.getByText('乙'));+ fireEvent.keyDown(window, { key: 'Escape' });+ fireEvent.keyDown(window, { key: '2' });+ expect(onAnswer).not.toHaveBeenCalled();+ await act(async () => finish(true));+ expect(onAnswer).toHaveBeenCalledExactlyOnceWith('req-voice', { '选哪些?': JSON.stringify(['完整回答']) });+ });++ it('keeps the answer editable instead of submitting after a failed stop', async () => {+ stop.mockResolvedValueOnce(false);+ const { view, onAnswer } = renderAsk([{ question: '补充一句' }]);+ fireEvent.change(view.getByPlaceholderText('请输入回答…'), { target: { value: '保留文字' } });fireEvent.click(view.getByTestId('ask-user-voice'));- stop.mockRejectedValueOnce(new Error('voice failed'));- await act(async () => fireEvent.click(view.getByRole('button', { name: '提交' })));+ await act(async () => fireEvent.click(view.getByText('提交')));+ expect(onAnswer).not.toHaveBeenCalled();+ expect((view.getByPlaceholderText('请输入回答…') as HTMLTextAreaElement).value).toBe('保留文字');+ });++ it('does not submit an empty finalized transcript', async () => {+ finalTranscript = '';+ const { view, onAnswer } = renderAsk([{ question: '补充一句' }]);+ fireEvent.click(view.getByTestId('ask-user-voice'));+ await act(async () => fireEvent.click(view.getByText('提交')));expect(stop).toHaveBeenCalledOnce();expect(onAnswer).not.toHaveBeenCalled();- expect((view.getByPlaceholderText('请输入回答…') as HTMLTextAreaElement).value).toBe('已有草稿');+ expect(view.getByText('提交').closest('button')!.disabled).toBe(true);+ });++ it('does not submit a late result after leaving the card', async () => {+ let finish!: (ok: boolean) => void;+ stop.mockImplementationOnce(() => new Promise<boolean>((resolve) => { finish = resolve; }));+ const { view, onAnswer } = renderAsk([{ question: '补充一句' }]);+ fireEvent.click(view.getByTestId('ask-user-voice'));+ fireEvent.click(view.getByText('提交'));+ view.unmount();+ await act(async () => finish(true));+ expect(onAnswer).not.toHaveBeenCalled();+ });++ it('encodes checked options together with the final voice answer', async () => {+ const { view, onAnswer } = renderAsk([{ question: '选哪些?', multiSelect: true, options: [{ label: '甲' }, { label: '乙' }] }]);+ fireEvent.click(view.getByText('甲'));+ fireEvent.click(view.getByTestId('ask-user-voice'));+ await act(async () => fireEvent.click(view.getByText('提交')));+ expect(onAnswer).toHaveBeenCalledExactlyOnceWith('req-voice', { '选哪些?': JSON.stringify(['甲', '完整回答']) });});});diff --cc apps/desktop/src/renderer/components/new-chat/AskUserQuestionPrompt.tsxindex bad0373a9e,a594fd6774..c2a538a69a--- a/apps/desktop/src/renderer/components/new-chat/AskUserQuestionPrompt.tsx+++ b/apps/desktop/src/renderer/components/new-chat/AskUserQuestionPrompt.tsx@@@ -1,4 -1,4 +1,5 @@@import { Button } from '@/components/ui/button';++import { Spinner } from '@/components/ui/spinner';/*** AskUserQuestionPrompt* ---------------------------------------------------------------------------@@@ -941,12 -924,11 +942,12 @@@ function AskUserQuestionForm(<buttontype="button"onClick={handleCustomSubmit}- disabled={!customInput.trim() && !dictation.isBusy}+ disabled={voiceSubmitting || (!dictation.isBusy && !customInput.trim())}+ aria-busy={voiceSubmitting}data-testid={isLastQuestion ? undefined : 'ask-user-custom-next'}- aria-label={voiceSubmitting ? voiceSubmitLabel : isLastQuestion ? undefined : t('chat.askUserQuestion.next')}+ aria-label={isLastQuestion ? undefined : t('chat.askUserQuestion.next')}className={cn(-- 'shrink-0 rounded-[9999px] text-13 font-medium',++ 'relative shrink-0 rounded-[9999px] text-13 font-medium',isLastQuestion? 'px-[16px] py-[6px]': 'flex h-8 w-8 items-center justify-center',@@@ -955,12 -937,10 +956,17 @@@: 'bg-[var(--ask-send-disabled-bg)] text-[var(--ask-send-disabled-text)]',)}>- {voiceSubmitting ? (- <span role="status" aria-label={voiceSubmitLabel}>{isLastQuestion ? voiceSubmitLabel : '…'}</span>- ) : isLastQuestion ? (- {isLastQuestion ? (-- t(pending.resumeOnSubmit ? 'chat.askUserQuestion.sendAndContinue' : 'chat.askUserQuestion.submit')-- ) : (-- <ArrowRight size={15} strokeWidth={2} aria-hidden="true" />++ <span className={cn('inline-flex items-center justify-center', voiceSubmitting && 'opacity-0')}>++ {isLastQuestion ? (++ t(pending.resumeOnSubmit ? 'chat.askUserQuestion.sendAndContinue' : 'chat.askUserQuestion.submit')++ ) : (++ <ArrowRight size={15} strokeWidth={2} aria-hidden="true" />++ )}++ </span>++ {voiceSubmitting && (++ <span aria-hidden="true" className="absolute inset-0 flex items-center justify-center">++ <Spinner size={14} />++ </span>)}</button></Tip>@@@ -1163,24 -1140,21 +1169,29 @@@<buttontype="button"onClick={submitDirectAnswer}- disabled={!customInput.trim() && !dictation.isBusy}+ disabled={voiceSubmitting || (!dictation.isBusy && !customInput.trim())}+ aria-busy={voiceSubmitting}data-testid={isLastQuestion ? undefined : 'ask-user-custom-next'}- aria-label={voiceSubmitting ? voiceSubmitLabel : isLastQuestion ? undefined : t('chat.askUserQuestion.next')}+ aria-label={isLastQuestion ? undefined : t('chat.askUserQuestion.next')}className={cn(-- 'h-10 rounded-[9999px] text-14 font-medium transition-colors',++ 'relative h-10 rounded-[9999px] text-14 font-medium transition-colors',isLastQuestion ? 'px-4' : 'flex w-10 items-center justify-center',customInput.trim() || dictation.isBusy? 'bg-[var(--ask-send-bg)] text-[var(--ask-send-text)]': 'bg-[var(--ask-send-disabled-bg)] text-[var(--ask-send-disabled-text)]',)}>- {voiceSubmitting ? (- <span role="status" aria-label={voiceSubmitLabel}>{isLastQuestion ? voiceSubmitLabel : '…'}</span>- ) : isLastQuestion ? (- {isLastQuestion ? (-- t(pending.resumeOnSubmit ? 'chat.askUserQuestion.sendAndContinue' : 'chat.askUserQuestion.submit')-- ) : (-- <ArrowRight size={17} strokeWidth={2} aria-hidden="true" />++ <span className={cn('inline-flex items-center justify-center', voiceSubmitting && 'opacity-0')}>++ {isLastQuestion ? (++ t(pending.resumeOnSubmit ? 'chat.askUserQuestion.sendAndContinue' : 'chat.askUserQuestion.submit')++ ) : (++ <ArrowRight size={17} strokeWidth={2} aria-hidden="true" />++ )}++ </span>++ {voiceSubmitting && (++ <span aria-hidden="true" className="absolute inset-0 flex items-center justify-center">++ <Spinner size={14} />++ </span>)}</button></Tip>diff --cc apps/mobile/src/__tests__/InteractionPanelReceipt.test.tsxindex 4b7c491665,79cbba9cd5..7995053286--- a/apps/mobile/src/__tests__/InteractionPanelReceipt.test.tsx+++ b/apps/mobile/src/__tests__/InteractionPanelReceipt.test.tsx@@@ -48,9 -48,9 +48,9 @@@ vi.mock('@/inputHandoff/InputHandoffCarvi.mock('react-native-safe-area-context', () => ({ useSafeAreaInsets: () => ({ top: 0, right: 0, bottom: 0, left: 0 }) }));vi.mock('react-native', async () => {const { createElement } = await import('react');- const view = (tag: string) => ({ children, onPress, disabled, testID, accessibilityState }: {- children?: ReactNode; onPress?: () => void; disabled?: boolean; testID?: string; accessibilityState?: { busy?: boolean };- }) => createElement(tag, { onClick: onPress, disabled, 'data-testid': testID, 'aria-busy': accessibilityState?.busy }, children);- const view = (tag: string) => ({ children, onPress, disabled, testID }: {- children?: ReactNode; onPress?: () => void; disabled?: boolean; testID?: string;- }) => createElement(tag, { onClick: onPress, disabled, 'data-testid': testID }, children);++ const view = (tag: string) => ({ children, onPress, disabled, testID, accessibilityState, accessibilityLabel }: {++ children?: ReactNode; onPress?: () => void; disabled?: boolean; testID?: string; accessibilityState?: { busy?: boolean }; accessibilityLabel?: string;++ }) => createElement(tag, { onClick: onPress, disabled, 'data-testid': testID, 'aria-busy': accessibilityState?.busy, 'aria-label': accessibilityLabel }, children);// Text keeps its onTextLayout so a test can report how many lines a label took.const Text = ({ children, onTextLayout, onPress, testID }: { children?: ReactNode; onTextLayout?: (event: { nativeEvent: { lines: unknown[] } }) => void; onPress?: () => void; testID?: string }) => {if (onTextLayout) textLayouts.set(String(children), onTextLayout);@@@ -124,96 -124,141 +124,235 @@@ async function type(id: string, value:});}+// #6785, unit: real card + hook; only native/cloud startup is faked.+// Existing cases never submitted while listening. The final text arrives at stop.+it.each([+ { multiSelect: false, connecting: false },+ { multiSelect: true, connecting: false },+ { multiSelect: false, connecting: true },+])('waits for voice finalization and submits once (%o)', async ({ multiSelect, connecting }) => {+ let finish!: () => void;+ const stop = vi.fn();+ voiceStarter.start.mockImplementation(async (input) => {+ const run = { stop: () => stop(), cancel: vi.fn(async () => undefined) };+ let ready: (() => void) | undefined;+ stop.mockImplementation(() => new Promise<void>((resolve) => { finish = () => { input.setText('完整回答'); ready?.(); resolve(); }; }));+ input.onRunCreated(run);+ input.onListening();+ return connecting ? new Promise((resolve) => { ready = () => resolve(run); }) : run;+ });+ remoteSessionStore.setPendingInteractions('s1', [{ request: {+ kind: 'ask_user_question', requestId, questions: [{ question: 'Answer?', multiSelect }],+ } }]);+ await act(async () => root.render(<AskCardAuthContext.Provider value={{+ getAccessToken: async () => null, refreshAccessToken: async () => null, apiFetch: async () => null,+ }}><Harness /></AskCardAuthContext.Provider>));+ await click('interaction.ask.voice');+ expect(host.querySelector<HTMLButtonElement>('[data-testid="interaction.ask.submitButton"]')!.disabled).toBe(false);+ await click('interaction.ask.submitButton');+ await click('interaction.ask.submitButton');+ expect(stop).toHaveBeenCalledOnce();+ expect(resolveInteraction).not.toHaveBeenCalled();+ await act(async () => finish());+ expect(resolveInteraction).toHaveBeenCalledOnce();+ expect(JSON.stringify(resolveInteraction.mock.calls[0])).toContain('完整回答');+});++it('queues a submit before the voice handle exists without pretending to record', async () => {+ let publish!: () => void;+ let finish!: () => void;+ const stop = vi.fn(() => new Promise<void>((resolve) => { finish = resolve; }));+ voiceStarter.start.mockImplementation((input) => new Promise((resolve) => {+ const run = { stop: async () => { await stop(); input.setText('最终回答'); }, cancel: vi.fn(async () => undefined) };+ publish = () => { input.onRunCreated(run); resolve(run); };+ }));+ remoteSessionStore.setPendingInteractions('s1', [{ request: {+ kind: 'ask_user_question', requestId, questions: [{ question: 'Answer?' }],+ } }]);+ await act(async () => root.render(<AskCardAuthContext.Provider value={{+ getAccessToken: async () => null, refreshAccessToken: async () => null, apiFetch: async () => null,+ }}><Harness /></AskCardAuthContext.Provider>));+ await type('interaction.ask.textInput', '已有文字');+ await click('interaction.ask.voice');+ const mic = host.querySelector('[data-testid="interaction.ask.voice"]')!;+ expect(mic.getAttribute('aria-busy')).toBe('true');++ expect(mic.getAttribute('aria-label')).toBe('session.common.voiceStopRecording');+ await click('interaction.ask.submitButton');+ const submit = host.querySelector('[data-testid="interaction.ask.submitButton"]')!;+ expect(submit.getAttribute('aria-busy')).toBe('true');+ expect(resolveInteraction).not.toHaveBeenCalled();+ await act(async () => publish());+ expect(stop).toHaveBeenCalledOnce();+ await act(async () => finish());+ expect(resolveInteraction).toHaveBeenCalledOnce();+ expect(JSON.stringify(resolveInteraction.mock.calls[0])).toContain('最终回答');+});++it.each(['stop', 'live'] as const)('retains text and permits manual correction after a %s failure', async (failure) => {+ let fail!: () => void;+ voiceStarter.start.mockImplementation(async (input) => {+ const run = { stop: async () => { input.setText('保留文字'); throw new Error('识别失败'); }, cancel: async () => undefined };+ fail = () => { input.setText('保留文字'); input.onError('识别失败'); };+ input.onRunCreated(run);+ input.onListening();+ return run;+ });+ remoteSessionStore.setPendingInteractions('s1', [{ request: {+ kind: 'ask_user_question', requestId, questions: [{ question: 'Answer?' }],+ } }]);+ await act(async () => root.render(<AskCardAuthContext.Provider value={{+ getAccessToken: async () => null, refreshAccessToken: async () => null, apiFetch: async () => null,+ }}><Harness /></AskCardAuthContext.Provider>));+ await click('interaction.ask.voice');+ if (failure === 'stop') await click('interaction.ask.submitButton');+ else await act(async () => fail());+ expect(resolveInteraction).not.toHaveBeenCalled();+ expect(host.querySelector<HTMLInputElement>('[data-testid="interaction.ask.textInput"]')!.value).toBe('保留文字');+ expect(host.querySelector('[data-testid="interaction.ask.voiceError"]')!.textContent).toBe('识别失败');+ await type('interaction.ask.textInput', '修改后的回答');+ await click('interaction.ask.submitButton');+ expect(resolveInteraction).toHaveBeenCalledOnce();+ expect(JSON.stringify(resolveInteraction.mock.calls[0])).toContain('修改后的回答');+});++ // Unit regression: the real card/hook disabled submit during recording. Existing+ // voice coverage only exercised signed-out errors, never final text or failures.+ it.each(['free', 'custom', 'multi', 'failed', 'removed', 'connecting', 'connecting-failed', 'connecting-removed', 'connecting-cancelled'])(+ 'submits final voice text once and preserves failed/cancelled answers: %s', async (mode) => {+ let finish!: () => void;+ let fail!: (error: Error) => void;+ let connect!: () => void;+ let failConnection!: (error: Error) => void;+ let signal: AbortSignal | undefined;+ const stop = vi.fn();+ const cancel = vi.fn(async () => undefined);- startDictation.mockImplementation(async (input: { signal?: AbortSignal; onListening: () => void; setText: (text: string) => void }) => {++ voiceStarter.start.mockImplementation(async (input: { signal?: AbortSignal; onListening: () => void; setText: (text: string) => void }) => {+ signal = input.signal;- input.onListening();+ stop.mockImplementation(() => new Promise<void>((resolve, reject) => {+ finish = () => { input.setText('Final answer'); resolve(); };+ fail = reject;+ }));+ const run = { stop, cancel };+ // PR #7017 review: listening can precede the ASR handshake. The previous+ // fixture always resolved startup immediately and missed lost recordings.+ if (mode.startsWith('connecting')) {+ await new Promise<void>((resolve, reject) => { connect = resolve; failConnection = reject; });+ }++ input.onListening();+ return run;+ });+ remoteSessionStore.setPendingInteractions('s1', [{ request: {+ kind: 'ask_user_question', requestId, questions: [{ question: 'Question?',+ ...(mode === 'custom' || mode === 'multi' ? { options: [{ label: 'A' }] } : {}),+ multiSelect: mode === 'multi',+ }],+ } }]);+ resolveInteraction.mockResolvedValue({ accepted: true });+ await act(async () => root.render(+ <AskCardAuthContext.Provider value={{ getAccessToken: async () => 'test', refreshAccessToken: async () => 'test', apiFetch: async () => ({}) }}>+ <Harness />+ </AskCardAuthContext.Provider>,+ ));+ if (mode === 'multi') await click('interaction.ask.option.1');+ if (mode === 'failed' || mode === 'connecting-failed') await type('interaction.ask.textInput', 'Saved draft');+ await click('interaction.ask.voice');+ const send = host.querySelector<HTMLButtonElement>('[data-testid="interaction.ask.submitButton"]')!;+ expect(send.disabled).toBe(false);+ if (mode === 'connecting-cancelled') {++ expect(host.querySelector('[data-testid="interaction.ask.voice"]')!.getAttribute('aria-label')).toBe('session.common.voiceStopRecording');+ await click('interaction.ask.voice');+ expect(signal?.aborted).toBe(true);++ expect(host.querySelector('[data-testid="interaction.ask.voice"]')!.getAttribute('aria-label')).toBe('session.screen.voiceStartInput');+ await act(async () => connect());+ expect(cancel).toHaveBeenCalledOnce();+ expect(stop).not.toHaveBeenCalled();+ expect(resolveInteraction).not.toHaveBeenCalled();+ return;+ }+ await click('interaction.ask.submitButton');+ await click('interaction.ask.submitButton');+ if (mode.startsWith('connecting')) {+ expect(signal?.aborted).toBe(false);+ expect(stop).not.toHaveBeenCalled();+ expect(resolveInteraction).not.toHaveBeenCalled();+ if (mode === 'connecting-removed') {+ await act(async () => remoteSessionStore.setPendingInteractions('s1', []));+ expect(signal?.aborted).toBe(true);+ }+ await act(async () => mode === 'connecting-failed' ? failConnection(new Error('Connection failed')) : connect());+ if (mode !== 'connecting') {+ expect(resolveInteraction).not.toHaveBeenCalled();+ expect(stop).not.toHaveBeenCalled();+ if (mode === 'connecting-failed') expect(readAskUserDraft(requestId)?.customInput).toBe('Saved draft');+ else expect(cancel).toHaveBeenCalledOnce();+ return;+ }+ }+ expect(stop).toHaveBeenCalledOnce();+ expect(resolveInteraction).not.toHaveBeenCalled();+ if (mode === 'removed') await act(async () => remoteSessionStore.setPendingInteractions('s1', []));+ await act(async () => mode === 'failed' ? fail(new Error('Voice failed')) : finish());+ if (mode === 'failed' || mode === 'removed') {+ expect(resolveInteraction).not.toHaveBeenCalled();+ if (mode === 'failed') expect(readAskUserDraft(requestId)?.customInput).toBe('Saved draft');+ } else {+ expect(resolveInteraction).toHaveBeenCalledExactlyOnceWith(requestId, {+ kind: 'ask_user_question', answers: { 'Question?': mode === 'multi' ? '["A","Final answer"]' : 'Final answer' },+ });+ }+ },+ );++ // PR #7017 review: no PCM has arrived yet, so the old hook left editing and+ // navigation enabled while Send awaited startup. Exercise actual card actions,+ // then resolve startup and verify the original answer/question is submitted.+ it.each(['options', 'previous'])('protects the answer while submitting before the first audio chunk: %s', async (action) => {+ let connect!: () => void;+ const stop = vi.fn();- startDictation.mockImplementation(async (input: { setText: (text: string) => void }) => {++ voiceStarter.start.mockImplementation(async (input: { setText: (text: string) => void }) => {+ stop.mockImplementation(async () => input.setText('Final answer'));+ await new Promise<void>((resolve) => { connect = resolve; });+ return { stop, cancel: vi.fn(async () => undefined) };+ });+ remoteSessionStore.setPendingInteractions('s1', [{ request: {+ kind: 'ask_user_question', requestId, questions: [+ ...(action === 'previous' ? [{ question: 'First?', multiSelect: true, options: [{ label: 'X' }, { label: 'Y' }] }] : []),+ { question: 'Current?', multiSelect: true, options: [{ label: 'A' }, { label: 'B' }] },+ ],+ } }]);+ resolveInteraction.mockResolvedValue({ accepted: true });+ await act(async () => root.render(+ <AskCardAuthContext.Provider value={{ getAccessToken: async () => 'test', refreshAccessToken: async () => 'test', apiFetch: async () => ({}) }}>+ <Harness />+ </AskCardAuthContext.Provider>,+ ));+ if (action === 'previous') {+ await click('interaction.ask.option.1');+ await click('interaction.ask.submitButton');+ }+ await click('interaction.ask.option.1');+ await click('interaction.ask.voice');+ await click('interaction.ask.submitButton');+ expect(resolveInteraction).not.toHaveBeenCalled();+ expect(stop).not.toHaveBeenCalled();+ expect(host.querySelector<HTMLInputElement>('[data-testid="interaction.ask.customInput"]')!.readOnly).toBe(true);+ for (const id of ['interaction.ask.option.2', 'interaction.ask.skipButton',+ ...(action === 'previous' ? ['interaction.ask.previousButton'] : [])]) {+ expect(host.querySelector<HTMLButtonElement>(`[data-testid="${id}"]`)!.disabled).toBe(true);+ await click(id);+ }+ expect(host.querySelector('[data-testid="interaction.ask.question"]')!.textContent).toBe('Current?');+ expect(readAskUserDraft(requestId)?.selectedLabels).toEqual(['A']);+ await act(async () => connect());+ expect(resolveInteraction).toHaveBeenCalledExactlyOnceWith(requestId, {+ kind: 'ask_user_question', answers: {+ ...(action === 'previous' ? { 'First?': '["X"]' } : {}),+ 'Current?': '["A","Final answer"]',+ },+ });+++ });+// Unit regression for PR #6306 review: a signed-out microphone tap used to// render hardcoded Chinese. Existing receipt tests never tapped this entry.// Exercise the real card and hook in each supported locale, without auth.diff --cc apps/mobile/src/session/InteractionPanel.tsxindex 2b80d01a34,a0ee4b31c0..1299b01232--- a/apps/mobile/src/session/InteractionPanel.tsx+++ b/apps/mobile/src/session/InteractionPanel.tsx@@@ -996,10 -1003,8 +1004,10 @@@ function AskCardVoiceButton({ listeningconst { colors } = useTheme();return (<Pressable-- accessibilityLabel={listening ? t('session.common.voiceStopRecording') : t('session.screen.voiceStartInput')}++ accessibilityLabel={listening || starting ? t('session.common.voiceStopRecording') : t('session.screen.voiceStartInput')}accessibilityRole="button"+ accessibilityState={{ busy: starting, disabled: Boolean(disabled) }}+ disabled={disabled}hitSlop={8}onPress={onPress}style={{ alignItems: 'center', height: 44, justifyContent: 'center', width: 44 }}@@@ -1317,7 -1311,7 +1325,7 @@@ function AskUserQuestionForm(<View style={[styles.customInputRow, { gap: touchLayout.actionGap }]}><InteractionTouchButtonaccessibilityLabel={t('interaction.panel.customAnswerPlaceholder')}- disabled={busy}- disabled={busy || voice.listening}++ disabled={busy || voiceLocked}onPress={() => {if (!isMulti) {clearCurrentAnswer();