diff --git a/main.ts b/main.ts index 775e6de..d1a0c86 100644 --- a/main.ts +++ b/main.ts @@ -529,23 +529,17 @@ export async function main(): Promise { // post-agent review cleanup: reportReviewNodeId → follow-up re-review dispatch. // runs after the agent exits so ordering is architecturally guaranteed (no LLM involvement). // best-effort: cleanup failures must not turn a successful agent run into a failure. + // + // note: progress-comment deletion on review submission is owned by + // create_pull_request_review (action/mcp/review.ts) and runs atomically + // with the submission, so it survives any path out of main (success, + // timeout, crash) without relying on cleanup ordering here. if (toolContext) { await postReviewCleanup(toolContext).catch((error) => { log.debug(`post-review cleanup failed: ${error}`); }); } - // review submitted → always delete the progress comment. - // the review is the durable artifact; the progress comment is noise. - // defense-in-depth: covers the case where the agent calls report_progress - // despite mode instructions, which sets finalSummaryWritten and prevents - // the stranded-comment heuristic below from firing. - if (toolContext && toolState.review && toolState.progressCommentId) { - await deleteProgressComment(toolContext).catch((error) => { - log.debug(`review progress comment cleanup failed: ${error}`); - }); - } - // clean up stranded progress comments. two cases: // 1. wasUpdated=false: nothing wrote to the comment ("Leaping into action" orphan) // 2. tracker published a checklist but the agent never wrote a final summary diff --git a/mcp/review.ts b/mcp/review.ts index e89fabb..6eb56a5 100644 --- a/mcp/review.ts +++ b/mcp/review.ts @@ -11,6 +11,7 @@ import { } from "../utils/diffCoverage.ts"; import { fixDoubleEscapedString } from "../utils/fixDoubleEscapedString.ts"; import { patchWorkflowRunFields } from "../utils/patchWorkflowRunFields.ts"; +import { deleteProgressComment } from "./comment.ts"; import type { ToolContext } from "./server.ts"; import { execute, tool } from "./shared.ts"; @@ -464,6 +465,17 @@ export function CreatePullRequestReviewTool(ctx: ToolContext) { reviewedSha: actuallyReviewedSha, }; + // a submitted review obsoletes the progress comment — the review IS the + // durable artifact. owned here (not in main.ts) so cleanup is atomic with + // submission and survives any path out of the run (success, timeout, + // crash). deleteProgressComment sets progressCommentId = null, so a later + // report_progress call short-circuits to a no-op. + // best-effort: a cleanup failure must not turn a successful review into + // a tool-call failure visible to the agent. + await deleteProgressComment(ctx).catch((err) => { + log.debug(`progress comment cleanup after review failed: ${err}`); + }); + // detect commits pushed since checkout and guide the agent to review them // inline instead of dispatching a separate workflow run if (