Skip to content

fix: ensure comment replies push changes to connected PRs#10

Merged
gf5901 merged 1 commit into
mainfrom
fix/comment-reply-push-pr
Mar 23, 2026
Merged

fix: ensure comment replies push changes to connected PRs#10
gf5901 merged 1 commit into
mainfrom
fix/comment-reply-push-pr

Conversation

@gf5901
Copy link
Copy Markdown
Owner

@gf5901 gf5901 commented Mar 23, 2026

Summary

  • Fix unpushed commits: _commit_reply_changes now checks git log origin/<branch>..HEAD for unpushed commits — not just git status --porcelain. When the Cursor agent commits changes itself during a session but doesn't push, those commits are now reliably pushed to the PR.
  • Inject PR context into prompt: The comment reply prompt now includes a ## Connected PR section with the PR URL when one exists, and instructs the agent that changes will be auto-pushed. This gives the agent awareness of the PR for fixing CI failures, merge conflicts, etc.
  • Pull latest before working / pushing: Reused worktrees are updated via git pull --rebase --autostash before the agent runs, and again before pushing, preventing stale-code edits and push rejections from diverged branches.
  • Save session ID after replies: Comment replies now persist the agent session ID so subsequent replies resume the same session with full conversation context.
  • Save CI status to task record: New poll_ci_status() in pr.py polls CI with a shorter timeout (180s, configurable via REPLY_CI_TIMEOUT) and saves the result as a ## CI Status section on the task — visible in the UI and available as context for future agent interactions.

Test plan

  • Verify all 331 existing tests pass (confirmed locally)
  • Post a comment on a task with an open PR asking to fix a code issue — verify the agent makes changes, they get pushed, and the PR is updated
  • Confirm CI status appears on the task detail page after the push
  • Post a follow-up comment on the same task — verify the agent resumes the previous session (same session ID)
  • Test with a PR that has a commit pushed externally (e.g. GitHub suggestion) — verify the rebase handles the diverged branch

Made with Cursor

Previously, comment reply agents would make code changes (e.g. fixing CI
failures or merge conflicts) but those changes often never reached the PR:

- _commit_reply_changes only checked `git status --porcelain` for uncommitted
  files — if the Cursor agent committed changes itself during its session, the
  working tree looked clean and the function bailed without pushing.
- The comment reply prompt had no PR context, so the agent didn't know a PR
  existed or what CI status to check.
- Reused worktrees were never updated from the remote, so the agent worked on
  stale code if the PR branch had advanced.

Changes:
- Detect unpushed commits via `git log origin/<branch>..HEAD` in addition to
  uncommitted changes, so agent-committed work always gets pushed.
- Pull latest (`git pull --rebase --autostash`) when reusing an existing
  worktree and before pushing, to handle diverged branches.
- Inject Connected PR section into the comment reply prompt when a PR URL
  exists on the task record.
- Save session ID after comment replies so subsequent replies resume the same
  agent session with full context.
- Add poll_ci_status() in pr.py — polls CI with a shorter timeout (180s) and
  returns a markdown summary. After pushing, the CI result is saved as a
  "CI Status" section on the task record, visible in the UI.

Made-with: Cursor
@gf5901 gf5901 merged commit cc290d9 into main Mar 23, 2026
4 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.

1 participant