mirror of
https://github.com/multica-ai/multica.git
synced 2026-07-13 05:16:29 +02:00
* fix(sidebar): stabilize useQuery default arrays to prevent render loop Inline `= []` defaults on `useQuery` return a new array reference on every render when `data` is undefined (query disabled or mid-load). Downstream effects/memos that depend on the value then fire every render; the pinned-items `useEffect` compounds this by calling `setLocalPinned` each time, so under sustained `data === undefined` (e.g. backend unreachable, WebSocket in reconnect loop) React trips its "Maximum update depth exceeded" guard and the sidebar becomes unusable. Use module-level empty-array constants so the default identity stays stable across renders. * fix(chat): short-circuit ResizeObserver update when bounds unchanged The resize observer always called `setRevision(r => r + 1)` from its callback, even when `clientWidth`/`clientHeight` were identical to the previous reading. Any spurious notification — sub-pixel layout jitter during mount, or an ancestor reflow triggered by an unrelated state update — then fed back into the same render cycle and could exceed React's update-depth limit. Guard the state bump by comparing against the previous bounds, and leave `setBoundsReady(true)` outside the guard since it's idempotent.