fix(app): preserve dictation text during submit (#2745)
Dictation auto-send bypassed the controlled composer update, so preserved draft surfaces could lock while showing an empty prompt. Publish the transcript before invoking the existing submit lifecycle so pending and failed submissions retain the user's spoken input.
This commit is contained in:
@@ -66,6 +66,7 @@ import {
|
||||
resolveVoiceTooltipText,
|
||||
} from "./labels";
|
||||
import {
|
||||
applyDictationTranscript,
|
||||
computeCanStartDictation,
|
||||
resolveComposerSurfacePresentation,
|
||||
runAlternateSendAction,
|
||||
@@ -778,42 +779,6 @@ function SendButtonTooltip({
|
||||
);
|
||||
}
|
||||
|
||||
interface DictationTranscriptContext {
|
||||
value: string;
|
||||
defaultSendBehavior: "interrupt" | "queue";
|
||||
isAgentRunning: boolean;
|
||||
onQueue: ((payload: MessagePayload) => void) | undefined;
|
||||
onSubmit: (payload: MessagePayload) => void;
|
||||
onChangeText: (text: string) => void;
|
||||
attachments: ComposerAttachment[];
|
||||
cwd: string;
|
||||
autoSend: boolean;
|
||||
}
|
||||
|
||||
function applyDictationTranscript(text: string, ctx: DictationTranscriptContext): void {
|
||||
if (!text) return;
|
||||
const shouldPad = ctx.value.length > 0 && !/\s$/.test(ctx.value);
|
||||
const nextValue = `${ctx.value}${shouldPad ? " " : ""}${text}`;
|
||||
|
||||
if (!ctx.autoSend) {
|
||||
ctx.onChangeText(nextValue);
|
||||
return;
|
||||
}
|
||||
|
||||
if (ctx.defaultSendBehavior === "queue" && ctx.isAgentRunning && ctx.onQueue) {
|
||||
ctx.onQueue({ text: nextValue, attachments: ctx.attachments, cwd: ctx.cwd });
|
||||
ctx.onChangeText("");
|
||||
return;
|
||||
}
|
||||
|
||||
ctx.onSubmit({
|
||||
text: nextValue,
|
||||
attachments: ctx.attachments,
|
||||
cwd: ctx.cwd,
|
||||
forceSend: ctx.isAgentRunning || undefined,
|
||||
});
|
||||
}
|
||||
|
||||
interface ToggleRealtimeVoiceContext {
|
||||
voice:
|
||||
| {
|
||||
|
||||
Reference in New Issue
Block a user