Skip to content

feat(studio): zoom the timeline to the selected clips - #5597

Closed
MannXo wants to merge 1 commit into
heygen-com:mainfrom
MannXo:feat/5581-zoom-to-selected-clips
Closed

MannXo wants to merge 1 commit into
heygen-com:mainfrom
MannXo:feat/5581-zoom-to-selected-clips

Conversation

@MannXo

@MannXo MannXo commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

What

Adds a "Zoom to selected clips" button to the timeline toolbar, next to Fit, and the Z key for the same action. The timeline zooms and scrolls so the selected clips span its visible width. With no clip selected the button is disabled and its tooltip says "Select clips to zoom to them".

Why

Fit shows the whole composition, but tightening a cut in a long one means zooming in by hand and then scrolling to find the clips again.

Related work

Fixes #5581

How

  • selectedClipsRange in timelineSelectionZoom.ts is the one function that holds the math. It takes the timeline elements and the selected ids and returns the span from the first selected clip's start to the last one's end, or null when nothing selected resolves to a clip. It matches ids the way the Delete key does (key ?? id, plus the selection anchor).
  • zoomToSelectedClips hands that span to the existing zoomTimelineToRange, which already eases the zoom, clamps it to the zoom limits and leaves the 24px range margin on each side. Nothing new was needed for the zoom or the scroll themselves.
  • A clip at the very start or end of the timeline stays fully on screen. The scroll cannot go past the content, so on that side the clip sits at the timeline edge instead of the margin.
  • The button is its own small component, ZoomToSelectionButton.tsx, so TimelineToolbar.tsx stays under the 600-line cap.
  • Z is added to STUDIO_PLAIN_KEYS and to the shortcuts panel under Editing. Only ⌘Z and ⌘⇧Z were bound before, and the plain-key dispatcher already skips text fields.
  • Expanded sub-composition children select as file#id, which is not in the timeline element list, so selecting only those leaves the button disabled. The S split key has the same limit today.

Before

After

Test plan

  • Unit tests added/updated

  • Manual testing performed

  • Documentation updated (if applicable)

  • Comments follow CONTRIBUTING.md "Comments": they say why, not what, and a bug fix says what the code must do and how to reproduce the bug

  • timelineSelectionZoom.test.ts covers the range for a single clip, several clips with gaps, a long clip that ends after a later one, clips at the very start and end, keyed ids, and an empty or unresolvable selection. It also drives the real zoom on a mounted viewport, checking that the span fills the width between the margins and that a first or last clip stays on screen.

  • TimelineToolbar.test.tsx covers the button's disabled and enabled states, a click, and the Z key with and without a selection.

  • In Chrome on the studio-open fixture, I selected Scene4 and Scene5 and pressed Z. They went from 254px at Fit to spanning x=107 to 1892 of the 1920px timeline. With the first clip selected it landed at x=84 to 1868, and with the last clip at x=107 to 1892.

  • bun run --cwd packages/studio test, bun run lint, bun run format:check, bun run --filter '*' typecheck, the comment citation and ratchet checks, bunx fallow audit --base origin/main --fail-on-issues and the test reachability check all pass locally.

A toolbar button next to Fit and the Z key zoom and scroll the timeline
so the selected clips span its width, through zoomTimelineToRange. The
button is disabled, with a tooltip saying why, while no clip is
selected.

Fixes heygen-com#5581
@jrusso1020

Copy link
Copy Markdown
Collaborator

Thanks for picking up #5581. #5824 covers the same issue and is close to landing, so I'm closing this as a duplicate. If something in your version is missing there, leave a note on #5824.

@jrusso1020 jrusso1020 closed this Oct 25, 2026
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.

Timeline: zoom to the selected clips

2 participants