Skip to content

Commit 519684d

Browse files
committed
fix: block change lines may be undefined
1 parent 4f0501b commit 519684d

1 file changed

Lines changed: 11 additions & 12 deletions

File tree

packages/ai-native/src/browser/chat/chat.view.tsx

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -76,18 +76,17 @@ const MAX_TITLE_LENGTH = 100;
7676
const getFileChanges = (codeBlocks: CodeBlockData[]) =>
7777
codeBlocks
7878
.map((block) => {
79-
const rangesFromDiffHunk =
80-
block.applyResult?.diff.split('\n').reduce(
81-
([del, add], line) => {
82-
if (line.startsWith('-')) {
83-
del += 1;
84-
} else if (line.startsWith('+')) {
85-
add += 1;
86-
}
87-
return [del, add];
88-
},
89-
[0, 0],
90-
) || [];
79+
const rangesFromDiffHunk = block.applyResult?.diff.split('\n').reduce(
80+
([del, add], line) => {
81+
if (line.startsWith('-')) {
82+
del += 1;
83+
} else if (line.startsWith('+')) {
84+
add += 1;
85+
}
86+
return [del, add];
87+
},
88+
[0, 0],
89+
) || [0, 0];
9190
return {
9291
path: block.relativePath,
9392
additions: rangesFromDiffHunk[1],

0 commit comments

Comments
 (0)