Cap icon indicating copy to clipboard operation
Cap copied to clipboard

caption word chunking and text assembly duplicated across four places

Open Ker102 opened this issue 1 month ago • 1 comments

The caption word utilities (caption_text_from_words, the attach-to-previous helpers, normalize_caption_words, caption_word_chunks, and the segment size constants) are copy-pasted in four places and they've already drifted.

  • crates/project/src/caption_timing.rs (private copy of the attach helpers + caption_text_from_words)
  • apps/desktop/src-tauri/src/captions.rs (full set: attach helpers, normalize, chunk, text assembly, TARGET_CAPTION_WORDS_PER_SEGMENT etc.)
  • apps/desktop-gpui/src/transcription.rs (same full set again)
  • apps/desktop-gpui/src/editor_window.rs (another caption_text_from_words with the attach list inlined)

Concrete drift: the weak-word boundary check in captions.rs uses normalized.len() <= 1 (bytes) while transcription.rs uses normalized.chars().count() <= 1. So the unicode fix from #2685 only landed in the gpui backend, a one letter word like "à" still counts as two letters on the Tauri side.

I'd move the whole set into cap-project next to CaptionWord and have everything consume it from there. Happy to send that PR, and there's a second one I'd build on top of it (configurable words per caption, issue coming).

richie said on discord he's fine with PRs for this area.

Ker102 avatar Oct 25 '26 22:10 Ker102

CAP-925

linear[bot] avatar Oct 25 '26 22:10 linear[bot]