Skip to content

Commit b017b29

Browse files
authored
fix(review): gutter hover button not rendering + update @pierre/diffs to 1.1.20 (#630)
The renderHoverUtility callback was gating on getHoveredLine() during React render, but Pierre updates hover state imperatively — so the button was permanently null. Always render the button; call getHoveredLine() only in the click handler. Also aligned button sizing/colors with Pierre's own [data-utility-button] spec. For provenance purposes, this commit was AI assisted.
1 parent a68463b commit b017b29

4 files changed

Lines changed: 29 additions & 22 deletions

File tree

bun.lock

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"@anthropic-ai/claude-agent-sdk": "^0.2.92",
3737
"@openai/codex-sdk": "^0.118.0",
3838
"@opencode-ai/sdk": "^1.3.0",
39-
"@pierre/diffs": "^1.1.12",
39+
"@pierre/diffs": "^1.1.20",
4040
"diff": "^8.0.4",
4141
"dockview-react": "^5.2.0",
4242
"dompurify": "^3.3.3",

packages/review-editor/components/DiffViewer.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -497,16 +497,19 @@ export const DiffViewer: React.FC<DiffViewerProps> = ({
497497
);
498498
}, [filePath, onSelectAnnotation, handleEdit, onDeleteAnnotation, onClickAIMarker]);
499499

500-
// Render hover utility (+ button)
500+
// Render hover utility (+ button).
501+
// Pierre manages visibility imperatively — it inserts/removes the slot
502+
// container on line hover. We must always return a button; calling
503+
// getHoveredLine() to gate rendering would return stale data because
504+
// Pierre's hover state changes don't trigger React re-renders.
501505
const renderHoverUtility = useCallback((getHoveredLine: () => { lineNumber: number; side: 'deletions' | 'additions' } | undefined) => {
502-
const line = getHoveredLine();
503-
if (!line) return null;
504-
505506
return (
506507
<button
507508
className="hover-add-comment"
508509
onClick={(e) => {
509510
e.stopPropagation();
511+
const line = getHoveredLine();
512+
if (!line) return;
510513
toolbar.handleLineSelectionEnd({
511514
start: line.lineNumber,
512515
end: line.lineNumber,

packages/review-editor/index.css

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -241,26 +241,30 @@ diffs-container {
241241
background: oklch(from var(--primary) l c h / 0.3) !important;
242242
}
243243
244-
/* Hover utility button (GitHub-style +) */
244+
/* Hover utility button — matches Pierre's [data-utility-button] sizing */
245245
.hover-add-comment {
246+
appearance: none;
246247
display: flex;
247248
align-items: center;
248249
justify-content: center;
249-
width: 1.25rem;
250-
height: 1.25rem;
251-
border-radius: 0.25rem;
252-
background: var(--primary);
253-
color: var(--primary-foreground);
254-
font-size: 0.75rem;
255-
font-weight: 600;
250+
width: 1lh;
251+
height: 1lh;
252+
font-size: var(--diffs-font-size, 13px);
253+
line-height: var(--diffs-line-height, 20px);
254+
border: none;
255+
border-radius: 4px;
256+
background-color: var(--diffs-modified-base);
257+
color: var(--diffs-bg);
258+
fill: currentColor;
256259
cursor: pointer;
257-
opacity: 0;
258-
transition: opacity 150ms;
260+
position: relative;
261+
z-index: 4;
262+
padding: 0;
263+
margin-right: calc(1ch - 1lh);
259264
}
260265
261266
.hover-add-comment:hover {
262-
opacity: 1;
263-
background: oklch(0.70 0.20 280);
267+
filter: brightness(1.2);
264268
}
265269
266270
/* File tree styling */

0 commit comments

Comments
 (0)