feat: add range selection functionality to element interaction#800
feat: add range selection functionality to element interaction#800oguzhancttnky wants to merge 3 commits into
Conversation
|
@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 pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughAdds shift-click range selection: new ChangesRange Selection Feature
Sequence DiagramsequenceDiagram
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
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
apps/web/src/timeline/hooks/element/use-element-selection.ts (1)
86-99:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winDeduplicate incoming
elementsas well, not just overlap with current selection.On Lines 88-98, duplicates inside
elementssurvive the merge, so selection can contain repeated refs.💡 Proposed fix
const mergeElementsIntoSelection = useCallback( ({ elements }: { elements: ElementRef[] }) => { - const merged = [ - ...selectedElements.filter( - (selectedElement) => - !elements.some( - (element) => - element.trackId === selectedElement.trackId && - element.elementId === selectedElement.elementId, - ), - ), - ...elements, - ]; + const merged: ElementRef[] = []; + const seen = new Set<string>(); + for (const element of [...selectedElements, ...elements]) { + const key = `${element.trackId}:${element.elementId}`; + if (seen.has(key)) continue; + seen.add(key); + merged.push(element); + } editor.selection.setSelectedElements({ elements: merged }); }, [selectedElements, editor], );🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/web/src/timeline/hooks/element/use-element-selection.ts` around lines 86 - 99, mergeElementsIntoSelection currently only filters out incoming elements that overlap with selectedElements but does not deduplicate duplicates within the incoming elements array itself, allowing repeated ElementRef entries to be merged into selection; update the function to first deduplicate the incoming elements (based on element.trackId + element.elementId) before merging, then build merged = [...existingFiltered, ...dedupedIncoming] and call editor.selection.setSelectedElements with that merged list (refer to mergeElementsIntoSelection, selectedElements, elements parameter, and editor.selection.setSelectedElements).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@apps/web/src/timeline/hooks/element/use-element-selection.ts`:
- Around line 86-99: mergeElementsIntoSelection currently only filters out
incoming elements that overlap with selectedElements but does not deduplicate
duplicates within the incoming elements array itself, allowing repeated
ElementRef entries to be merged into selection; update the function to first
deduplicate the incoming elements (based on element.trackId + element.elementId)
before merging, then build merged = [...existingFiltered, ...dedupedIncoming]
and call editor.selection.setSelectedElements with that merged list (refer to
mergeElementsIntoSelection, selectedElements, elements parameter, and
editor.selection.setSelectedElements).
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 7396d58d-c64e-4e5c-9de9-cd27c94b3b79
📒 Files selected for processing (3)
apps/web/src/timeline/controllers/element-interaction-controller.tsapps/web/src/timeline/hooks/element/use-element-interaction.tsapps/web/src/timeline/hooks/element/use-element-selection.ts
e51e76d to
e223348
Compare
a9c37b9 to
ae2b34e
Compare
Closes #801
Adds Shift-click range selection for timeline clips on the same row.
Summary by CodeRabbit