-
Notifications
You must be signed in to change notification settings - Fork 70
refine scrolling #468
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
refine scrolling #468
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -68,14 +68,14 @@ | |
|
|
||
| onMount(() => { | ||
| // Load history, wait for Svelte to flush the new list items to the | ||
| // DOM, then attach OverlayScrollbars and scroll to bottom. Without | ||
| // DOM, then attach OverlayScrollbars and pin to the bottom. Without | ||
| // the tick() wait, scrollHeight is read before the rows render and | ||
| // the viewport ends up parked at the top. | ||
| (async () => { | ||
| await Promise.all([getChatContentLogs(), getChatStateLogs()]); | ||
| await tick(); | ||
| initScrollbars(); | ||
| scroll(); | ||
| pinToBottomWhileSettling(); | ||
| })(); | ||
|
|
||
| return () => { | ||
|
|
@@ -111,6 +111,43 @@ | |
| }); | ||
| } | ||
|
|
||
| /** | ||
| * Keep each log panel pinned to the very bottom while the initial layout | ||
| * settles. Async content can grow the row heights after first paint, so a | ||
| * fixed delay isn't enough — a ResizeObserver re-pins on every height change | ||
| * using instant `scrollTop` writes (no animation, no visible scroll). | ||
| * Pinning stops as soon as the user interacts with a panel, or after a | ||
| * safety timeout, so it never fights manual scrolling. | ||
| * @param {number} timeoutMs | ||
| */ | ||
| function pinToBottomWhileSettling(timeoutMs = 3000) { | ||
| scrollbars.forEach(scrollbar => { | ||
| if (!scrollbar) return; | ||
|
|
||
| const { viewport } = scrollbar.elements(); | ||
| const content = viewport.firstElementChild || viewport; | ||
| const pin = () => { viewport.scrollTop = viewport.scrollHeight; }; | ||
| pin(); | ||
|
|
||
| const observer = new ResizeObserver(pin); | ||
| observer.observe(content); | ||
|
|
||
| /** @type {ReturnType<typeof setTimeout>} */ | ||
| let timer; | ||
| const stop = () => { | ||
| observer.disconnect(); | ||
| clearTimeout(timer); | ||
| viewport.removeEventListener('wheel', stop); | ||
| viewport.removeEventListener('pointerdown', stop); | ||
| viewport.removeEventListener('keydown', stop); | ||
| }; | ||
| viewport.addEventListener('wheel', stop, { passive: true }); | ||
| viewport.addEventListener('pointerdown', stop); | ||
| viewport.addEventListener('keydown', stop); | ||
| timer = setTimeout(stop, timeoutMs); | ||
| }); | ||
|
Comment on lines
+123
to
+148
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 2. Persist-log leaks scroll resources In persist-log.svelte, pinToBottomWhileSettling() adds ResizeObserver/listeners per panel but the onMount cleanup only calls cleanLogs(), so these resources may remain active after unmount until the timeout fires. Additionally, initScrollbars() creates OverlayScrollbars instances but the component never destroys them on teardown. Agent Prompt
|
||
| } | ||
|
|
||
| function initScrollbars() { | ||
| scrollbarElements.forEach(item => { | ||
| const elem = document.querySelector(item.id); | ||
|
|
||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1. Pin observer lacks teardown
🐞 Bug☼ ReliabilityAgent Prompt
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools