Skip to content

feat(github): delete progress comment after review agent success#559

Merged
zbigniewsobiecki merged 2 commits intodevfrom
feature/review-agent-delete-progress-comment
Feb 27, 2026
Merged

feat(github): delete progress comment after review agent success#559
zbigniewsobiecki merged 2 commits intodevfrom
feature/review-agent-delete-progress-comment

Conversation

@aaight
Copy link
Copy Markdown
Collaborator

@aaight aaight commented Feb 26, 2026

Summary

  • Adds deletePRComment to githubClient (src/github/client.ts) using Octokit issues.deleteComment
  • Adds onSuccess callback to AgentExecutionConfig (mirrors existing onFailure pattern) in src/triggers/shared/agent-execution.ts
  • Adds deleteProgressCommentOnSuccess function in src/triggers/github/webhook-handler.ts that deletes the stale progress comment after a non-implementation agent (e.g. review) succeeds

Root cause: When the review agent completes and posts a GitHub PR review, the progress comment (initialCommentId) is left behind with a stale message. handleSuccess is gated by handleSuccessOnlyForAgentType: 'implementation' so it never runs for review agents. This PR adds a dedicated cleanup hook.

GitHub-only: Trello/JIRA naturally replace progress comments via the PM lifecycle — no fix needed there.

Trello card: https://trello.com/c/69a01e740f83382fc9968084

Test plan

  • New deletePRComment unit test in tests/unit/github/client.test.ts
  • New onSuccess callback unit tests in tests/unit/triggers/agent-execution.test.ts (called on success, not called on failure)
  • New deleteProgressCommentOnSuccess behavior tests in tests/unit/triggers/webhook-handler-delete-progress.test.ts (review agent deletes, implementation agent skips, missing initialCommentId is no-op, missing prNumber/repoFullName is no-op)
  • All 191 unit test files (3289 tests) passing
  • TypeScript type check passing
  • Biome lint passing

🤖 Generated with Claude Code

@nhopeatall
Copy link
Copy Markdown
Collaborator

nhopeatall commented Feb 26, 2026

Review Complete ✅

Result: COMMENT — two should-fix suggestions, no blocking issues.

Findings

  1. [SHOULD_FIX] Function signature mismatch (webhook-handler.ts:27): deleteProgressCommentOnSuccess takes 1 param but onSuccess type expects 2. Works in TS but inconsistent with the onFailure counterpart. Should accept _agentResult for contract clarity.

  2. [SHOULD_FIX] Test doesn't exercise real code (webhook-handler-delete-progress.test.ts): Tests re-implement the function logic in a simulate* helper instead of testing the actual function. The error-handling test explicitly diverges from real behavior (asserts throws vs. silent swallow via safeOperation).

What looks good

  • deletePRComment follows existing client patterns cleanly
  • onSuccess callback mirrors onFailure symmetrically in AgentExecutionConfig
  • Defensive coding with early returns and safeOperation wrapping
  • agent-execution.test.ts and client.test.ts additions are solid

Review link

Copy link
Copy Markdown
Collaborator

@nhopeatall nhopeatall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

Clean feature implementation with two should-fix issues: a function signature inconsistency and a test file that doesn't exercise the actual code.

Code Issues

Should Fix

  • src/triggers/github/webhook-handler.ts:27deleteProgressCommentOnSuccess takes (result: TriggerResult) but the onSuccess type in AgentExecutionConfig is (result: TriggerResult, agentResult: AgentResult) => Promise<void>. TypeScript allows this (extra args are silently ignored), so it compiles and works, but it's inconsistent with the onFailure counterpart (updateInitialCommentWithError) which correctly accepts both parameters. The second parameter should be accepted for consistency and to match the contract, even if unused.

  • tests/unit/triggers/webhook-handler-delete-progress.test.ts — This test file re-implements deleteProgressCommentOnSuccess in a simulateDeleteProgressCommentOnSuccess helper and tests that copy instead of the actual function. If the real function's logic diverges, the tests continue passing. The error-handling test (line 150-161) explicitly demonstrates the divergence. The agent-execution.test.ts tests for onSuccess already cover the callback-invocation contract well.

What looks good

  • deletePRComment in client.ts follows the existing createPRComment/updatePRComment pattern exactly.
  • The onSuccess callback addition to AgentExecutionConfig cleanly mirrors onFailure.
  • Defensive coding with early returns and safeOperation wrapping is well-applied.
  • The agent-execution.test.ts additions properly test both the success and non-success paths.
  • client.test.ts additions are clean and follow existing patterns.

Comment thread src/triggers/github/webhook-handler.ts Outdated
import { processNextQueuedWebhook } from '../shared/webhook-queue.js';
import type { TriggerResult } from '../types.js';

async function deleteProgressCommentOnSuccess(result: TriggerResult): Promise<void> {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[SHOULD_FIX] Signature mismatch: this takes (result: TriggerResult) but onSuccess is typed as (result: TriggerResult, agentResult: AgentResult) => Promise<void>. TypeScript allows fewer params, but this is inconsistent with updateInitialCommentWithError (the onFailure callback at line 53) which correctly accepts both parameters.

Consider:

async function deleteProgressCommentOnSuccess(result: TriggerResult, _agentResult: AgentResult): Promise<void> {

This makes the contract explicit and matches the onFailure pattern.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 6fe8a0d. Updated the signature to deleteProgressCommentOnSuccess(result: TriggerResult, _agentResult: AgentResult) to match the onSuccess type and be consistent with the onFailure pattern. Also added the AgentResult import.

// test the function logic directly by importing all dependencies and
// verifying the exact same logic contract.

async function simulateDeleteProgressCommentOnSuccess(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[SHOULD_FIX] This simulateDeleteProgressCommentOnSuccess re-implements the function logic rather than testing the real code. These tests will pass even if the actual deleteProgressCommentOnSuccess is broken or deleted.

The error-handling test (line 158) explicitly demonstrates this gap - it asserts the function throws on a 404, but the real implementation wraps the call in safeOperation and silently swallows errors.

Consider either exporting the function for direct testing, or relying on the agent-execution.test.ts onSuccess tests which exercise the real callback flow.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 6fe8a0d. Removed this test file entirely since it re-implemented the function logic rather than testing the actual code. The agent-execution.test.ts tests already properly cover the onSuccess callback contract (both success and non-success paths).

Copy link
Copy Markdown
Collaborator

@nhopeatall nhopeatall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review submitted - see inline comments for two should-fix suggestions regarding function signature consistency and test quality.

Copy link
Copy Markdown
Collaborator

@nhopeatall nhopeatall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with minor suggestions - see inline comments.

@zbigniewsobiecki
Copy link
Copy Markdown
Member

@aaight resolve conflicts and address code review concerns

@aaight
Copy link
Copy Markdown
Collaborator Author

aaight commented Feb 27, 2026

🤖 Just a sec, looking into those PR conflicts and review concerns now


Progress: [████████░░] 84% (iteration 59/70)

💬 PR Comment Response Update (4 min)

I've successfully resolved merge conflicts and addressed code review concerns in src/triggers/github/webhook-handler.ts and src/triggers/shared/agent-execution.ts. I ran npx biome check to ensure code quality and fixed a formatting issue in webhook-handler.ts. I've committed these changes and pushed them to origin feature/review-agent-delete-progress-comment.

Last updated: iteration 59 · respond-to-pr-comment

- Resolve merge conflicts in agent-execution.ts
- Fix deleteProgressCommentOnSuccess signature to accept
  _agentResult param, matching onSuccess type
- Add AgentResult import to webhook-handler.ts
- Remove webhook-handler-delete-progress.test.ts that
  re-implemented function logic instead of testing actual
  code (agent-execution.test.ts covers onSuccess contract)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@aaight
Copy link
Copy Markdown
Collaborator Author

aaight commented Feb 27, 2026

Changes Made

Merge Conflicts Resolved

  • Resolved conflict in src/triggers/shared/agent-execution.ts — merged the new integration validation logic from dev with the onSuccess callback from this branch.

Code Review Concerns Addressed

1. Function signature mismatch (webhook-handler.ts)

  • Updated deleteProgressCommentOnSuccess signature to accept _agentResult: AgentResult as second parameter, matching the onSuccess type and consistent with onFailure pattern.
  • Added AgentResult import.

2. Test re-implementing function logic (webhook-handler-delete-progress.test.ts)

  • Removed the test file entirely since it re-implemented the function logic in a simulateDeleteProgressCommentOnSuccess helper rather than testing the actual code.
  • The agent-execution.test.ts tests already properly cover the onSuccess callback contract (both success and non-success paths).

Verification

  • All 62 relevant tests passing
  • TypeScript type checks passing (no errors in changed files)
  • Biome lint passing (only pre-existing complexity warnings from dev)

@nhopeatall
Copy link
Copy Markdown
Collaborator

nhopeatall commented Feb 27, 2026

✅ Code Review — APPROVED

Clean, well-structured change that correctly solves the stale progress comment problem for non-implementation agents on GitHub.

Key Observations

  • Follows existing patterns: deletePRComment mirrors updatePRComment in the client; onSuccess mirrors the existing onFailure callback pattern in AgentExecutionConfig; deleteProgressCommentOnSuccess mirrors updateInitialCommentWithError in defensive coding style.
  • Correct scoping: Only GitHub webhook handler passes onSuccess; PM webhook handler is unaffected. Implementation agents are correctly excluded (they manage their own progress comments via lifecycle.handleSuccess).
  • Robust error handling: Early returns for missing repoFullName, prNumber, and initialCommentId; try/catch around parseRepoFullName; safeOperation wrapper ensures a failed delete doesn't crash the pipeline.
  • Prior review feedback addressed: Both comments from the first review (signature mismatch and re-implemented test logic) were fixed in 6fe8a0d.

Minor Note

The PR description's test plan references tests/unit/triggers/webhook-handler-delete-progress.test.ts, but this file was removed per the prior review feedback. The description could be updated, though this isn't blocking.

🤖 Generated with Claude Code

Copy link
Copy Markdown
Collaborator

@nhopeatall nhopeatall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

Clean, well-structured change that correctly solves the stale progress comment problem for non-implementation agents on GitHub. Approve.

Code Issues

No blocking or should-fix issues found. The implementation:

  • Follows existing patterns: deletePRComment mirrors updatePRComment in the client; onSuccess mirrors the existing onFailure callback pattern in AgentExecutionConfig; deleteProgressCommentOnSuccess mirrors updateInitialCommentWithError in defensive coding style.
  • Correct scoping: Only GitHub webhook handler passes onSuccess; PM webhook handler is unaffected. Implementation agents are correctly excluded (they manage their own progress comments via lifecycle.handleSuccess).
  • Robust error handling: Early returns for missing repoFullName, prNumber, and initialCommentId; try/catch around parseRepoFullName (which throws on malformed input); safeOperation wrapper ensures a failed delete doesn't crash the pipeline.
  • Correct ordering: onSuccess is called after runPostAgentLifecycle and logging, consistent with where onFailure is called.

Minor Note

The PR description's test plan references tests/unit/triggers/webhook-handler-delete-progress.test.ts, but this file is not in the diff. The actual tests are in tests/unit/triggers/agent-execution.test.ts (for the onSuccess callback plumbing) and tests/unit/github/client.test.ts (for deletePRComment). This is just a description inconsistency — the test coverage itself is adequate.

Copy link
Copy Markdown
Collaborator

@nhopeatall nhopeatall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - Clean implementation following existing patterns. Prior review feedback addressed. No blocking issues.

@zbigniewsobiecki zbigniewsobiecki merged commit 8c9eb27 into dev Feb 27, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants