Skip to content

fix(react-ui): restore sidebar collapse in dev + stop Talk page auto-scroll - #10383

Merged
mudler merged 1 commit into
masterfrom
fix/sidebar-collapse-talk-scroll
Jun 17, 2026
Merged

fix(react-ui): restore sidebar collapse in dev + stop Talk page auto-scroll#10383
mudler merged 1 commit into
masterfrom
fix/sidebar-collapse-talk-scroll

Conversation

@localai-bot

Copy link
Copy Markdown
Collaborator

What

Two React UI regressions surfaced after the console-navigation redesign (#10377):

1. Sidebar won't collapse (dev builds only)

toggleCollapse performed its side effects (localStorage write + sidebar-collapse event dispatch) inside the setCollapsed updater:

setCollapsed(prev => {
  const next = !prev
  localStorage.setItem(...)                   // side effect
  window.dispatchEvent(new CustomEvent(...))  // side effect, fires synchronously
  return next
})

React StrictMode (on in dev, stripped in production) double-invokes state updaters to surface impurity. The synchronous dispatch re-entered setState from the App/Sidebar sidebar-collapse listeners 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 next from 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.jsx auto-scrolled via transcriptEndRef.current.scrollIntoView(...). The transcript is already its own overflow container (maxHeight: 24rem; overflowY: auto), but scrollIntoView bubbles 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):

  • Collapse: toggle / expand / re-collapse round-trip + persistence across reload all work; .sidebar.collapsed class and .sidebar-is-collapsed layout class apply; width 200px -> 52px.
  • Talk: window.scrollY === 0 on load (was scrolling down to the transcript box).
  • eslint clean on both files (no new warnings).

Assisted-by: Claude:claude-opus-4-8 [Claude Code]

…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]
@mudler
mudler merged commit 88726f2 into master Jun 17, 2026
58 of 59 checks passed
@mudler
mudler deleted the fix/sidebar-collapse-talk-scroll branch June 17, 2026 22:48
@localai-bot localai-bot added the bug Something isn't working label Jun 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants