From 6640bee95c9ad59dc9629de07a0e31eda28f2d21 Mon Sep 17 00:00:00 2001 From: Kelvin Amoaba <97001695+AmoabaKelvin@users.noreply.github.com> Date: Mon, 9 Nov 2026 19:11:31 +0000 Subject: [PATCH] fix(dictation): join retried phrases with the same spacing rule --- .../src/components/dictation/dictation-kept-recording.ts | 6 +++++- src/shared/dictation-transcript-spacing.ts | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/renderer/src/components/dictation/dictation-kept-recording.ts b/src/renderer/src/components/dictation/dictation-kept-recording.ts index f0b7ca42b0d..7981c21c90f 100644 --- a/src/renderer/src/components/dictation/dictation-kept-recording.ts +++ b/src/renderer/src/components/dictation/dictation-kept-recording.ts @@ -6,6 +6,7 @@ import type { DictationContext } from '../../../../shared/speech-types' import type { DictationInsertionTarget } from './dictation-insertion-target' import type { DictationTranscriptDelivery } from './dictation-transcript-delivery' import { trimLandedOverlap } from './dictation-retry-overlap' +import { appendDictationText } from '../../../../shared/dictation-transcript-spacing' import { showRetryOverlapUnmatchedToast } from './dictation-toasts' // The cloud cap, ten minutes, is about 38 MB of 16 kHz float audio. @@ -92,7 +93,10 @@ function* joinIntoBlocks(chunks: Float32Array[]): Generator { // The retry repeats words that landed before the failure; only what follows them is typed. function insertAfterLanded(recording: DictationKeptRecording, retried: string[]): void { - const { text, matched } = trimLandedOverlap(recording.deliver.landedText(), retried.join(' ')) + const { text, matched } = trimLandedOverlap( + recording.deliver.landedText(), + retried.reduce(appendDictationText, '') + ) if (text) { recording.deliver(text, recording.target) } diff --git a/src/shared/dictation-transcript-spacing.ts b/src/shared/dictation-transcript-spacing.ts index 5698d10f3e2..f67a9686e84 100644 --- a/src/shared/dictation-transcript-spacing.ts +++ b/src/shared/dictation-transcript-spacing.ts @@ -4,7 +4,7 @@ export const DICTATION_TEXT_BLOCK_SELECTOR = // Chinese and Japanese don't space words or after their full-width punctuation; Korean does, so Hangul spaces like Latin text. const UNSPACED_SCRIPT_CHAR_RE = - /^[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\u3000-\u303f\u30fc\uff00-\uffef]$/u + /^[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\u3000-\u303f\u30fb\u30fc\uff00-\uff9f\uffe0-\uffef]$/u const NO_SPACE_BEFORE_CHAR_RE = /^[,.;:!?%。,、!?;:))\]}”’»]$/u const NO_SPACE_AFTER_CHAR_RE = /^[([{(《「『“‘«„]$/u const STRAIGHT_QUOTE_RE = /["'`]/