Skip to content

Commit cac5b5c

Browse files
fix(desktop): wait for dictation ownership before locking annotations
1 parent 83da608 commit cac5b5c

1 file changed

Lines changed: 3 additions & 16 deletions

File tree

‎apps/desktop/src/preview/PickPreload.ts‎

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,6 @@ function startAnnotation(
609609
let voicePhase: DesktopPreviewAnnotationVoiceState["phase"] = "idle";
610610
let voiceSettings = false;
611611
let voiceBusy = false;
612-
let voicePreparing = false;
613612
let voiceAvailable = false;
614613
let voiceKeyCode: string | null = null;
615614
let pendingVoiceSubmission: PreviewAnnotationSubmission | null = null;
@@ -711,12 +710,7 @@ function startAnnotation(
711710
return;
712711
}
713712
if (!voiceAvailable || (voiceBusy && voicePhase !== "recording")) return;
714-
const action = voicePhase === "recording" ? "stop" : "start";
715-
voiceBusy = true;
716-
if (action === "start") voicePreparing = true;
717-
comment.readOnly = true;
718-
updateStatus();
719-
sendVoice(action);
713+
sendVoice(voicePhase === "recording" ? "stop" : "start");
720714
});
721715
voiceFinish.addEventListener("click", (event) => {
722716
if (event.isTrusted) sendVoice("stop");
@@ -738,7 +732,6 @@ function startAnnotation(
738732
const submissionChanged = voiceBusy !== state.blocksSubmission;
739733
const previewChanged = voicePreview.textContent !== (state.preview ?? "");
740734
voicePhase = state.phase;
741-
voicePreparing = state.phase === "preparing";
742735
voiceSettings = state.errorAction === "settings";
743736
voiceBusy = state.blocksSubmission;
744737
voiceAvailable = state.available;
@@ -888,7 +881,7 @@ function startAnnotation(
888881
sendVoice("cancel");
889882
}
890883
editor.style.display = hasTargets ? "flex" : "none";
891-
submit.disabled = !hasTargets || voicePreparing || pendingCapture;
884+
submit.disabled = !hasTargets || voicePhase === "preparing" || pendingCapture;
892885
submit.style.opacity = hasTargets ? "1" : "0.45";
893886
adjust.disabled = !hasTargets;
894887
stylePanel.style.display = editorExpanded && selected.size > 0 ? "grid" : "none";
@@ -1623,12 +1616,6 @@ function startAnnotation(
16231616
event.preventDefault();
16241617
event.stopImmediatePropagation();
16251618
voiceKeyCode = event.code || event.key;
1626-
if (!event.repeat && !voiceBusy) {
1627-
voiceBusy = true;
1628-
voicePreparing = true;
1629-
comment.readOnly = true;
1630-
updateStatus();
1631-
}
16321619
sendVoice("key", event);
16331620
return;
16341621
}
@@ -1650,7 +1637,7 @@ function startAnnotation(
16501637

16511638
const submitAnnotation = (submission: PreviewAnnotationSubmission): void => {
16521639
if (submission === "send" && !sendEnabled) return;
1653-
if (voicePreparing) return;
1640+
if (voicePhase === "preparing") return;
16541641
// Submitting while dictating finishes the recording and submits once the text lands.
16551642
if (voiceBusy) {
16561643
if (pendingVoiceSubmission === null) {

0 commit comments

Comments
 (0)