Skip to content

Add progress.txt PR comment to all eternity-loop flows#12

Closed
robertherber wants to merge 7 commits intomainfrom
add-progress-comment
Closed

Add progress.txt PR comment to all eternity-loop flows#12
robertherber wants to merge 7 commits intomainfrom
add-progress-comment

Conversation

@robertherber
Copy link
Member

Summary

  • Adds a post_progress_comment helper that posts ralph/progress.txt as a collapsible PR comment (prefixed with 🤖 **eternity-loop bot:** so it's excluded from human comment detection)
  • Calls it in all three finalization flows: review, ci-fix, and new task
  • For new tasks, looks up the PR number by branch name after finalize_task creates it

Test plan

  • Run eternity-loop with a review task and verify progress comment appears on the PR
  • Run with a CI fix task and verify progress comment appears
  • Run with a new todo task and verify progress comment appears after PR creation

🤖 Generated with Claude Code

Post ralph/progress.txt as a collapsible PR comment after each task
completes (review, ci-fix, and new task flows).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings March 2, 2026 22:54
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds automated posting of scripts/ralph/progress.txt as a collapsible GitHub PR comment at the end of eternity-loop task finalization flows (review, ci-fix, and newly-created PRs).

Changes:

  • Introduces a post_progress_comment helper that reads progress.txt and posts it via gh pr comment.
  • Invokes post_progress_comment after finishing review and ci-fix flows.
  • For new tasks, looks up the newly-created PR number by branch name, then posts the progress comment.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1248 to +1251
gh pr comment "$pr_number" --body "$comment_body" 2>/dev/null || {
log_err "[progress] WARNING: Failed to post progress comment on PR #$pr_number"
}
log_err "[progress] Progress comment posted on PR #$pr_number."
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

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

gh pr comment ... || { ... } logs a warning on failure, but the function still unconditionally logs "Progress comment posted" afterwards. This will report success even when the comment wasn't created. Consider logging success only when gh pr comment exits 0 (and keep the warning log for failures).

Suggested change
gh pr comment "$pr_number" --body "$comment_body" 2>/dev/null || {
log_err "[progress] WARNING: Failed to post progress comment on PR #$pr_number"
}
log_err "[progress] Progress comment posted on PR #$pr_number."
if gh pr comment "$pr_number" --body "$comment_body" 2>/dev/null; then
log_err "[progress] Progress comment posted on PR #$pr_number."
else
log_err "[progress] WARNING: Failed to post progress comment on PR #$pr_number"
fi

Copilot uses AI. Check for mistakes.
Comment on lines +1474 to +1476
cd "$WORK_DIR"
local new_pr_number
new_pr_number=$(gh pr list --head "$BRANCH_NAME" --json number --jq '.[0].number' 2>/dev/null) || true
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

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

local new_pr_number is used in the main script body (not inside a function). In bash this prints "local: can only be used in a function" and returns non-zero; with set -e enabled near the top of the script, this will terminate the loop. Use a normal variable assignment (or move this logic into a function) instead of local here.

Copilot uses AI. Check for mistakes.
# Post progress log as PR comment (look up PR number by branch)
cd "$WORK_DIR"
local new_pr_number
new_pr_number=$(gh pr list --head "$BRANCH_NAME" --json number --jq '.[0].number' 2>/dev/null) || true
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

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

When gh pr list --json number --jq '.[0].number' returns an empty list, --jq will output null (a non-empty string). The -n check will pass and post_progress_comment will be invoked with pr_number="null", which will fail. Consider changing the jq to '.[0].number // empty' (or explicitly checking for null) before posting the comment.

Suggested change
new_pr_number=$(gh pr list --head "$BRANCH_NAME" --json number --jq '.[0].number' 2>/dev/null) || true
new_pr_number=$(gh pr list --head "$BRANCH_NAME" --json number --jq '.[0].number // empty' 2>/dev/null) || true

Copilot uses AI. Check for mistakes.
robertherber and others added 6 commits March 3, 2026 00:12
`local` can only be used inside functions in bash. The new task flow's
PR number variable was declared with `local` at the top-level loop scope,
causing a fatal error.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
ensure_main_branch calls git clean -fd which deletes all untracked files.
When it ran after start_task, it wiped out the freshly generated prd.json.
Ralph would then see no PRD, immediately output COMPLETE, and produce
no commits.

Moving ensure_main_branch before start_task ensures prd.json is generated
on a clean main branch and survives into the ralph-loop execution.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Split PR comments by the latest commit date so Claude knows which
comments are new (actionable) and which are older (context only).

- get_pr_review_comments now accepts an optional cutoff date parameter
- When provided, returns {new_comments, previous_comments} instead of flat lists
- start_review_task passes the latest commit date as cutoff
- The PRD generation prompt clearly labels new comments as actionable
  and previous comments as background context only
- The reply-to-comments flow (no cutoff) still gets the flat format

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Increase log capture from 200 to 500 lines, with smart truncation:
  first 100 lines (setup context) + last 400 lines (actual errors)
- Include full logs when under 500 lines
- List failed jobs and their failed step names for structure
- Fetch GitHub check-run error annotations (file:line: message)
  which provide precise error locations
- Show check state in failed checks list

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The annotations API queries were complex, unreliable, and the useful
error info is already in the --log-failed output.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Previously Ralph only saw the PRD user stories for CI fixes but not
the actual failure logs. If the PRD-generating Claude didn't capture
enough detail, Ralph had no way to diagnose the failures.

Now for ci-fix tasks, the raw CI failure details (failed checks, job
names, and log output) are appended directly to Ralph's CLAUDE.md.
Also instructs Ralph to use fix(ci): commit prefix which aligns with
the loop prevention check in check_pr_has_ci_failures.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

2 participants