Skip to content

refactor(studio): improve Timeline, PlayerControls, and player hook#63

Merged
miguel-heygen merged 3 commits intomainfrom
studio/3-timeline-player
Mar 28, 2026
Merged

refactor(studio): improve Timeline, PlayerControls, and player hook#63
miguel-heygen merged 3 commits intomainfrom
studio/3-timeline-player

Conversation

@miguel-heygen
Copy link
Copy Markdown
Collaborator

@miguel-heygen miguel-heygen commented Mar 26, 2026

Summary

  • Timeline: Refactored track rendering with zoom support, drag/resize interactions, and playhead scrubbing
  • PlayerControls: Redesigned with seek bar, time display, playback rate selector
  • useTimelinePlayer: Enhanced with iframe bridge communication, timeline message parsing, and deterministic seek
  • Add Timeline unit tests (109 lines)

🤖 Generated with Claude Code

@miguel-heygen miguel-heygen force-pushed the studio/2-timeline-components branch from e745317 to 5c3dfeb Compare March 26, 2026 18:29
@miguel-heygen miguel-heygen force-pushed the studio/3-timeline-player branch 2 times, most recently from 239c259 to 3f73516 Compare March 26, 2026 18:37
@miguel-heygen miguel-heygen force-pushed the studio/2-timeline-components branch from 5c3dfeb to 83c21e2 Compare March 26, 2026 18:37
@miguel-heygen miguel-heygen force-pushed the studio/3-timeline-player branch from 3f73516 to fa1456d Compare March 26, 2026 18:44
@miguel-heygen miguel-heygen force-pushed the studio/2-timeline-components branch 2 times, most recently from 2d2514e to 4eb3fd0 Compare March 26, 2026 19:25
@miguel-heygen miguel-heygen force-pushed the studio/3-timeline-player branch from fa1456d to 38e3bb8 Compare March 26, 2026 19:25
@miguel-heygen miguel-heygen force-pushed the studio/2-timeline-components branch from 4eb3fd0 to 5bf4c98 Compare March 26, 2026 19:47
@miguel-heygen miguel-heygen force-pushed the studio/3-timeline-player branch 3 times, most recently from 14e3a4d to 3a0d4bd Compare March 26, 2026 20:05
@miguel-heygen miguel-heygen force-pushed the studio/2-timeline-components branch from 5bf4c98 to 3af8a9f Compare March 26, 2026 20:05
@miguel-heygen miguel-heygen changed the title refactor(studio): improve Timeline, PlayerControls, and useTimelinePlayer refactor(studio): improve Timeline, PlayerControls, and player hook Mar 26, 2026
@vanceingalls
Copy link
Copy Markdown
Collaborator

Review: PR #63 — Timeline, PlayerControls, Player Hook

Good performance optimizations with imperative DOM updates. One critical test issue.

Issues

[Critical] Timeline.test.ts tests a stale copy of `generateTicks`. The replicated function in the test file lacks all three safety improvements added to the real Timeline.tsx in this same PR: Number.isFinite guard, duration > 7200 cap, maxTicks loop cap, and minorInterval floor of 0.25. The tests pass against the old algorithm but don't validate the actual shipped code. Extract these functions to a shared module and import in both the component and tests.

[Important] `useTimelinePlayer` `onIframeLoad` polls with a 25-attempt limit (5s). If the runtime takes longer to initialize, the timeline silently fails. Warning is logged but there's no user-visible feedback or retry.

**[Suggestion] Speed menu has no click-outside-to-close handler.

**[Suggestion] `onClipChange` prop is declared in `TimelineProps` but never used in the component body.

What's well done

  • PlayerControls uses imperative DOM updates via refs for progress bar and time display — avoids React re-renders at 60fps
  • generateTicks hardened with isFinite guard, duration cap, minor interval floor, max ticks safety
  • effectiveDuration correctly uses max of store duration and furthest element end
  • Auto-scroll during playback and drag-to-scroll near edges
  • handlePointerDown checks e.button !== 0 to ignore right-clicks

@miguel-heygen miguel-heygen force-pushed the studio/2-timeline-components branch from 3af8a9f to b641529 Compare March 26, 2026 20:48
@miguel-heygen miguel-heygen force-pushed the studio/3-timeline-player branch from 3a0d4bd to 819ed22 Compare March 26, 2026 20:48
@miguel-heygen
Copy link
Copy Markdown
Collaborator Author

Great catches Vance!

Addressed:

  • [Critical] Tests now import the real generateTicks and formatTick from Timeline.tsx (exported). No more duplicated logic — tests validate the actual shipped code.
  • onClipChange unused prop removed from Timeline component
  • trackOffsets (drag-related) removed entirely

Not addressed (tracked for follow-up):

  • useTimelinePlayer 25-attempt polling limit — will add user-visible feedback on timeout
  • Speed menu click-outside-to-close — will add in UI polish pass

Copy link
Copy Markdown
Collaborator Author

miguel-heygen commented Mar 28, 2026

Merge activity

@miguel-heygen miguel-heygen changed the base branch from studio/2-timeline-components to graphite-base/63 March 28, 2026 08:00
@miguel-heygen miguel-heygen force-pushed the studio/3-timeline-player branch 2 times, most recently from 44b0ac0 to a5f1a98 Compare March 28, 2026 18:00
…d tests

- Add zoom state (zoomMode, pixelsPerSecond) to player store
- Add updateElementDuration, updateElementTrack, updateElement actions
- Remove agent activity tracking (activeEdits, agentId, agentColor)
- Add comprehensive store tests (265 lines)
- Add time utility tests
- TimelineClip: extracted clip rendering with drag, resize, and selection
- CompositionThumbnail: renders composition preview as timeline thumbnail
- VideoThumbnail: extracts and displays video frame thumbnails via canvas
@miguel-heygen miguel-heygen force-pushed the studio/3-timeline-player branch from a5f1a98 to 51cd554 Compare March 28, 2026 18:05
@miguel-heygen miguel-heygen changed the base branch from graphite-base/63 to main March 28, 2026 18:05
@miguel-heygen miguel-heygen force-pushed the studio/3-timeline-player branch 2 times, most recently from e6c4d1f to a75cc6a Compare March 28, 2026 18:15
…ayer

- Timeline: refactored track rendering, zoom support, drag/resize
- PlayerControls: updated layout, added playback rate selector
- useTimelinePlayer: improved seeking, element discovery, composition support
- Added Timeline tests (149 lines)
@miguel-heygen miguel-heygen force-pushed the studio/3-timeline-player branch from a75cc6a to b9274af Compare March 28, 2026 18:27
@miguel-heygen miguel-heygen merged commit 0769678 into main Mar 28, 2026
14 checks passed
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.

2 participants