Skip to content

Commit b2582fa

Browse files
fix(mobile): dismiss dictation review when its context ends
1 parent f3c3782 commit b2582fa

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

‎apps/mobile/src/features/threads/ThreadComposer.tsx‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ export interface ThreadComposerProps {
162162
readonly canSteerActiveTurn: boolean;
163163
readonly editorRef?: RefObject<ComposerEditorHandle | null>;
164164
readonly onChangeDraftMessage: (value: string) => void;
165+
readonly onDraftCleared: () => void;
165166
readonly isReviewingDictation: boolean;
166167
readonly onDictationComplete: () => void;
167168
readonly onPickDraftMedia: () => Promise<void>;
@@ -550,7 +551,10 @@ export const ThreadComposer = function ThreadComposer(props: ThreadComposerProps
550551
const handleSend = async (followUp?: ActiveTurnComposerAction) => {
551552
if (voiceInput.blocksSubmission || pendingPastedTextAttachmentCountRef.current > 0) return;
552553
if (usageLimitsOffered && isUsageLimitsCommand(draftMessage) && draftAttachments.length === 0) {
553-
if (openUsageLimits()) onChangeDraftMessage("");
554+
if (openUsageLimits()) {
555+
onChangeDraftMessage("");
556+
props.onDraftCleared();
557+
}
554558
return;
555559
}
556560
const threadKey = scopedThreadKey(props.environmentId, props.selectedThread.id);

‎apps/mobile/src/features/threads/ThreadDetailScreen.tsx‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,8 +418,8 @@ export const ThreadDetailScreen = function ThreadDetailScreen(props: ThreadDetai
418418
const dismissDictationReview = () =>
419419
setDictationReviewThreadKey((current) => (current === selectedThreadKey ? null : current));
420420
const handleDictationComplete = () => {
421-
// The voice session retains its startup callback. Focus must stay current and
422-
// belong to that thread, even when another composer is now on screen.
421+
// The voice session retains its startup callback, so only expand its selected thread.
422+
if (selectedThreadKeyRef.current !== selectedThreadKey) return;
423423
if (composerFocusedThreadKeyRef.current !== selectedThreadKey) {
424424
setDictationReviewThreadKey(selectedThreadKey);
425425
}
@@ -808,6 +808,7 @@ export const ThreadDetailScreen = function ThreadDetailScreen(props: ThreadDetai
808808
// A replaced or unmounted native editor may not emit a blur event.
809809
composerFocusedThreadKeyRef.current = null;
810810
setComposerFocused(false);
811+
setDictationReviewThreadKey(null);
811812
}, [selectedThreadKey, showContent]);
812813

813814
const visitThread = useAtomCommand(threadEnvironment.visit, { reportFailure: false });
@@ -1195,6 +1196,7 @@ export const ThreadDetailScreen = function ThreadDetailScreen(props: ThreadDetai
11951196
saving={props.isSavingQueuedEdit}
11961197
onCancel={() => {
11971198
voiceInputSession.cancel(props.composerDraftKey);
1199+
dismissDictationReview();
11981200
props.onCancelQueuedRunEdit();
11991201
}}
12001202
/>
@@ -1373,6 +1375,7 @@ export const ThreadDetailScreen = function ThreadDetailScreen(props: ThreadDetai
13731375
}
13741376
bottomInset={composerBottomInset}
13751377
onChangeDraftMessage={props.onChangeDraftMessage}
1378+
onDraftCleared={dismissDictationReview}
13761379
isReviewingDictation={isReviewingDictation}
13771380
onDictationComplete={handleDictationComplete}
13781381
onPickDraftMedia={props.onPickDraftMedia}

0 commit comments

Comments
 (0)