Skip to content

feat(desktop-gpui): add keep only this clip action to timeline clip menu - #3629

Open
ghazy2001 wants to merge 6 commits into
CapSoftware:mainfrom
ghazy2001:feat/editor-keep-only-this-clip-3628
Open

ghazy2001 wants to merge 6 commits into
CapSoftware:mainfrom
ghazy2001:feat/editor-keep-only-this-clip-3628

Conversation

@ghazy2001

@ghazy2001 ghazy2001 commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Closes #3628

Adds a Keep only this clip action to the desktop GPUI video editor timeline's clip context menu right beside Delete clip, allowing users to isolate a single retained clip in one step after splitting a recording instead of deleting every surrounding clip individually.

Changes

  • Core timeline edit (apps/desktop-gpui/src/editor_edits.rs):
    • Added keep_only_clip_segment(timeline, index) with upfront bounds and multi-clip guards (index < timeline.segments.len() and timeline.segments.len() >= 2).
    • Delegates removal of all non-selected clip indices in descending order through delete_clip_segments, preserving the retained clip's trim boundaries and settings (timescale, name, speed_audio_mode, hide_cursor, volume), stripping removed clip transitions, and ripple-trimming/rebasing all associated output tracks (zoom, scene, camera3d, mask, text & fullscreen holds, caption, keyboard, audio with trim_start, style, and image) cleanly to 0.0 without leading or trailing gaps.
  • Editor action, playhead & viewport re-anchoring, and context menu UI (apps/desktop-gpui/src/editor_window.rs):
    • Added EditorWindow::keep_only_clip, committing the mutation as a single undoable history entry (including source-timed caption re-projection via synchronize_caption_track) so a single Undo / Redo restores all removed clips, transitions, and track timings.
    • Added keep_only_playhead and transform_after_keep_only so an interior playhead stays on the same relative frame within the kept clip while an exterior/boundary playhead resets to 0.0, and zoomed-in timeline viewports re-anchor cleanly over [0.0, total] instead of leaving the retained clip off-screen.
    • Added the "clip-menu-keep-only" row above "clip-menu-delete" in render_clip_speed_popover (disabled with a hint when the timeline already has only one clip) and adjusted CLIP_MENU_HEIGHT_ESTIMATE.
  • Localization & tests (apps/desktop-gpui/locales/*.toml, src/i18n/editor_shell_surface_tests.rs):
    • Added editor.window.clip_menu.keep_only and editor.window.clip_menu.keep_only_single_clip across all 7 locale catalogs (en, de, es, fr, hi, ja, zh-CN) and updated editor_shell_surface_tests.
    • Added unit tests covering single-clip/empty/out-of-bounds guards, first/middle/last clip isolation across all synchronized tracks and source-timed captions, single-step undo/redo round-tripping, playhead rebasing, and viewport transform re-anchoring.

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge; the previous playhead issue is fixed.

Summary

Adds “Keep only this clip” to the clip menu, with translations, one-step undo, and track timing tests.

  • The clip menu can keep one clip and remove the rest.

Reviews (2) · Last reviewed commit: "test(desktop-gpui): fix transition type ..." · Reviewed by Greptile

@vercel

vercel Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
cap-status Skipped Skipped Nov 1, 2026 6:06pm UTC

@vercel
vercel Bot temporarily deployed to Preview – cap-status November 1, 2026 16:09 Inactive
Comment thread apps/desktop-gpui/src/editor_window.rs Outdated
Comment on lines +305 to +306
Some((start, end)) if previous_playhead > start && previous_playhead < end => {
(previous_playhead - start).clamp(0.0, new_total.max(0.0))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Playhead jumps behind retained titles

keep_only_playhead subtracts the old clip start but misses fullscreen titles that remain before the clip. For two 10-second clips with a fullscreen title at [10, 12], keeping the second clip moves the title to [0, 2]. The old clip starts at 12, so a playhead at 15 moves to 3; it should move to 5 to show the same recording frame.

Account for the retained clip’s new output start when rebasing, and add a boundary-title test.

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/desktop-gpui/src/editor_window.rs
Line: 305-306

Comment:
**Playhead jumps behind retained titles**

`keep_only_playhead` subtracts the old clip start but misses fullscreen titles that remain before the clip. For two 10-second clips with a fullscreen title at `[10, 12]`, keeping the second clip moves the title to `[0, 2]`. The old clip starts at `12`, so a playhead at `15` moves to `3`; it should move to `5` to show the same recording frame.

Account for the retained clip’s new output start when rebasing, and add a boundary-title test.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in commit 940fd90. keep_only_playhead now rebases against
ew_clip_start (the retained clip's output start) so playhead positions within clips that follow preceding fullscreen titles or holds stay frame-accurate, and added boundary-title unit test coverage.

@vercel
vercel Bot temporarily deployed to Preview – cap-status November 1, 2026 17:27 Inactive
@vercel
vercel Bot temporarily deployed to Preview – cap-status November 1, 2026 17:35 Inactive
@vercel
vercel Bot temporarily deployed to Preview – cap-status November 1, 2026 17:46 Inactive
@vercel
vercel Bot temporarily deployed to Preview – cap-status November 1, 2026 17:50 Inactive
@vercel
vercel Bot temporarily deployed to Preview – cap-status November 1, 2026 18:06 Inactive
@richiemcilroy

Copy link
Copy Markdown
Member

Thanks! Can you get Greptile to 5/5? Then we'll take a look.

@ghazy2001

Copy link
Copy Markdown
Contributor Author

@greptileai review

Re-requesting review on latest commit 0754857 (addresses playhead rebasing with preceding fullscreen titles/holds via new_clip_start, with boundary-title unit tests and GPUI fixtures passing).

This branch was previously deployed

1 inactive deployment
Preview – cap-status — 0754857c Deployed Nov 1, 2026 by vercel[bot]
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.

Feature request: Keep only this clip / Delete other clips in the video timeline context menu

2 participants