-
Notifications
You must be signed in to change notification settings - Fork 1.1k
fix: split action respects segment timescale (speed) #1446
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: split action respects segment timescale (speed) #1446
Conversation
WalkthroughSplit and duration calculations for clip segments were made timescale-aware: splitting now normalizes computed times against the segment's Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20–30 minutes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ 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 |
|
Amazing! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
apps/desktop/src/routes/editor/Timeline/TrackManager.tsx (1)
60-60: Consider moving unrelated UI styling to a separate PR.This background color change appears unrelated to the PR's stated objective of fixing the timescale bug in the split tool. Mixing cosmetic UI changes with bug fixes can make code review and git history less clear.
Additionally, note that
TrackIconat line 72 still usesbg-gray-2/60. If this background change is intentional, verify whetherTrackIconshould be updated for visual consistency.
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
apps/desktop/src/routes/editor/Timeline/TrackManager.tsx(1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.tsx
📄 CodeRabbit inference engine (CLAUDE.md)
Use React Query hooks with Server Actions for mutations and perform precise cache updates using setQueryData/setQueriesData instead of broad invalidations
Files:
apps/desktop/src/routes/editor/Timeline/TrackManager.tsx
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.{ts,tsx,js,jsx}: Use strict TypeScript; avoid any type; leverage shared types from @cap/* packages
Follow camelCase naming for variables and functions; PascalCase for components; hooks must start with 'use' prefix
Use Biome for linting and formatting; match existing formatting conventions in the codebase
Use Tailwind CSS for styling in web components; stay consistent with spacing and tokens
Use static skeletons for loading states that mirror content; avoid bouncing animations
Memoize expensive work, code-split naturally, and use Next/Image for remote assets
**/*.{ts,tsx,js,jsx}: Use 2-space indent for TypeScript files; format with Biome usingpnpm format
Use Biome for code formatting and linting; runpnpm formatregularly
Use kebab-case for file names (e.g.,user-menu.tsx); use PascalCase for components
Files:
apps/desktop/src/routes/editor/Timeline/TrackManager.tsx
**/*.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.{ts,tsx}: Never add any form of comments to code (single-line //, multi-line /* /, JSDoc /* */, or any other comment syntax); code must be self-explanatory through naming, types, and structure
Directory naming must use lowercase-dashed convention
Files:
apps/desktop/src/routes/editor/Timeline/TrackManager.tsx
**/*.{ts,tsx,js,jsx,rs}
📄 CodeRabbit inference engine (AGENTS.md)
Never add comments to code (
//,/* */,///,//!,#, etc.); code must be self-explanatory through naming, types, and structure
Files:
apps/desktop/src/routes/editor/Timeline/TrackManager.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Cursor Bugbot
Fix: Split action respects segment timescale (speed)
Problem
#1445 When using the split tool (scissors) on the timeline, if a previous segment had a modified playback speed (timescale), the split would occur at the wrong position instead of where the user clicked.
Root Cause
The code was mixing two different time representations:
(end - start) / timescaleend - startThe
splitClipSegmentfunction searched for the target segment using recording time durations instead of timeline time, causing incorrect segment detection when earlier segments had modified speeds.Example
Consider this timeline:
When clicking to split at 25% into Segment 1 (which is at 75s into the timeline):
Changes
apps/desktop/src/routes/editor/context.tstimescalewhen calculating segment duration during searchapps/desktop/src/routes/editor/Timeline/ClipTrack.tsxsplitTimein timeline time (divide bytimescale) to be consistent withprevDuration()Testing
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.
Note
Ensure clip splitting uses timeline time and converts to recording time so splits occur at correct positions with speed-adjusted segments; minor add-button style tweak.
projectActions.splitClipSegmentinapps/desktop/src/routes/editor/context.tsto search by timeline duration(end - start) / timescaleand convert split position back to recording time (* timescale).apps/desktop/src/routes/editor/Timeline/ClipTrack.tsx, computesplitTimeasfraction * (end - start) / timescalebefore callingsplitClipSegment.apps/desktop/src/routes/editor/Timeline/TrackManager.tsxadd button styling (classchanges).Written by Cursor Bugbot for commit 73b4b71. This will update automatically on new commits. Configure here.