fix: improve review inline/body discipline and agent reliability
This commit is contained in:
+15
-4
@@ -236,6 +236,11 @@ function postProcessBody(
|
||||
if (validComments.length === 0) return body;
|
||||
|
||||
const commentedPaths = new Set(validComments.map((c) => c.path));
|
||||
// Also match short filenames (e.g. "data-settings.tsx") since the body often
|
||||
// uses basenames while inline comments store full repo-relative paths.
|
||||
const commentedBasenames = new Set(
|
||||
validComments.map((c) => c.path.split("/").pop() ?? c.path),
|
||||
);
|
||||
|
||||
const sectionRegex = /^### .+$/gm;
|
||||
const matches: Array<{ index: number; heading: string }> = [];
|
||||
@@ -254,13 +259,19 @@ function postProcessBody(
|
||||
const toRemove: Array<{ start: number; end: number }> = [];
|
||||
for (const section of sections) {
|
||||
const content = body.slice(section.start, section.end);
|
||||
let matched: string | undefined;
|
||||
for (const path of commentedPaths) {
|
||||
if (content.includes(path)) {
|
||||
toRemove.push({ start: section.start, end: section.end });
|
||||
log.info(`stripped duplicate body section "${section.heading.slice(0, 80)}" — already covered by inline comment on ${path}`);
|
||||
break;
|
||||
if (content.includes(path)) { matched = path; break; }
|
||||
}
|
||||
if (!matched) {
|
||||
for (const basename of commentedBasenames) {
|
||||
if (content.includes(basename)) { matched = basename; break; }
|
||||
}
|
||||
}
|
||||
if (matched) {
|
||||
toRemove.push({ start: section.start, end: section.end });
|
||||
log.info(`stripped duplicate body section "${section.heading.slice(0, 80)}" — already covered by inline comment on ${matched}`);
|
||||
}
|
||||
}
|
||||
|
||||
if (toRemove.length === 0) return body;
|
||||
|
||||
Reference in New Issue
Block a user