From 69115f29eeffe898402b10abb4ebc77cf8dc5527 Mon Sep 17 00:00:00 2001 From: sshwy Date: Tue, 23 Jun 2026 14:20:49 +0800 Subject: [PATCH] fix(ui): line number click and hover utility not opening comment editor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - selection-bridge: allow single-line number column clicks to trigger onLineNumberSelectionEnd, not just multi-line drags - file.tsx: route number column clicks through selection flow instead of returning early, and add enableGutterUtility/renderGutterUtility to SharedProps matching pierre's native option names - session-review / file-tabs: rename enableHoverUtility → enableGutterUtility and renderHoverUtility → renderGutterUtility --- packages/app/src/pages/session/file-tabs.tsx | 4 ++-- packages/ui/src/components/file.tsx | 10 ++++------ packages/ui/src/components/session-review.tsx | 4 ++-- packages/ui/src/pierre/selection-bridge.ts | 6 +++--- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/packages/app/src/pages/session/file-tabs.tsx b/packages/app/src/pages/session/file-tabs.tsx index 364760eab0bc..102bbb605d10 100644 --- a/packages/app/src/pages/session/file-tabs.tsx +++ b/packages/app/src/pages/session/file-tabs.tsx @@ -405,7 +405,7 @@ export function FileTabContent(props: { tab: string }) { cacheKey: cacheKey(), }} enableLineSelection - enableHoverUtility + enableGutterUtility selectedLines={activeSelection()} commentedLines={commentedLines()} onRendered={() => { @@ -413,7 +413,7 @@ export function FileTabContent(props: { tab: string }) { }} annotations={commentsUi.annotations()} renderAnnotation={commentsUi.renderAnnotation} - renderHoverUtility={commentsUi.renderHoverUtility} + renderGutterUtility={commentsUi.renderHoverUtility} onLineSelected={(range: SelectedLineRange | null) => { commentsUi.onLineSelected(range) }} diff --git a/packages/ui/src/components/file.tsx b/packages/ui/src/components/file.tsx index 8c8096375a39..e86f525d7aa2 100644 --- a/packages/ui/src/components/file.tsx +++ b/packages/ui/src/components/file.tsx @@ -65,6 +65,8 @@ type SharedProps = { classList?: ComponentProps<"div">["classList"] media?: FileMediaOptions search?: FileSearchControl + enableGutterUtility?: boolean + renderGutterUtility?: (getHoveredRow: () => any) => HTMLElement | null | undefined } export type FileSearchHandle = { @@ -211,13 +213,9 @@ function useFileViewer(config: ViewerConfig) { if (event.button !== 0) return const hit = config.lineFromMouseEvent(event) - if (hit.numberColumn) { - bridge.begin(true, hit.line) - return - } if (hit.line === undefined) return - bridge.begin(false, hit.line) + bridge.begin(hit.numberColumn, hit.line) dragStart = hit.line dragEnd = hit.line dragMoved = false @@ -249,7 +247,7 @@ function useFileViewer(config: ViewerConfig) { const handleMouseUp = () => { if (!config.enableLineSelection()) return - if (bridge.finish() === "numbers") return + bridge.finish() if (dragStart === undefined) return if (!dragMoved) { diff --git a/packages/ui/src/components/session-review.tsx b/packages/ui/src/components/session-review.tsx index ebdd5d939caf..ec2932cf534f 100644 --- a/packages/ui/src/components/session-review.tsx +++ b/packages/ui/src/components/session-review.tsx @@ -620,13 +620,13 @@ export const SessionReview = (props: SessionReviewProps) => { props.onDiffRendered?.() }} enableLineSelection={props.onLineComment != null} - enableHoverUtility={props.onLineComment != null} + enableGutterUtility={props.onLineComment != null} onLineSelected={handleLineSelected} onLineSelectionEnd={handleLineSelectionEnd} onLineNumberSelectionEnd={commentsUi.onLineNumberSelectionEnd} annotations={commentsUi.annotations()} renderAnnotation={commentsUi.renderAnnotation} - renderHoverUtility={props.onLineComment ? commentsUi.renderHoverUtility : undefined} + renderGutterUtility={props.onLineComment ? commentsUi.renderHoverUtility : undefined} selectedLines={selectedLines()} commentedLines={commentedLines()} media={{ diff --git a/packages/ui/src/pierre/selection-bridge.ts b/packages/ui/src/pierre/selection-bridge.ts index 4055ec0874a3..b89e029817cf 100644 --- a/packages/ui/src/pierre/selection-bridge.ts +++ b/packages/ui/src/pierre/selection-bridge.ts @@ -115,12 +115,12 @@ export function createLineNumberSelectionBridge() { }, finish() { const current = mode - pending = current === "numbers" && moved + pending = current === "numbers" clear() return current }, - consume(range: SelectedLineRange | null) { - const result = pending && !isSingleLineSelection(range) + consume(_range: SelectedLineRange | null) { + const result = pending pending = false return result },