The best way to control Claude Code, Codex and more from any computer or phone
fix(server): review guide stops no longer show the same lines twice (#23725)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: maria-rcks <maria@kuuro.net>
Victor Vogel committed
Oct 31, 2026 at 21:28 UTC
e5a2031a7398725e4aeaf4e7bf06045c5955d733
2 files changed
+60
-15
apps/server/src/pullRequest/pullRequestReviewGuideNormalize.test.ts
+42
@@ -152,6 +152,48 @@ describe("normalizeReviewGuide", () => {
152
expect(result.stops).toHaveLength(1);
153
});
154
155
+ it("merges excerpts that a later excerpt bridges into one", () => {
156
+ const result = normalizeReviewGuide(
157
+ guide({
158
+ stops: [
159
+ stop({
160
+ excerpts: [
161
+ excerpt("src/a.ts", 40, 41),
162
+ { ...excerpt("src/a.ts", 50, 51), caption: "Second" },
163
+ excerpt("src/a.ts", 41, 50),
164
+ ],
165
+ }),
166
+ ],
167
+ }),
168
+ change,
169
+ );
170
+ expect(result.stops[0]?.excerpts).toEqual([
171
+ { ...excerpt("src/a.ts", 40, 51), caption: "Second" },
172
+ ]);
173
+
174
+ const tailNote = { path: "src/a.ts", line: 40, title: "Tail", body: "Keep this note." };
175
+ const wide = normalizeReviewGuide(
176
+ guide({
177
+ stops: [
178
+ stop({
179
+ excerpts: [
180
+ excerpt("src/a.ts", 1, 25),
181
+ { ...excerpt("src/a.ts", 30, 45), caption: "Second" },
182
+ excerpt("src/a.ts", 24, 32),
183
+ ],
184
+ notes: [tailNote],
185
+ }),
186
+ ],
187
+ }),
188
+ parseReviewGuideChange(
189
+ "src/a.ts\0",
190
+ "diff --git a/src/a.ts b/src/a.ts\n--- a/src/a.ts\n+++ b/src/a.ts\n@@ -0,0 +1,60 @@\n+added",
191
+ ),
192
+ );
193
+ expect(wide.stops[0]?.excerpts).toEqual([{ ...excerpt("src/a.ts", 1, 25), caption: "Second" }]);
194
+ expect(wide.stops[0]?.notes).toEqual([]);
195
+ });
196
+
197
it("drops notes outside the stop's remaining excerpts", () => {
198
const result = normalizeReviewGuide(
199
guide({
apps/server/src/pullRequest/pullRequestReviewGuideNormalize.ts
+18
-15
@@ -87,26 +87,29 @@ function clampExcerpt(
87
function mergeExcerpts(
88
excerpts: ReadonlyArray<PullRequestReviewGuideExcerpt>,
89
): Array<PullRequestReviewGuideExcerpt> {
90
- const merged: Array<PullRequestReviewGuideExcerpt> = [];
90
+ let merged: Array<PullRequestReviewGuideExcerpt> = [];
91
for (const excerpt of excerpts) {
92
- const index = merged.findIndex(
93
- (other) =>
94
- other.path === excerpt.path &&
95
- other.side === excerpt.side &&
96
- other.start <= excerpt.end + 1 &&
97
- excerpt.start <= other.end + 1,
98
- );
99
- const other = merged[index];
100
- if (other === undefined) {
92
+ const touches = (other: PullRequestReviewGuideExcerpt) =>
93
+ other.path === excerpt.path &&
94
+ other.side === excerpt.side &&
95
+ other.start <= excerpt.end + 1 &&
96
+ excerpt.start <= other.end + 1;
97
+ // An excerpt can bridge several earlier ones; fold them all into the first.
98
+ const group = merged.filter(touches);
99
+ const first = group[0];
100
+ if (first === undefined) {
101
merged.push(excerpt);
102
continue;
103
}
104
- merged[index] = {
105
- ...other,
106
- start: Math.min(other.start, excerpt.start),
107
- end: Math.max(other.end, excerpt.end),
108
- caption: other.caption || excerpt.caption,
104
+ const combined = {
105
+ ...first,
106
+ start: Math.min(excerpt.start, ...group.map((other) => other.start)),
107
+ end: Math.max(excerpt.end, ...group.map((other) => other.end)),
108
+ caption: group.find((other) => other.caption)?.caption ?? excerpt.caption,
109
};
110
+ merged = merged.flatMap((other) =>
111
+ other === first ? [combined] : touches(other) ? [] : [other],
112
+ );
113
}
114
return merged.map((excerpt) => ({
115
...excerpt,