Update assets/js/chat.js: scroll new bot responses to the start after rendering - #41
Open
kierknoby wants to merge 1 commit into
Open
Update assets/js/chat.js: scroll new bot responses to the start after rendering#41kierknoby wants to merge 1 commit into
kierknoby wants to merge 1 commit into
Conversation
…teraction cancelling pending automatic scrolling while preserving existing bottom-scroll behaviour for user messages.
mwtcmi
self-requested a review
August 6, 2026 20:03
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.
What this is
assets/js/chat.jsnow positions new bot responses at the start of the response rather than scrolling to the bottom of the completed message.For normal bot replies, the new message is scrolled into view after the browser has completed layout. For replies containing Mermaid diagrams, scrolling waits until the Mermaid nodes belonging to that response have either rendered successfully or failed cleanly.
User messages retain the existing bottom-scroll behaviour.
This is a single-file chat UI adjustment. There are no database or schema changes, and no changes to response generation or tool output.
Why
Long Frogman responses currently finish with the viewport positioned at the end of the reply. The user must then scroll back up to find the beginning.
This is most noticeable with output such as large CDR listings, firewall status and inbound-route lists, where the first thing shown is often the final lines rather than the heading and opening context.
The new behaviour places the beginning of the bot response at the top of the viewport instead of its final lines.
Behaviour
Bot replies:
block: 'start'User messages retain the existing bottom-scroll behaviour.
Only Mermaid nodes belonging to the newly appended bot response affect the wait counter. The existing Mermaid scan across the message list is unchanged.
Mermaid handling
Mermaid changes the height of a response asynchronously after the message has already been inserted into the DOM.
The implementation tracks Mermaid nodes belonging to the newly appended bot response and delays the final scroll until each tracked node has rendered successfully, rejected or thrown synchronously.
The final scroll runs after two
requestAnimationFrame()callbacks, withsetTimeout(fn, 0)as a fallback.User interaction
A pending bot-response scroll is cancelled when the message container captures a wheel, touch, mouse or keyboard interaction before the deferred scroll executes.
The listeners are removed when cancellation occurs or after the pending scroll completes.
Compatibility
No intentional behaviour changes are made outside chat scroll handling in
assets/js/chat.js.node --check assets/js/chat.jspasses.Test plan
Tested on an existing Frogman installation by switching between current upstream
mainand this branch, hard-refreshing the browser after each installation, and repeating the same chat commands.Install this branch
Revert to upstream
mainThe browser was force-refreshed after each switch.
Commands tested
Confirmed against upstream
mainthat long bot responses finish at the bottom of the output.Confirmed on this branch that:
The branch was then reverted to upstream
mainand reapplied to confirm that the behaviour follows this change rather than browser state or cached output.What's deliberately not in this PR
Files changed
assets/js/chat.js