Skip to content

feat(editor): clamp timeline scroll bounds - #59

Merged
byrongamatos merged 3 commits into
feat/editor-snap-togglefrom
feat/editor-scroll-bounds
Jul 5, 2026
Merged

feat(editor): clamp timeline scroll bounds#59
byrongamatos merged 3 commits into
feat/editor-snap-togglefrom
feat/editor-scroll-bounds

Conversation

@ChrisBeWithYou

Copy link
Copy Markdown
Contributor

Summary

  • add shared timeline scroll-bound math with a small tail past the song end
  • clamp wheel pan, middle-drag pan, zoom, seek, playback follow, pending-view restore, and audio duration changes
  • add focused JS coverage for short-song pinning, long-song tail bounds, and invalid scroll values

Testing

  • node --check screen.js
  • node tests/scroll_bounds.test.js
  • node tests/snap_options.test.js
  • node tests/eof_shortcuts.test.js
  • all tests/*.test.js via node

@coderabbitai

coderabbitai Bot commented Jul 4, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 57141d1d-a674-494f-946e-9891ad9a2e9c

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/editor-scroll-bounds

Comment @coderabbitai help to get the list of available commands.

@byrongamatos

Copy link
Copy Markdown
Collaborator

Review pass (Claude Code) — stacked on #58. Clean, well-structured. The pure _editorViewportDurationPure/_editorMaxScrollXPure/_editorClampScrollXPure are correct — NaN/negative → 0, a short song pins to start, a long song scrolls to duration + tail − viewport — and _editorClampScrollX is applied uniformly at every scroll-mutation site (wheel, middle-drag, zoom, seek, follow, pending-view restore, duration change), replacing the old min-only Math.max(0, …) clamps. node --check + all JS tests green (scroll_bounds + snap + shortcut suites). No bug in this PR.

Flags: (1) soft overlap with #46, which also clamps S.scrollX (its _maxScrollX + _jumpCursorTo) at some of the same sites — they'll textually collide there and add two redundant bound helpers, so it's part of the same #46 reconciliation. (2) Inherits the stack-wide drum-shortcut issue (pre-fix #55 base) I detailed on #58 — no new keybindings here, so nothing #59-specific. (Codex rate-limited until ~1 AM — manual + test-backed.)

@byrongamatos

Copy link
Copy Markdown
Collaborator

Codex review pass — found + fixed 2 real bugs in the scroll-bound math I'd missed:

  1. Tail hid the start of short songs: _editorMaxScrollXPure returned duration + tail − viewport unconditionally, so a song that already fits (e.g. 6s song / 7s viewport / 2s tail) still exposed 1s of scroll that could hide the beginning behind a blank tail. Now pins to 0 unless the content actually runs past the viewport.
  2. No re-clamp on resize: the max scroll derives from canvas width, but resizeCanvas() redrew with the stale S.scrollX — widening the editor could leave the timeline past the new max. Added _editorApplyScrollBounds() before the resize draw.
    Both pushed; +test for the fits-but-tail case; all JS tests green. (The 2nd fix's final Codex re-confirm was cut off by the usage limit resetting, but the change is small and verified manually.)

ChrisBeWithYou and others added 3 commits July 5, 2026 14:23
_editorMaxScrollXPure returned duration + tail - viewport unconditionally, so a
song that already fits (e.g. 6s song, 7s viewport, 2s tail) still exposed 1s of
scroll room that could hide the beginning behind a blank tail. Only extend the
scroll range once the content runs past the viewport (duration > viewport).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The max scroll derives from canvas width, but resizeCanvas() redrew with the old
S.scrollX — widening the editor could leave the timeline past the new max with
blank tail. Apply the scroll bounds before drawing on resize.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@byrongamatos
byrongamatos force-pushed the feat/editor-snap-toggle branch from 3ca2420 to bf78154 Compare July 5, 2026 12:25
@byrongamatos
byrongamatos force-pushed the feat/editor-scroll-bounds branch from 15d607c to ee4b88d Compare July 5, 2026 12:25
@byrongamatos
byrongamatos merged commit 04d79b0 into feat/editor-snap-toggle Jul 5, 2026
1 check 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