Skip to content

Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.

fix(web): scope timeline minimap hover target to the side gutter (#3869)

xxashxx-svg946b867666be
diff --git a/apps/web/src/components/chat/MessagesTimeline.logic.ts b/apps/web/src/components/chat/MessagesTimeline.logic.ts
index c6e277cce..3227bac24 100644
--- a/apps/web/src/components/chat/MessagesTimeline.logic.ts
+++ b/apps/web/src/components/chat/MessagesTimeline.logic.ts
@@ -64,6 +64,45 @@ export function resolveTimelineMinimapHasPersistentGutter(viewportWidth: number)
return sideGutter >= TIMELINE_MINIMAP_PERSISTENT_GUTTER;
}
+export const TIMELINE_MINIMAP_HIT_STRIP_LEFT = 12;
+export const TIMELINE_MINIMAP_HIT_STRIP_MAX_WIDTH = 40;
+export const TIMELINE_MINIMAP_EXPANDED_HIT_STRIP_WIDTH = "22rem";
+
+/**
+ * The minimap overlays the viewport's left edge while the content column is
+ * centered, so the side gutter between them shrinks under browser zoom or a
+ * narrow pane. A fixed-width hover strip would then sit on top of the message
+ * text and swallow its pointer events. Cap the strip's width so it never
+ * extends past the gutter into the content column; 0 disables the strip.
+ */
+export function resolveTimelineMinimapHitStripWidth(viewportWidth: number): number {
+ if (!Number.isFinite(viewportWidth) || viewportWidth <= 0) {
+ return 0;
+ }
+
+ const contentWidth = Math.min(viewportWidth, TIMELINE_CONTENT_MAX_WIDTH);
+ const sideGutter = Math.max(0, (viewportWidth - contentWidth) / 2);
+ return Math.max(
+ 0,
+ Math.min(
+ TIMELINE_MINIMAP_HIT_STRIP_MAX_WIDTH,
+ Math.floor(sideGutter) - TIMELINE_MINIMAP_HIT_STRIP_LEFT,
+ ),
+ );
+}
+
+/**
+ * Once the preview is open, keep the full preview and the space leading to it
+ * interactive. The collapsed strip remains gutter-capped so it cannot block
+ * selecting message text.
+ */
+export function resolveTimelineMinimapInteractiveWidth(
+ collapsedWidth: number,
+ expanded: boolean,
+): number | string {
+ return expanded ? TIMELINE_MINIMAP_EXPANDED_HIT_STRIP_WIDTH : collapsedWidth;
+}
+
function computeElapsedMs(startIso: string, endIso: string): number | null {
const start = Date.parse(startIso);
const end = Date.parse(endIso);
diff --git a/apps/web/src/components/chat/MessagesTimeline.test.tsx b/apps/web/src/components/chat/MessagesTimeline.test.tsx
index 0957e0253..a58724f33 100644
--- a/apps/web/src/components/chat/MessagesTimeline.test.tsx
+++ b/apps/web/src/components/chat/MessagesTimeline.test.tsx
@@ -224,7 +224,9 @@ describe("MessagesTimeline", () => {
resolveTimelineIsAtEnd,
resolveTimelineMinimapHasPersistentGutter,
resolveTimelineMinimapHeightStyle,
+ resolveTimelineMinimapHitStripWidth,
resolveTimelineMinimapIndexFromPointer,
+ resolveTimelineMinimapInteractiveWidth,
resolveTimelineMinimapTopPercent,
} = await import("./MessagesTimeline.logic");
@@ -254,6 +256,28 @@ describe("MessagesTimeline", () => {
expect(resolveTimelineMinimapHasPersistentGutter(832)).toBe(false);
expect(resolveTimelineMinimapHasPersistentGutter(863)).toBe(false);
expect(resolveTimelineMinimapHasPersistentGutter(864)).toBe(true);
+
+ // No usable gutter (zoomed in / narrow pane): the strip must go inert
+ // instead of overlaying the centered content column.
+ expect(resolveTimelineMinimapHitStripWidth(768)).toBe(0);
+ expect(resolveTimelineMinimapHitStripWidth(792)).toBe(0);
+ // Partial gutter: strip shrinks to what fits between the viewport edge
+ // and the content column.
+ expect(resolveTimelineMinimapHitStripWidth(820)).toBe(14);
+ // Full gutter: unchanged 40px-wide strip.
+ expect(resolveTimelineMinimapHitStripWidth(872)).toBe(40);
+ expect(resolveTimelineMinimapHitStripWidth(1400)).toBe(40);
+ expect(resolveTimelineMinimapHitStripWidth(0)).toBe(0);
+ expect(resolveTimelineMinimapHitStripWidth(Number.NaN)).toBe(0);
+
+ // The collapsed target stays narrow, but an open preview keeps its full
+ // 20rem width plus the 2rem offset from the minimap rail interactive.
+ expect(resolveTimelineMinimapInteractiveWidth(0, false)).toBe(0);
+ expect(resolveTimelineMinimapInteractiveWidth(14, false)).toBe(14);
+ expect(resolveTimelineMinimapInteractiveWidth(40, false)).toBe(40);
+ expect(resolveTimelineMinimapInteractiveWidth(0, true)).toBe("22rem");
+ expect(resolveTimelineMinimapInteractiveWidth(14, true)).toBe("22rem");
+ expect(resolveTimelineMinimapInteractiveWidth(40, true)).toBe("22rem");
});
it("anchors a sent attachment message using its measured height", async () => {
diff --git a/apps/web/src/components/chat/MessagesTimeline.tsx b/apps/web/src/components/chat/MessagesTimeline.tsx
index 46d6a4050..73fc86312 100644
--- a/apps/web/src/components/chat/MessagesTimeline.tsx
+++ b/apps/web/src/components/chat/MessagesTimeline.tsx
@@ -73,7 +73,9 @@ import {
resolveTimelineIsAtEnd,
resolveTimelineMinimapHasPersistentGutter,
resolveTimelineMinimapHeightStyle,
+ resolveTimelineMinimapHitStripWidth,
resolveTimelineMinimapIndexFromPointer,
+ resolveTimelineMinimapInteractiveWidth,
resolveTimelineMinimapTopPercent,
type StableMessagesTimelineRowsState,
type MessagesTimelineRow,
@@ -324,6 +326,7 @@ export const MessagesTimeline = memo(function MessagesTimeline({
null,
);
const [minimapHasPersistentGutter, setMinimapHasPersistentGutter] = useState(false);
+ const [minimapHitStripWidth, setMinimapHitStripWidth] = useState(0);
const handleAnchorReady = useCallback(
(info: { anchorIndex: number | undefined }) => {
if (anchorMessageId !== null && info.anchorIndex !== undefined) {
@@ -395,6 +398,7 @@ export const MessagesTimeline = memo(function MessagesTimeline({
setMinimapHasPersistentGutter((current) =>
current === nextHasPersistentGutter ? current : nextHasPersistentGutter,
);
+ setMinimapHitStripWidth(resolveTimelineMinimapHitStripWidth(viewportWidth));
};
const frame = requestAnimationFrame(measure);
@@ -511,6 +515,7 @@ export const MessagesTimeline = memo(function MessagesTimeline({
items={minimapItems}
bottomInset={contentInsetEndAdjustment}
hasPersistentGutter={minimapHasPersistentGutter}
+ hitStripWidth={minimapHitStripWidth}
stripMap={minimapStripMap}
onSelect={(item) => {
onManualNavigation();
@@ -605,15 +610,21 @@ function resolveTimelineRowHeight(state: TimelinePositionState, rowIndex: number
return typeof height === "number" && Number.isFinite(height) ? height : null;
}
+function timelineMinimapEventTargetsPreview(target: EventTarget): boolean {
+ return target instanceof Element && target.closest("[data-minimap-preview]") !== null;
+}
+
function TimelineMinimap({
bottomInset,
hasPersistentGutter,
+ hitStripWidth,
items,
stripMap,
onSelect,
}: {
bottomInset: number;
hasPersistentGutter: boolean;
+ hitStripWidth: number;
items: ReadonlyArray<TimelineMinimapItem>;
stripMap: Map<string, HTMLSpanElement>;
onSelect: (item: TimelineMinimapItem) => void;
@@ -676,7 +687,7 @@ function TimelineMinimap({
return (
<div
className={cn(
- "group/minimap pointer-events-auto absolute top-0 left-0 z-40 hidden w-18 [@media(pointer:fine)]:block",
+ "group/minimap pointer-events-none absolute top-0 left-0 z-40 hidden w-18 [@media(pointer:fine)]:block",
hasPersistentGutter
? "opacity-100"
: "opacity-0 transition-opacity duration-150 hover:opacity-100 focus-within:opacity-100",
@@ -688,9 +699,17 @@ function TimelineMinimap({
<div className="relative h-full w-full select-none">
<button
aria-label={`Jump to message: ${activeItem?.userText ?? "User message"}`}
- className="pointer-events-auto absolute top-1/2 left-3 w-10 -translate-y-1/2 cursor-pointer bg-transparent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70"
+ className={cn(
+ "absolute top-1/2 left-3 -translate-y-1/2 cursor-pointer bg-transparent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/70",
+ // The strip is width-capped to the side gutter so it never overlays
+ // the centered content column; with no usable gutter it goes inert.
+ hitStripWidth > 0 ? "pointer-events-auto" : "pointer-events-none",
+ )}
onBlur={() => setActiveIndex(null)}
onClick={(event) => {
+ if (timelineMinimapEventTargetsPreview(event.target)) {
+ return;
+ }
const nextIndex = resolveActiveIndexFromPointer(event);
const nextItem = nextIndex === null ? null : (items[nextIndex] ?? null);
if (nextItem) {
@@ -722,9 +741,15 @@ function TimelineMinimap({
onMouseLeave={() => setActiveIndex(null)}
onMouseMove={updateActiveIndexFromPointer}
onMouseDown={(event) => {
+ if (timelineMinimapEventTargetsPreview(event.target)) {
+ return;
+ }
event.preventDefault();
}}
- style={{ height: resolveTimelineMinimapHeightStyle(items.length) }}
+ style={{
+ height: resolveTimelineMinimapHeightStyle(items.length),
+ width: resolveTimelineMinimapInteractiveWidth(hitStripWidth, activeItem !== null),
+ }}
type="button"
>
<div className="absolute top-0 left-3 h-full w-px bg-border/15" />
@@ -761,27 +786,31 @@ function TimelineMinimap({
})}
{activeItem ? (
<span
- className="pointer-events-none absolute left-8 w-80 rounded-xl border border-border/70 bg-popover/95 p-3 text-left text-popover-foreground shadow-xl shadow-black/25 backdrop-blur"
+ className="pointer-events-auto absolute left-8 w-80 cursor-text select-text"
+ data-minimap-preview
+ onMouseMove={(event) => event.stopPropagation()}
style={{
top: `${activeTopPercent}%`,
transform: `translateY(${activeTooltipTranslate})`,
}}
>
- <span className="block max-w-full overflow-hidden text-ellipsis whitespace-nowrap text-sm font-medium leading-5">
- {activeItem.userText ?? "User message"}
- </span>
- {activeItem.assistantText ? (
- <span
- className="mt-1 max-h-[3.75rem] overflow-hidden text-muted-foreground text-sm leading-5"
- style={{
- display: "-webkit-box",
- WebkitBoxOrient: "vertical",
- WebkitLineClamp: 3,
- }}
- >
- {activeItem.assistantText}
+ <span className="block rounded-xl border border-border/70 bg-popover/95 p-3 text-left text-popover-foreground shadow-xl shadow-black/25 backdrop-blur">
+ <span className="block max-w-full overflow-hidden text-ellipsis whitespace-nowrap text-sm font-medium leading-5">
+ {activeItem.userText ?? "User message"}
</span>
- ) : null}
+ {activeItem.assistantText ? (
+ <span
+ className="mt-1 max-h-[3.75rem] overflow-hidden text-muted-foreground text-sm leading-5"
+ style={{
+ display: "-webkit-box",
+ WebkitBoxOrient: "vertical",
+ WebkitLineClamp: 3,
+ }}
+ >
+ {activeItem.assistantText}
+ </span>
+ ) : null}
+ </span>
</span>
) : null}
</button>