Skip to content

Refactor: Clean up 'starting work' comments after PR follow-up processing #222

Closed

Description

@integry

Currently, the 'processPullRequestCommentJob' posts a comment to indicate it is "Starting work on follow-up changes". This comment includes check-marked IDs (e.g., '3497728780✓') which act as a guard to prevent reprocessing the same follow-up comment.

When the job completes (either by pushing new changes or by determining no changes are needed), it posts a second comment ("Applied the requested follow-up changes" or "Analyzed the follow-up request").

This leaves two bot comments. The initial "Starting work" comment is now redundant.

Task:

  1. Modify 'src/jobs/processPullRequestCommentJob.js'.
  2. The completion comments (both for success-with-changes and success-with-no-changes) must be updated to include the reprocessing guard. The footer of these comments should include the string:
    '---
    Processing comment ID[s]: {comment_id}✓, {comment_id}✓...'
    This ensures the reprocessing guard is transferred to the final comment.
  3. After the completion comment is successfully posted (in both success scenarios), add logic to delete the initial 'startingWorkComment'.
  4. Introduce a short delay (e.g., 3 seconds) before deleting the 'startingWorkComment'. This ensures a brief overlap where both comments exist, guaranteeing the reprocessing guard is always present.

Implementation Steps:

  1. In 'src/jobs/processPullRequestCommentJob.js', locate the 'if (commitResult)' block.

  2. Find where 'prCommentBody' is constructed. Append the reprocessing guard footer to it before it's posted. The footer should look like:
    '\n\n---\n_Processing comment ID${unprocessedComments.length > 1 ? 's' : ''}: ${unprocessedComments.map(c => String(c.id) + '✓').join(', ')}_'

  3. Locate the 'else' block (for no commitResult).

  4. Find where 'noChangesBody' is constructed. Append the same reprocessing guard footer to it before it's posted.

  5. After the 'completionComment = await octokit.request(...)' call in both the 'if' and 'else' blocks, add the logic to delete the 'startingWorkComment' (which was stored when the job started).

    // Add this logic after the completionComment is posted in both success blocks
    if (startingWorkComment && startingWorkComment.data.id) {
        await new Promise(resolve => setTimeout(resolve, 3000)); // 3s delay
        try {
            await octokit.request('DELETE /repos/{owner}/{repo}/issues/comments/{comment_id}', {
                owner: repoOwner,
                repo: repoName,
                comment_id: startingWorkComment.data.id
            });
            correlatedLogger.info({ commentId: startingWorkComment.data.id }, 'Removed \'starting work\' comment');
        } catch (deleteError) {
            correlatedLogger.warn({ commentId: startingWorkComment.data.id, error: deleteError.message }, 'Failed to remove \'starting work\' comment');
        }
    }

Activity

  1. integry commented on Nov 6, 2025

    @integry
    OwnerAuthor

    I will modify 'src/jobs/processPullRequestCommentJob.js' to implement this logic.

    --- a/src/jobs/processPullRequestCommentJob.js
    +++ b/src/jobs/processPullRequestCommentJob.js
    @@ -321,6 +321,11 @@
                     prCommentBody += `- Cost: $${cost.toFixed(2)}\n`;
                 }
     
    +            // Add reprocessing guard to final comment
    +            prCommentBody += `\n\n---\n_Processing comment ID${unprocessedComments.length > 1 ? 's' : ''}: ${unprocessedComments.map(c => String(c.id) + '✓').join(', ')}_`;
    +
                 completionComment = await octokit.request('POST /repos/{owner}/{repo}/issues/{issue_number}/comments', {
                     owner: repoOwner,
                     repo: repoName,
    @@ -328,6 +333,21 @@
                     body: prCommentBody,
                 });
     
    +            // Delete the "starting work" comment now that the final comment is posted
    +            if (startingWorkComment && startingWorkComment.data.id) {
    +                correlatedLogger.info({ commentId: startingWorkComment.data.id }, 'Process complete, delaying removal of \'starting work\' comment...');
    +                await new Promise(resolve => setTimeout(resolve, 3000)); // 3s delay
    +                try {
    +                    await octokit.request('DELETE /repos/{owner}/{repo}/issues/comments/{comment_id}', {
    +                        owner: repoOwner,
    +                        repo: repoName,
    +                        comment_id: startingWorkComment.data.id
    +                    });
    +                    correlatedLogger.info({ commentId: startingWorkComment.data.id }, 'Removed \'starting work\' comment');
    +                } catch (deleteError) {
    +                    correlatedLogger.warn({ commentId: startingWorkComment.data.id, error: deleteError.message }, 'Failed to remove \'starting work\' comment');
    +                }
    +            }
    +
                 correlatedLogger.info({
                     pullRequestNumber,
                     commitHash: commitResult.commitHash,
    @@ -351,12 +371,28 @@
                     noChangesBody += `- Cost: $${analysisCost.toFixed(2)}\n`;
                 }
                 
    +            // Add reprocessing guard to final comment
    +            noChangesBody += `\n\n---\n_Processing comment ID${unprocessedComments.length > 1 ? 's' : ''}: ${unprocessedComments.map(c => String(c.id) + '✓').join(', ')}_`;
    +
                 completionComment = await octokit.request('POST /repos/{owner}/{repo}/issues/{issue_number}/comments', {
                     owner: repoOwner,
                     repo: repoName,
                     issue_number: pullRequestNumber,
                     body: noChangesBody,
                 });
    +
    +            // Delete the "starting work" comment now that the final comment is posted
    +            if (startingWorkComment && startingWorkComment.data.id) {
    +                correlatedLogger.info({ commentId: startingWorkComment.data.id }, 'Process complete (no changes), delaying removal of \'starting work\' comment...');
    +                await new Promise(resolve => setTimeout(resolve, 3000)); // 3s delay
    +                try {
    +                    await octokit.request('DELETE /repos/{owner}/{repo}/issues/comments/{comment_id}', {
    +                        owner: repoOwner,
    +                        repo: repoName,
    +                        comment_id: startingWorkComment.data.id
    +                    });
    +                    correlatedLogger.info({ commentId: startingWorkComment.data.id }, 'Removed \'starting work\' comment');
    +                } catch (deleteError) {
    +                    correlatedLogger.warn({ commentId: startingWorkComment.data.id, error: deleteError.message }, 'Failed to remove \'starting work\' comment');
    +                }
    +            }
             }
     
             await stateManager.updateTaskState(taskId, TaskStates.COMPLETED, {
  2. propr-dev commented on Nov 6, 2025

    @propr-dev
    Contributor

    🤖 AI processing has started for this issue using claude-sonnet-4-5-20250929 model.

    I'll analyze the problem and work on a solution. This may take a few minutes.

    Processing Details:

    • Model: claude-sonnet-4-5-20250929
    • Branch: ai-fix/222-refactor-clean-up-startin-20251106-1546-claude-sonnet-4-5-20250929-lev
    • Base Branch: main
    • Worktree: issue-222-20251106-1546-claude-sonnet-4-5-20250929-lev
  3. added a commit that references this issue on Nov 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions