Skip to content

Commit 8baa39d

Browse files
authored
Defer empty diff guard until after hook setup (#400)
- Keep hook execution order stable in `InlineDiffBlock` - Return early only after derived state and effects are initialized
1 parent d396d36 commit 8baa39d

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

apps/web/src/components/chat/InlineDiffBlock.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,6 @@ export const InlineDiffBlock = memo(function InlineDiffBlock(props: {
267267
});
268268
}, [allLines]);
269269

270-
if (allLines.length === 0) return null;
271-
272270
const needsTruncation = allLines.length > MAX_VISIBLE_LINES;
273271
const visibleLines =
274272
needsTruncation && !isExpanded ? keyedLines.slice(0, MAX_VISIBLE_LINES) : keyedLines;
@@ -328,6 +326,10 @@ export const InlineDiffBlock = memo(function InlineDiffBlock(props: {
328326
}
329327
}, [highlightedLines, languageId, diffThemeName]);
330328

329+
if (allLines.length === 0) {
330+
return null;
331+
}
332+
331333
return (
332334
<div className="overflow-hidden rounded-xl border border-border/70">
333335
{/* File header */}

0 commit comments

Comments
 (0)