fix(mcp): preserve coveragePreflightRan across checkout_pr refreshes (#576)

checkout_pr unconditionally rebuilds ctx.toolState.diffCoverage via
createDiffCoverageState, which initialised coveragePreflightRan to false.
a second checkout_pr therefore reset the "one-time nudge per review
session" guarantee in runDiffCoveragePreflight, and the next
create_pull_request_review threw the diff-coverage pre-flight error
again — even after the agent had already gone through the
read-and-resubmit dance once.

createDiffCoverageState now accepts an optional previous state and
carries forward coveragePreflightRan. coveredRanges are intentionally
not carried because their line numbers are tied to the previous diff's
content (especially under incremental diffs).

closes #566

Co-authored-by: pullfrog[bot] <226033991+pullfrog[bot]@users.noreply.github.com>
Co-authored-by: David Blass <david@arktype.io>
This commit is contained in:
pullfrog[bot]
2026-05-06 20:54:34 +00:00
committed by pullfrog[bot]
parent 3c8b493aee
commit 6db4a6d02e
3 changed files with 24 additions and 1 deletions
+5 -1
View File
@@ -78,13 +78,17 @@ export function createDiffCoverageState(params: {
diffPath: string;
totalLines: number;
toc: string;
previous?: DiffCoverageState | undefined;
}): DiffCoverageState {
return {
diffPath: params.diffPath,
totalLines: params.totalLines,
tocEntries: parseDiffTocEntries({ toc: params.toc }),
coveredRanges: [],
coveragePreflightRan: false,
// carry forward across checkout_pr refreshes so the nudge stays "once per
// review session". coveredRanges are intentionally not carried because
// line numbers are tied to the previous diff's content.
coveragePreflightRan: params.previous?.coveragePreflightRan ?? false,
};
}