feat: use multiple clips for 'zoom to selection' ('z')#13
Conversation
📝 WalkthroughWalkthrough
ChangesSelection zoom behavior
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
app.js (1)
1227-1228: 🚀 Performance & Scalability | 🔵 Trivial | 💤 Low valueConsider
reduceinstead of spread for very large selections.
Math.min(...clips.map(...))andMath.max(...clips.map(...))spread the entire array as arguments. While unlikely to matter in practice (clip counts are typically modest), engines cap argument counts (~65k+). Areduce-based approach avoids this theoretical limit and also avoids creating an intermediate array.♻️ Optional refactor using reduce
- const t0 = Math.min(...clips.map((c) => c.start)); - const t1 = Math.max(...clips.map((c) => c.start + c.duration)); + const t0 = clips.reduce((m, c) => Math.min(m, c.start), Infinity); + const t1 = clips.reduce((m, c) => Math.max(m, c.start + c.duration), -Infinity);🤖 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 `@app.js` around lines 1227 - 1228, Update the t0 and t1 calculations to use reduce over clips instead of map followed by spread into Math.min and Math.max. Preserve the existing minimum start and maximum end-time results while avoiding intermediate arrays and argument-count limits.
🤖 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.
Nitpick comments:
In `@app.js`:
- Around line 1227-1228: Update the t0 and t1 calculations to use reduce over
clips instead of map followed by spread into Math.min and Math.max. Preserve the
existing minimum start and maximum end-time results while avoiding intermediate
arrays and argument-count limits.
What does this PR do?
'Zoom to selection' invoked by a shortcut 'z' now uses multiple selected clips.
Closes #
Type of change
How was it verified?
node --check server.js && node --check app.js && node --check mcp-server.jspassesCLAUDE.md/README.mdif the schema, props, or API changedChecklist
Summary by CodeRabbit
Bug Fixes
Documentation
Zkey zooms to selected clips.