fix(react-ui): restore sidebar collapse in dev + stop Talk page auto-scroll - #10383
Merged
Conversation
…scroll The sidebar collapse toggle silently no-op'd in dev builds. toggleCollapse ran its side effects (localStorage write + sidebar-collapse dispatch) inside the setCollapsed updater. StrictMode double-invokes updaters in dev to surface impurity, and the synchronous dispatch re-entered setState from the App/Sidebar listeners mid-update, so the toggle never committed. Production builds don't double-invoke, which is why only the dev server was affected. Compute next from current state and move the persist + broadcast into the handler body so the updater is pure. Also fix the Talk page anchoring to the transcript box on load. The transcript is its own overflow container, but scrollIntoView bubbles to every scrollable ancestor including the window, yanking the whole page down on mount. Scroll the transcript container directly instead. Signed-off-by: Ettore Di Giacinto <mudler@localai.io> Assisted-by: Claude:claude-opus-4-8 [Claude Code]
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
Two React UI regressions surfaced after the console-navigation redesign (#10377):
1. Sidebar won't collapse (dev builds only)
toggleCollapseperformed its side effects (localStorage write +sidebar-collapseevent dispatch) inside thesetCollapsedupdater:React StrictMode (on in dev, stripped in production) double-invokes state updaters to surface impurity. The synchronous dispatch re-entered
setStatefrom theApp/Sidebarsidebar-collapselisteners mid-update, so the toggle never committed and the button appeared dead. Production builds don't double-invoke, so only the vite dev server was affected.Fix: compute
nextfrom current state and move the persist + broadcast into the handler body, leaving a pure updater.2. Talk page anchored to the transcript box on load
Talk.jsxauto-scrolled viatranscriptEndRef.current.scrollIntoView(...). The transcript is already its own overflow container (maxHeight: 24rem; overflowY: auto), butscrollIntoViewbubbles to every scrollable ancestor including the window, yanking the whole page down to the box on mount. Fix: scroll the transcript container directly so the page stays at the top.Testing
Verified against a running vite dev server (reproduces both bugs) and a production build (collapse already worked there):
.sidebar.collapsedclass and.sidebar-is-collapsedlayout class apply; width 200px -> 52px.window.scrollY === 0on load (was scrolling down to the transcript box).eslintclean on both files (no new warnings).Assisted-by: Claude:claude-opus-4-8 [Claude Code]