Skip to content

Native: Add /pr to push a session's branch and open a pull request - #1289

Draft
Kaloyanes wants to merge 3 commits into
hardbeat920:mainfrom
Kaloyanes:pr/open-pr-command
Draft

Kaloyanes wants to merge 3 commits into
hardbeat920:mainfrom
Kaloyanes:pr/open-pr-command

Conversation

@Kaloyanes

Copy link
Copy Markdown
Contributor

Depends on #1230. This branch is stacked on it (it merges pr/auto-link-opened-prs), so the diff below includes #1230's commits until that merges. The /pr change is the last commit, e453b199.

What changed

Adds a /pr command that pushes the session's branch and opens a GitHub pull request.

  • A bare /pr (or /pr --draft) checks the branch, then puts a proposed title and body in the composer as editable /pr text. The title comes from the session; the body comes from the latest reply plus the branch's commits.
  • Sending that text pushes with upstream tracking, runs gh pr create (with --draft when asked), and links the new PR to the session through Native: Link a session to the pull request its agent opens #1230's linking.
  • If the branch already has an open PR, that PR is returned and nothing is pushed or created.

Each precondition has its own error message: a git repository, not detached, not the default branch, gh installed and signed in, no uncommitted changes (it suggests /commit), and commits ahead of the base.

Why

Opening a PR from a session meant asking the agent to do it, or leaving MonoCode for a terminal. /pr does it in one step, with a body you can edit before anything is pushed.

Where

  • monocode-core/src/scm/open_pr.rs: the rules, behind a small PrTools trait for the git and gh calls, so they're tested with a fake.
  • monocode-core/src/scm.rs: new gh_exec, git_capture and pr_url_from_output, which pr_create now shares.
  • monocode-gpui/src/conversation/open_pr.rs, plus small hooks in conversation.rs, commands.rs, git_actions.rs and composer_completion.rs.

UI

No new chrome. /pr shows up in slash-command completion, and the proposed PR text goes in the composer.

Checks

None of the checks ran for this PR. The build machine is out of disk space (about 1.45 GB free), so cargo fmt --check, cargo check, cargo clippy -D warnings and the tests (including the PrTools fake tests in scm/open_pr.rs) have not run on this branch. I opened it as a draft so CI can run them; it stays a draft until they pass locally too.

Checklist

A finished `gh pr create` (or GitHub MCP `create_pull_request`) call
links its session to the new PR, so PR activity notifications follow
it. An agent-opened PR replaces a linked issue but never an earlier PR.
A bare /pr (or /pr --draft) checks the branch, then writes a proposed title
and body into the composer as editable /pr text. Sending the edited text
pushes with upstream tracking, runs gh pr create (adding --draft when asked)
and links the pull request to the session. The title comes from the session,
the body from its latest reply plus the branch's commits.

Preconditions, each with its own error: git repository, not detached, not
the default branch, gh installed and signed in, no uncommitted changes
(hinting /commit), commits ahead of the base. An open pull request for the
branch is returned as is, with nothing pushed or created.

The git and gh calls sit behind a small PrTools trait in scm/open_pr.rs, so
the rules are tested with a fake. scm.rs gains gh_exec, git_capture and
pr_url_from_output, which pr_create now shares.
@coderabbitai

coderabbitai Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

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