feat: add range selection functionality to element interaction
Closes #801
Adds Shift-click range selection for timeline clips on the same row.
Summary by CodeRabbit
- New Features
- Shift-range selection: hold Shift and click to select a contiguous range of timeline elements between an anchor and a target.
- Anchor-aware selection: range selection uses an anchor when on the same track; otherwise selection falls back to the clicked element, and editor selection is updated for each element in the chosen range.
@oguzhancttnky is attempting to deploy a commit to the OpenCut OSS Team on Vercel.
A member of the Team first needs to authorize it.
[!NOTE]
Reviews paused
It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the
reviews.auto_review.auto_pause_after_reviewed_commitssetting.Use the following commands to manage reviews:
@coderabbitai resumeto resume automatic reviews.@coderabbitai reviewto trigger a single review.Use the checkboxes below for quick actions:
- [ ] ▶️ Resume reviews
- [ ] 🔍 Trigger review
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 58acbfc1-1ad8-415e-bc04-fd1810a6aec8
📥 Commits
Reviewing files that changed from the base of the PR and between a9c37b9503e48b71850da0c4d86d5133b215e096 and ae2b34e1145085e8c84734f542200e55d1b27eb3.
📒 Files selected for processing (2)
apps/web/src/timeline/controllers/element-interaction-controller.tsapps/web/src/timeline/hooks/element/use-element-selection.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- apps/web/src/timeline/controllers/element-interaction-controller.ts
- apps/web/src/timeline/hooks/element/use-element-selection.ts
📝 Walkthrough
Walkthrough
Adds shift-click range selection: new selectRange API, a hook selectElementRange that computes inclusive contiguous ranges ordered by startTime, and controller wiring that tracks an anchor and calls selectRange on shift-click.
Changes
Range Selection Feature
| Layer / File(s) | Summary |
|---|---|
Selection API Contract apps/web/src/timeline/controllers/element-interaction-controller.ts |
ElementSelectionApi gains selectRange method accepting an optional anchor and required target, returning the selected element refs. |
Range selection logic & hook export apps/web/src/timeline/hooks/element/use-element-selection.ts |
Adds selectElementRange (resolve target track via findTrackInSceneTracks, validate anchor on same track, order elements by startTime with stable tie-break, select inclusive slice between anchor and target, fallback to target-only) and returns it from the hook. |
Controller wiring & anchor handling apps/web/src/timeline/controllers/element-interaction-controller.ts, apps/web/src/timeline/hooks/element/use-element-interaction.ts |
Controller stores elementSelectionAnchor, wires selection.selectRange to the hook callback, handles shift-mousedown by calling selectRange(anchor, target) and sets selectedElements from the returned range, and updates/preserves anchor during click handling with an early return for multi-selection/range paths. |
Sequence Diagram
sequenceDiagram
participant User
participant ElementInteractionController
participant ElementSelectionApi
participant useElementSelection
User->>ElementInteractionController: Shift+click targetElement
ElementInteractionController->>ElementSelectionApi: selectRange(anchor?, target)
ElementSelectionApi->>useElementSelection: selectElementRange(anchor?, target)
useElementSelection->>useElementSelection: Resolve track & anchor
useElementSelection->>useElementSelection: Order elements by startTime (stable)
useElementSelection->>useElementSelection: Compute inclusive slice anchor→target
useElementSelection-->>ElementSelectionApi: selectedElementRefs[]
ElementSelectionApi-->>ElementInteractionController: selectedElementRefs[]
ElementInteractionController->>ElementInteractionController: Update selectedElements & anchor
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~20 minutes
Poem
🐰 I hopped from anchor to end with a twitch of my paw,
Shifted the range and each clip found its place,
Ordered by time, tied indices kept pace,
From first click to target the selection did span,
A tiny rabbit cheer for a timeline well-planned.
🚥 Pre-merge checks | ✅ 3 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | ⚠️ Warning | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. | Write docstrings for the functions missing them to satisfy the coverage threshold. |
| Description check | ❓ Inconclusive | The PR description is minimal but adequate, referencing the linked issue and briefly describing the feature. However, it does not follow the repository's description template. | Consider filling out the template sections relevant to this feature, or clarify if the maintainer approval mentioned in the template has been obtained. |
✅ Passed checks (3 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title check | ✅ Passed | The title accurately summarizes the main change: adding range selection functionality to element interaction, which is the primary focus of this PR. |
| Linked Issues check | ✅ Passed | The PR implementation meets all coding requirements from issue #801: adds selectRange method and anchor-based range selection [#801], preserves Ctrl/Cmd-click behavior [#801], and implements same-row fallback selection [#801]. |
| Out of Scope Changes check | ✅ Passed | All changes are scoped to range selection functionality. The modifications add the selectRange method, anchor state management, and range selection logic—all directly aligned with issue #801 requirements. |
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing Touches
🧪 Generate unit tests (beta)
- [ ] Create PR with unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.
-
Just copy the description: Can you copy and paste the PR's title, description and all the error logs or stack traces discussed during the conversation, so I can help you review it.
-
Look at “Linked Issues”: most PRs will have a linked issue (like “Fixes #799”). Check the linked issue in the PR for the full context.
-
Look at the "Files Changed" tab: if the PR is a big one, a quick browse of the "files changed" tab will give you clues to the main fix (updating a dependency, fixing a bug in the Rust/WASM core, correcting a layout of the UI).