recorder: auto-scroll segment bar when a clip is added - #171
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR restores “scroll-to-newest” behavior for the recorder segment bar when a new clip is added, while preserving existing delete offset restoration and avoiding conflicts with playhead-follow during preview.
Changes:
- Track segment-count direction changes and schedule an animated
scrollToEndon length increases (new recording/import) when not previewing. - Keep existing “restore previous offset” behavior for length decreases (delete).
- Defer the scroll-to-end until
onContentSizeChangeso the new thumbnail has measured before scrolling.
Suppressed comments (1)
src/features/recorder/segment-bar.tsx:172
onContentSizeChangewill executescrollToEndwheneverstickToEndis set, even if the user has entered preview mode since the segment was added (cursor now truthy). Also, if bothrestoreOffsetandstickToEndare set (e.g. batched updates), the current two independentifblocks will restore the offset and then immediately scroll to end, breaking the delete-preservation behavior. Guard the scroll-to-end by!cursorand make the two branches mutually exclusive, cancelling any pending stick-to-end when previewing.
// Honor a pending scroll-to-newest now that the added thumb has been measured.
if (stickToEnd.current) {
stickToEnd.current = false;
scrollRef.current?.scrollToEnd({ animated: true });
}
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
Suppressed comments (1)
src/features/recorder/segment-bar.tsx:108
stickToEndcan remain set across a subsequent length DECREASE (delete) if a clip is removed before the pendingscrollToEndruns. In that caseonContentSizeChangewill restore the offset and then immediately scroll to end, defeating the delete-preservation behavior. Clear any pendingstickToEndwhen a decrease is detected so deletes can never trigger an unintended auto-scroll.
if (cursor) stickToEnd.current = false;
if (segments.length < prevCount.current) restoreOffset.current = scrollOffset.value;
else if (segments.length > prevCount.current && !cursor) stickToEnd.current = true;
prevCount.current = segments.length;
SarkarShubhdeep
approved these changes
Aug 25, 2026
SarkarShubhdeep
left a comment
Collaborator
There was a problem hiding this comment.
Auto scroll to newly added clip works with no issues.
Scroll-to-newest existed (f2a1e38) but was dropped in 400fc68 along with the scroll-preservation work — a new recording or library import off the right edge of a full bar landed invisibly. Reinstate it alongside the preservation logic as one direction-keyed effect (reorder never changes length, so the branches are mutually exclusive): - length increase (recording or import) in record mode → animated scrollToEnd, deferred to onContentSizeChange so the added thumb has laid out before the scroll - length decrease (delete) → the existing restore-offset behavior, untouched - gated on the cursor being absent: while previewing, playhead-follow owns the scroll Closes #167
A clip add armed stickToEnd, but if the preview opened before onContentSizeChange ran, the stale flag survived and fired an unexpected scrollToEnd on a later content-size change while previewing. Clear it whenever the cursor is present — in the length effect and re-checked in the handler, since the native event can land before the effect re-runs.
morepriyam
force-pushed
the
feat/segment-bar-autoscroll
branch
from
August 26, 2026 05:35
c6e015d to
f664992
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #167.
Stacked on #170 (same file); only the last commit is this PR's change.
Scroll-to-newest existed in f2a1e38 but was dropped in 400fc68 with the scroll-preservation work — since then a clip recorded or imported past the right edge of a full bar lands invisibly off-screen.
Change
Reinstated alongside the preservation logic as one direction-keyed effect — reorder never changes the segment count, so the branches are mutually exclusive by construction:
scrollToEnd, deferred toonContentSizeChangeso the new thumb has laid out before the scroll firesTesting
tsc --noEmit, ESLint, and the jest suite clean