Skip to content

feat(desktop): transcript editing - soft delete with ability to restore, deleted words buffers, pause deletion#1880

Open
ganganimaulik wants to merge 37 commits into
CapSoftware:mainfrom
ganganimaulik:feat/transcript-editing-buffers
Open

feat(desktop): transcript editing - soft delete with ability to restore, deleted words buffers, pause deletion#1880
ganganimaulik wants to merge 37 commits into
CapSoftware:mainfrom
ganganimaulik:feat/transcript-editing-buffers

Conversation

@ganganimaulik
Copy link
Copy Markdown

@ganganimaulik ganganimaulik commented Jun 1, 2026

Overview

Screenshot 2026-06-01 at 4 18 32 PM Screenshot 2026-06-01 at 4 18 58 PM

right click on deleted word:
Screenshot 2026-06-01 at 4 19 14 PM

This pull request implements comprehensive transcript editing tools for the Cap desktop editor, introducing word/pause deletion, adjustable speech buffers, timeline-wide ripple editing, and an automated "Auto Clean" feature with batch undo/redo.


Key Features

  1. Soft Word Deletion & Restoration

    • Soft-deletes words (deleted: true) rather than splicing them out.
    • Deleting words triggers a ripple cut across all timeline tracks (captions, zoom, mask, text, and keyboard events).
    • Restoring a word shifts the timeline rightward to cleanly re-insert it.
    • Deleted words are filtered out of the visual captions text and the Rust rendering pipeline.
  2. Adjustable Word Buffers (Buffer Popover)

    • Allows users to configure a custom bufferStart and bufferEnd (from -0.5s to 1.0s) around any deleted word by right-clicking it.
    • Modifying these buffers shifts the surrounding timeline tracks dynamically, ensuring word transitions do not cut off trailing/leading syllables.
  3. Pause Detection & Deletion

    • Automatically detects silence gaps between words and renders them as interactive inline pause indicators (e.g., ⏸ 1.2s).
    • Allows deleting pauses directly from the transcript UI, which performs a ripple deletion of that pause duration across the timeline.
  4. Auto-Clean with Batch Undo

    • Automated "Auto Clean" feature that scans the transcript for filler words (uh, um, ah, er, hmm, mhm) and pauses exceeding a configurable silence threshold.
    • Single-click cleans all fillers and long pauses.
    • Full support for batch undo to instantly restore all auto-cleaned items.

Greptile Summary

This PR introduces a comprehensive transcript editing layer on top of the existing caption system: words can be soft-deleted (marked deleted: true) and later restored with full ripple edits across all timeline tracks, pauses between words are surfaced as interactive inline badges, adjustable pre/post buffers let users fine-tune how much silence is removed around each deleted word, and an Auto Clean button batch-deletes filler words and long silences in one click. The Rust backend is updated to carry the new metadata fields through serde and to filter deleted words from the rendered caption output.

  • Soft delete / restore: applyWordDeletions marks words deleted and runs rippleDeleteAllTracks; restoreWords reverses this by inserting the original cut duration back with rippleInsertAllTracks. Timing math is correct when restoring multiple words because processing happens in chronological order so each word's stored position already reflects prior restorations.
  • Pause detection & deletion: The pauses memo computes silent gaps between visible words and renders PauseBadge components; handleDeletePause inserts a synthetic pause word (always deleted: true) and performs the ripple cut — these words are filtered from the Rust renderer by the !w.deleted guard.
  • Auto Clean: Iterates over keeper words, marks fillers deleted, caps trailing silence on word ends, then merges and applies ripple cuts for all filler gaps and long silences in reverse order so original coordinates stay valid throughout.

Confidence Score: 4/5

Safe to merge; the ripple-edit math is sound and no data-corruption paths were found.

The core timeline arithmetic is correct and well-covered by inline vitest tests. The four flagged items are all non-blocking: a pause-badge inaccuracy under non-default buffer values, a missing click-outside handler, a misleading variable name/comment, and potentially surprising Backspace behavior on mixed selections. None corrupt project data.

apps/desktop/src/routes/editor/TranscriptPage.tsx contains all four flagged items and is worth a close read before merging.

Important Files Changed

Filename Overview
apps/desktop/src/routes/editor/TranscriptPage.tsx Core of the PR – adds soft delete/restore, pause detection, buffer popover, and Auto Clean; four issues flagged: inverted buffer formula in pause detection, missing click-outside for the dropdown, misleading comment/variable name in restoreWords, and mixed-selection Backspace behavior
apps/desktop/src/routes/editor/timeline-utils.ts Adds ripple-insert counterparts and fixes cutClipSegmentsForRange when endSegIdx is never reached; logic and tests look correct
apps/desktop/src/routes/editor/captions.ts Updates getCaptionTextFromWords and createCaptionTrackSegments to filter deleted/pause words from visible text; changes are correct and test data is updated accordingly
apps/desktop/src-tauri/src/captions.rs Adds Whisper/Parakeet word-duration capping heuristic and ..Default::default() for new CaptionWord fields; capping logic is duplicated between mid-segment and final-word paths
crates/rendering/src/layers/captions.rs Filters deleted words from rendered caption text and word list; since pause words always have deleted=true, no pause placeholder text leaks through
crates/project/src/configuration.rs Adds five #[serde(default)] fields to CaptionWord; backward-compatible with existing project files
apps/desktop/src/utils/tauri.ts Extends generated CaptionWord type with the five optional editing fields to match the updated Rust struct
apps/desktop/src/routes/editor/Timeline/ClipTrack.tsx Adds null guards for missing segments in WaveformCanvas and the For-loop body; safe defensive fix
apps/desktop/src/routes/editor/filler-detection.ts New file with isFillerWord, detectPauses, and constants; well-tested with vitest inline tests
apps/desktop/src/routes/editor/caption-types.ts New thin type file extending BaseCaptionWord with the five optional editing fields; straightforward

Comments Outside Diff (1)

  1. apps/desktop/src/routes/editor/TranscriptPage.tsx, line 199-254 (link)

    P2 Incorrect deletedDurationInGap formula for non-zero buffers

    protectedStart = Math.max(0, -bufStart) only contributes when bufStart is negative (i.e., the cut is smaller than the word). For the common positive-buffer case — where the actual cut extends beyond the word — nothing is added, so deletedDurationInGap undercounts by bufferStart + bufferEnd. This means silentGap = gap - deletedDurationInGap ends up larger than the real remaining silence, causing false pause badges to appear between deleted words whenever a user has adjusted buffers to positive values.

    The effective deleted duration is curr.storedEnd + bufEnd - Math.max(0, curr.start - bufStart), which should replace the current formula.

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: apps/desktop/src/routes/editor/TranscriptPage.tsx
    Line: 199-254
    
    Comment:
    **Incorrect `deletedDurationInGap` formula for non-zero buffers**
    
    `protectedStart = Math.max(0, -bufStart)` only contributes when `bufStart` is negative (i.e., the cut is *smaller* than the word). For the common positive-buffer case — where the actual cut extends beyond the word — nothing is added, so `deletedDurationInGap` undercounts by `bufferStart + bufferEnd`. This means `silentGap = gap - deletedDurationInGap` ends up larger than the real remaining silence, causing false pause badges to appear between deleted words whenever a user has adjusted buffers to positive values.
    
    The effective deleted duration is `curr.storedEnd + bufEnd - Math.max(0, curr.start - bufStart)`, which should replace the current formula.
    
    How can I resolve this? If you propose a fix, please make it concise.
Prompt To Fix All With AI
Fix the following 5 code review issues. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 5
apps/desktop/src/routes/editor/TranscriptPage.tsx:199-254
**Incorrect `deletedDurationInGap` formula for non-zero buffers**

`protectedStart = Math.max(0, -bufStart)` only contributes when `bufStart` is negative (i.e., the cut is *smaller* than the word). For the common positive-buffer case — where the actual cut extends beyond the word — nothing is added, so `deletedDurationInGap` undercounts by `bufferStart + bufferEnd`. This means `silentGap = gap - deletedDurationInGap` ends up larger than the real remaining silence, causing false pause badges to appear between deleted words whenever a user has adjusted buffers to positive values.

The effective deleted duration is `curr.storedEnd + bufEnd - Math.max(0, curr.start - bufStart)`, which should replace the current formula.

### Issue 2 of 5
apps/desktop/src/routes/editor/TranscriptPage.tsx:665-722
**Auto Clean dropdown has no click-outside dismissal**

The `showAutoCleanDropdown` popover has no click-outside handler, so once opened it stays visible until the user explicitly clicks the toggle button again or a button inside the dropdown. Compare with `BufferPopover`, which correctly uses `createEventListener(document, "mousedown", handleClickOutside)`. An equivalent handler should be added here so the dropdown closes whenever a click lands outside it.

### Issue 3 of 5
apps/desktop/src/routes/editor/TranscriptPage.tsx:340-346
**Misleading variable name and comment in `restoreWords`**

`sortedByIndex` is sorted descending (last words first), so `reversedWords = [...sortedByIndex].reverse()` is actually in ascending chronological order (first word first). The comment `// Process in reverse so that shifting words doesn't affect the indices/times of earlier words` is the opposite of what the code does. The correct explanation is: processing from earliest to latest ensures each word's stored position already reflects all prior restorations when we compute the `insertDuration`. Consider renaming `reversedWords` to `chronologicalWords` (or similar) and updating the comment to avoid future confusion.

### Issue 4 of 5
apps/desktop/src/routes/editor/TranscriptPage.tsx:1095-1116
**Backspace simultaneously deletes and restores on mixed selections**

When a user selects a range that contains both deleted and non-deleted words then presses Backspace, the handler deletes the non-deleted words AND restores the deleted ones in a single keystroke. This is surprising: the two operations don't cancel out (each produces a different ripple edit), and the undo history will record them as a single action. Consider resolving the mixed state to a single intent — e.g., if any non-deleted words are selected, only delete those; if all selected words are already deleted, restore them.

### Issue 5 of 5
apps/desktop/src-tauri/src/captions.rs:812-860
**Duration-capping logic is duplicated in two places**

The block that computes `max_duration` and clamps `word_end` appears identically at both the mid-segment word-completion path and the final-word path. Extracting it into a small inline helper (or a closure) would eliminate the duplication and make future tuning of the heuristic a single-site change.

Reviews (1): Last reviewed commit: "fix: remove timeline clamping in handleB..." | Re-trigger Greptile

Greptile also left 4 inline comments on this PR.

This fixes a boundary math flaw where restoring a word could cause adjacent words exactly at the insert point to stretch their durations instead of simply shifting right, gradually desyncing the timeline.
- Passing explicit ignoreWords lists to shiftCaptionTimesAfterCut and shiftCaptionTimesAfterInsert
- Prevents deleted words from being shifted by their own cut durations if buffer values are negative
- Ensures proper tracking of _markForRemoval for restoring words
…econstruct timeline and prevent pause blocks"

This reverts commit dfa8dfe.
…xtended does not have storedEnd, causing NaN timeline corruption
…y search with findIndex in activeWordIndex to support perfect reverse timeline math without pause block corruption
@ganganimaulik ganganimaulik marked this pull request as ready for review June 1, 2026 15:03
Comment thread apps/desktop/src/routes/editor/TranscriptPage.tsx
Comment thread apps/desktop/src/routes/editor/TranscriptPage.tsx
Comment thread apps/desktop/src/routes/editor/TranscriptPage.tsx
Comment thread apps/desktop/src-tauri/src/captions.rs
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.

1 participant