Repository navigation
fix(web): mouse wheel over the thread minimap scrolls like the chat on macOS #38503
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
178ccb6
8445aaa
82fea36
e7ca57c
0666fa8
d9b9646
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -104,7 +104,6 @@ import { type TimestampFormat } from "@t3tools/contracts/settings"; | |
| import { type HandoffTimelineRun } from "./V2LifecycleRow"; | ||
| import { TimelineSystemDivider } from "./TimelineSystemDivider"; | ||
|
|
||
| import { forwardWheelToTimeline } from "./timelineMinimapWheel"; | ||
| import { TimelineMinimap } from "./TimelineMinimap"; | ||
| import { | ||
| type TimelineRowSharedState, | ||
|
|
@@ -837,6 +836,7 @@ const ConversationTimeline = memo(function ConversationTimeline({ | |
| const [timelineViewportElement, setTimelineViewportElement] = useState<HTMLDivElement | null>( | ||
| null, | ||
| ); | ||
| const [timelineScrollNode, setTimelineScrollNode] = useState<HTMLElement | null>(null); | ||
| const { | ||
| target: readyCitationRequest, | ||
| positioning: citationPositioning, | ||
|
|
@@ -1060,7 +1060,11 @@ const ConversationTimeline = memo(function ConversationTimeline({ | |
| setMinimapHasPersistentGutter((current) => | ||
| current === nextHasPersistentGutter ? current : nextHasPersistentGutter, | ||
| ); | ||
| setMinimapHitStripWidth(resolveTimelineMinimapHitStripWidth(viewportWidth, contentWidth)); | ||
| const scrollNode = listRef.current?.getScrollableNode(); | ||
| const scrollbarGutter = scrollNode ? (scrollNode.offsetWidth - scrollNode.clientWidth) / 2 : 0; | ||
| setMinimapHitStripWidth( | ||
| resolveTimelineMinimapHitStripWidth(viewportWidth, contentWidth, scrollbarGutter), | ||
|
Comment on lines
+1063
to
+1066
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Re-measure the minimap hit strip when the scrollbar gutter changes.
Trigger the same measurement when the scroll node's size changes, for example by observing the list's scroll node with
|
||
| ); | ||
| }; | ||
| // Rows added, removed or rewrapped (chat width) change the content size, | ||
| // which moves the scroll position, the overflow, and the content lane width. | ||
|
|
@@ -1257,6 +1261,7 @@ const ConversationTimeline = memo(function ConversationTimeline({ | |
| listRef.current = list; | ||
| const scrollNode: HTMLElement | null = list?.getScrollableNode() ?? null; | ||
| registerTimeline?.(scrollNode); | ||
| setTimelineScrollNode(scrollNode); | ||
| const viewport = scrollNode | ||
| ? attachTimelineViewport(scrollNode, (frame) => { | ||
| const rowId = frame.closest<HTMLElement>("[data-timeline-row-id]")?.dataset.timelineRowId; | ||
|
|
@@ -1311,6 +1316,7 @@ const ConversationTimeline = memo(function ConversationTimeline({ | |
| } | ||
| listRef.current = null; | ||
| registerTimeline?.(null); | ||
| setTimelineScrollNode(null); | ||
| }; | ||
| }); | ||
|
|
||
|
|
@@ -1408,11 +1414,6 @@ const ConversationTimeline = memo(function ConversationTimeline({ | |
| </TimelineListFooter> | ||
| ); | ||
|
|
||
| const forwardMinimapWheel = (event: WheelEvent) => { | ||
| const scrollNode = listRef.current?.getScrollableNode(); | ||
| if (scrollNode) forwardWheelToTimeline(event, scrollNode); | ||
| }; | ||
|
|
||
| if (showsEmptyState) { | ||
| if (hideEmptyPlaceholder) { | ||
| return ( | ||
|
|
@@ -1444,7 +1445,7 @@ const ConversationTimeline = memo(function ConversationTimeline({ | |
| <TimelineRowActivityCtx value={activityState}> | ||
| <TooltipScrollDismissArea | ||
| ref={attachTimelineViewportElement} | ||
| className="relative h-full min-h-0" | ||
| className="relative h-full min-h-0 @container-size" | ||
| data-assistant-citation-viewport="true" | ||
| > | ||
| {onCiteAssistantText && citationThreadRef ? ( | ||
|
|
@@ -1503,23 +1504,25 @@ const ConversationTimeline = memo(function ConversationTimeline({ | |
| ListHeaderComponent={listHeader} | ||
| ListFooterComponent={timelineListFooter} | ||
| /> | ||
| <TimelineMinimap | ||
| items={minimapItems} | ||
| hasPersistentGutter={minimapHasPersistentGutter} | ||
| hitStripWidth={minimapHitStripWidth} | ||
| currentIndex={minimapCurrentIndex} | ||
| atEnd={minimapAtEnd} | ||
| stripMap={minimapStripMap} | ||
| onWheel={forwardMinimapWheel} | ||
| onSelect={(item) => { | ||
| navigateTimeline(); | ||
| void listRef.current?.scrollToIndex({ | ||
| index: item.rowIndex, | ||
| animated: !window.matchMedia("(prefers-reduced-motion: reduce)").matches, | ||
| viewOffset: TIMELINE_MINIMAP_TARGET_OFFSET, | ||
| }); | ||
| }} | ||
| /> | ||
| {timelineScrollNode ? ( | ||
| <TimelineMinimap | ||
| scrollNode={timelineScrollNode} | ||
| items={minimapItems} | ||
| hasPersistentGutter={minimapHasPersistentGutter} | ||
| hitStripWidth={minimapHitStripWidth} | ||
| currentIndex={minimapCurrentIndex} | ||
| atEnd={minimapAtEnd} | ||
| stripMap={minimapStripMap} | ||
| onSelect={(item) => { | ||
| navigateTimeline(); | ||
| void listRef.current?.scrollToIndex({ | ||
| index: item.rowIndex, | ||
| animated: !window.matchMedia("(prefers-reduced-motion: reduce)").matches, | ||
| viewOffset: TIMELINE_MINIMAP_TARGET_OFFSET, | ||
| }); | ||
| }} | ||
| /> | ||
| ) : null} | ||
| </TooltipScrollDismissArea> | ||
| </TimelineRowActivityCtx> | ||
| </MarkdownFindContext> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep the minimap usable below the height cap.
At a 96px timeline height with a 16px root font, the new cap collapses the rail to zero height. With two turns, both marks occupy the same position, so pointer users cannot pick between them. The old cap gave those turns an 8px rail.
Keep a usable rail where it fits. If there is not enough room for both the rail and the turn buttons, use a compact layout rather than collapsing the rail. Keep the rail inside the scroll node so wheel input stays native.