Skip to content

refactor: move caption word utilities into cap-project - #3295

Merged
richiemcilroy merged 6 commits into
CapSoftware:mainfrom
Ker102:refactor/caption-words-shared-module
Oct 26, 2026
Merged

richiemcilroy merged 6 commits into
CapSoftware:mainfrom
Ker102:refactor/caption-words-shared-module

Conversation

@Ker102

@Ker102 Ker102 commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Sorry for the noise, I put the first version of this up from the wrong account (#3278), it was supposed to go here.

Moves the caption word utilities (caption_text_from_words, the attach-to-previous helpers, normalize_caption_words, caption_word_chunks, and the segment size constants) into cap_project::caption_words and points everything at it. The copies had drifted apart, details in #3290.

Pure refactor: apps/desktop keeps its own copy since that app no longer ships, and the shared module keeps the gpui behavior throughout (the weak-word boundary check compares chars, the #2685 fix). Also folds in the f64 copy of MAX_CAPTION_WORD_DURATION from crates/rendering/src/layers/captions.rs, which now derives from the shared const instead of a comment asking people to keep it in sync.

Tested:

  • cargo test -p cap-project: 195 passed
  • cargo clippy -p cap-project --all-features -- -D warnings, cargo fmt --check
  • cargo check -p cap-rendering -p cap-verify --tests: compiles
  • cargo test --no-run for the gpui app and all its test targets (unit tests, camera_convert, editor_frame0): compiles and links, run on this branch with the stacked follow-up on top

everything ran in an ubuntu 24.04 container with the repo's toolchain.

Closes #3290

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge.

Summary

Moves caption word helpers and limits into cap_project::caption_words.

  • Caption word rules now come from one shared project module.

Reviews (1) · Last reviewed commit: "fix: address review notes on the shared ..." · Reviewed by Greptile

)

caption_text_from_words, the attach-to-previous helpers,
normalize_caption_words, caption_word_chunks and the segment size constants
were copy-pasted across captions.rs (tauri), transcription.rs (gpui),
editor_window.rs (gpui) and caption_timing.rs, and the copies had drifted.
They now all consume the single set in cap_project::caption_words.

One behavior change: the weak-word boundary check on the Tauri side compared
byte length (normalized.len() <= 1), so non-ASCII one letter words like "à"
counted as two letters there. The shared version compares chars().count(),
matching what CapSoftware#2685 landed in the gpui backend.
Drop the Tauri app changes (apps/desktop no longer ships), the module
comment and the comment restating normalize_caption_words, and correct
the caption_word_chunks doc: the short tail merge can put a segment over
the max, so the doc no longer promises a hard cap.
@vercel

vercel Bot commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

@Ker102 is attempting to deploy a commit to the Cap Software Inc Team on Vercel.

A member of the Team first needs to authorize it.

@richiemcilroy
richiemcilroy merged commit f6046f1 into CapSoftware:main Oct 26, 2026
54 of 57 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

caption word chunking and text assembly duplicated across four places

2 participants