Matt Toohey a28d5a4b9f fix: sidebar highlight pill follows active session after list re-sort (#121)
* fix: sidebar highlight pill follows active session after list re-sort

When the session list re-sorts (e.g. because updateSession bumps
updatedAt), the active SidebarChatRow moves to a new DOM position but
the highlight pill stays at its old pixel offset. This happens because
the SidebarChatRow effect that re-measures position depends on
[activeRef, isActive] — neither of which changes on a re-sort.

Fix: compute a listOrderKey (joined session IDs) that changes whenever
the list order changes, and include it in the activeSessionRefCallback
and activeProjectRefCallback dependency arrays. This makes the callback
a new reference on re-sort, which triggers SidebarChatRow's existing
effect to re-fire and re-measure the highlight position.

* fix: use MutationObserver for layout-driven highlight remeasurement

Replace the listOrderKey workaround with a MutationObserver in
useSidebarHighlight that watches for any DOM subtree changes in the
nav container. This handles all cases where the active row's pixel
position changes: list re-sorts, project expand/collapse, filtering,
and show-more toggles.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: debounce MutationObserver callback with requestAnimationFrame

Wrap the MutationObserver callback in rAF to measure after the browser
has completed layout, avoiding stale geometry from pre-layout reads.
The trailing rAF also coalesces rapid-fire mutations into a single
measurement, preventing redundant intermediate renders.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-08 17:25:35 +10:00
S
Description
No description provided
Apache-2.0 1.5 GiB
Languages
Rust 63.6%
TypeScript 29.6%
JavaScript 1.7%
Shell 1.6%
Python 1.5%
Other 1.8%