The best way to control Claude Code, Codex and more from any computer or phone
fix(web): text selection keeps going under the turn minimap (#16748)
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Robert Nisipeanu committed
Oct 15, 2026 at 20:26 UTC
52a769d43e467cc63bb6896e7cc43072f2ce0577
1 file changed
+47
-3
apps/web/src/components/chat/MessagesTimeline.tsx
+47
-3
@@ -1766,6 +1766,24 @@ function timelineMinimapEventTargetsPreview(target: EventTarget): boolean {
1766
return target instanceof Element && target.closest("[data-minimap-preview]") !== null;
1767
}
1768
1769
+// Calls `onRelease` once no mouse button is held. A release outside the window
1770
+// can skip `mouseup`, so the next button-free `mousemove` also counts. Returns a
1771
+// function that stops listening.
1772
+function onMouseButtonsReleased(onRelease: () => void): () => void {
1773
+ const check = (event: globalThis.MouseEvent) => {
1774
+ if (event.buttons !== 0) return;
1775
+ stop();
1776
+ onRelease();
1777
+ };
1778
+ const stop = () => {
1779
+ window.removeEventListener("mouseup", check);
1780
+ window.removeEventListener("mousemove", check);
1781
+ };
1782
+ window.addEventListener("mouseup", check);
1783
+ window.addEventListener("mousemove", check);
1784
+ return stop;
1785
+}
1786
+
1787
function TimelineMinimap({
1788
hasPersistentGutter,
1789
hitStripWidth,
@@ -1793,6 +1811,18 @@ function TimelineMinimap({
1811
[onWheel],
1812
);
1813
1814
+ // A held drag that started on the minimap (the strip or its turn buttons) is a
1815
+ // scrub; one that started anywhere else is a text selection. While a selection
1816
+ // crosses the minimap, the minimap lets the pointer through so the selection
1817
+ // keeps following the text underneath, until the button is released.
1818
+ const pressedOnStripRef = useRef(false);
1819
+ const [passThrough, setPassThrough] = useState(false);
1820
+
1821
+ useEffect(() => {
1822
+ if (!passThrough) return;
1823
+ return onMouseButtonsReleased(() => setPassThrough(false));
1824
+ }, [passThrough]);
1825
+
1826
const resolvedActiveIndex =
1827
activeIndex !== null && activeIndex < items.length ? activeIndex : null;
1828
const activeItem = useMemo(
@@ -1802,7 +1832,8 @@ function TimelineMinimap({
1832
),
1833
[items, resolvedActiveIndex],
1834
);
1805
- const navigationInteractive = resolveTimelineMinimapNavigationInteractive(hitStripWidth);
1835
+ const navigationInteractive =
1836
+ resolveTimelineMinimapNavigationInteractive(hitStripWidth) && !passThrough;
1837
const activeTopPercent =
1838
resolvedActiveIndex === null
1839
? 0
@@ -1874,8 +1905,18 @@ function TimelineMinimap({
1905
"absolute top-1/2 left-3 -translate-y-1/2",
1906
// The strip is width-capped to the side gutter so it never overlays
1907
// the centered content column; with no usable gutter it goes inert.
1877
- hitStripWidth > 0 ? "pointer-events-auto" : "pointer-events-none",
1908
+ hitStripWidth > 0 && !passThrough ? "pointer-events-auto" : "pointer-events-none",
1909
)}
1910
+ onMouseDown={() => {
1911
+ if (pressedOnStripRef.current) return;
1912
+ pressedOnStripRef.current = true;
1913
+ onMouseButtonsReleased(() => {
1914
+ pressedOnStripRef.current = false;
1915
+ });
1916
+ }}
1917
+ onMouseMove={(event) => {
1918
+ if (event.buttons !== 0 && !pressedOnStripRef.current) setPassThrough(true);
1919
+ }}
1920
style={{
1921
height: resolveTimelineMinimapHeightStyle(items.length),
1922
width: resolveTimelineMinimapInteractiveWidth(hitStripWidth, activeItem !== null),
@@ -1926,7 +1967,10 @@ function TimelineMinimap({
1967
}
1968
}}
1969
onMouseLeave={() => setActiveIndex(null)}
1929
- onMouseMove={updateActiveIndexFromPointer}
1970
+ onMouseMove={(event) => {
1971
+ if (event.buttons !== 0 && !pressedOnStripRef.current) return;
1972
+ updateActiveIndexFromPointer(event);
1973
+ }}
1974
onMouseDown={(event) => {
1975
if (timelineMinimapEventTargetsPreview(event.target)) {
1976
return;