Skip to content

Source control: Open PR action usable during a run, with merge when CI passes #533

Description

@Tryanks

Summary

Add an "Open PR" action to a thread that can be pressed at any time, including while a turn is running, with an option to merge once CI passes. It replaces typing "open a PR, merge when CI passes" into the conversation by hand.

Behaviour

A split button in the thread header with two actions:

  1. Open PR (host) — the default.
    • When the thread is idle it runs immediately. While a turn is running it is armed: a visible, cancellable pending chip; it runs when the thread next becomes idle (turn ended, no pending approvals or input). It never commits half-written edits. If the turn ended in an error or was interrupted, the chip waits with "Run now" / "Cancel".
    • Steps: commit (message generated the same way as today's commit dialog), push / publish the branch, create the PR against the base (worktree base, else the default branch), title and body generated from the diff, then link it to the thread as created. Reuse an existing open PR for the branch instead of creating a duplicate.
    • Merge when CI passes (checkbox, remembered per project): use the forge's native auto-merge, never a Tcode-side CI watcher — GitHub gh pr merge --auto (requires auto-merge enabled on the repo), GitLab auto-merge / merge when pipeline succeeds, Gitea/Forgejo merge_when_checks_succeed on the merge API (neither tea nor fj exposes it; call the API), Azure DevOps auto-complete. Bitbucket: no native equivalent known; the option is disabled there. Verify each before shipping.
    • Failures surface as toasts and on the PR badge; a failing CI is shown on the linked PR, and the user decides whether to ask the agent to fix it.
  2. Ask agent to open PR.
    • Puts a visible, editable message into the composer ("Open a pull request for these changes and merge it once CI passes"); while running it goes into the existing message queue. The agent does the work with its own tools, including fixing a failing CI.
    • Nothing hidden is injected: the message is the user's message (Principle 1). The resulting PR is found by the branch-PR lookup after the turn.

Dependencies

Forge detection and linked PRs (#532). Title/body generation should share the owner of commit-message generation (generate_commit_message, crates/runtime/src/app/git.rs).

Related work

guivieiras/tcode has unmerged queued-message work (attached composer drawer 219d046, edit/remove actions c58bf81) that the "Ask agent" path would use.

Activity

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

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions