Skip to content

Forge: Set review to auto-merge#13237

Draft
estib-vega wants to merge 1 commit intomasterfrom
set-auto-merge
Draft

Forge: Set review to auto-merge#13237
estib-vega wants to merge 1 commit intomasterfrom
set-auto-merge

Conversation

@estib-vega
Copy link
Copy Markdown
Contributor

@estib-vega estib-vega commented Apr 8, 2026

Add a button to the PR card to enable the auto-merge if there are checks
and they haven’t finished.

Screenshot 2026-04-08 at 17.21.16.png

TODOs

  • Ability to toggle on and off
  • Ensure this is not janky (loading the checks info should be a bit faster)
  • Get some design vetting

Add a button to the PR card to enable the auto-merge if there are checks
and they haven’t finished.
Copilot AI review requested due to automatic review settings April 8, 2026 23:24
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 8, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
gitbutler-web Skipped Skipped Apr 8, 2026 11:24pm

Request Review

Copy link
Copy Markdown
Contributor

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 an “Enable auto-merge” action to the stacked PR card so users can opt into auto-merge while CI checks are still in progress, wiring the UI to forge-specific PR services.

Changes:

  • Extend ForgePrService with a setAutoMerge(projectId, prNumber, enable) capability.
  • Implement setAutoMerge in GitHub/GitLab PR services via backend mutations.
  • Add an “Enable auto-merge” button to StackedPullRequestCard based on checks status.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
apps/desktop/src/lib/forge/interface/forgePrService.ts Adds setAutoMerge to the forge PR service interface.
apps/desktop/src/lib/forge/gitlab/gitlabPrService.svelte.ts Implements setAutoMerge for GitLab via backend mutation.
apps/desktop/src/lib/forge/github/githubPrService.svelte.ts Implements setAutoMerge for GitHub via backend mutation.
apps/desktop/src/components/forge/StackedPullRequestCard.svelte Fetches checks status and shows an “Enable auto-merge” button when appropriate.

Comment on lines 37 to +41
const prQuery = $derived(branch?.prNumber ? prService?.get(branch?.prNumber) : undefined);
const pr = $derived(prQuery?.response);

const checksQuery = $derived(checksService?.get(branchName));

Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

checksService?.get(branchName) is created without any polling or enable/disable gating. Since RTK Query won’t re-fetch by default, the checks state can become stale and the “Enable auto-merge” button may not appear/disappear as checks progress. Also, this will still try to query checks even for forked PRs where check-runs aren’t available (see CIChecksBadge.svelte’s enabled = !isFork && !isMerged pattern), which can generate unnecessary errors/network traffic. Consider only creating this query when pr is available and eligible, and pass subscriptionOptions.pollingInterval like CIChecksBadge does so the UI reflects running/completed checks.

Copilot uses AI. Check for mistakes.
Comment on lines +118 to +121
{:else if isDefined(checks) && !(checks.completed && checks.success)}
<AsyncButton wide style="gray" kind="outline" action={handleEnableAutoMerge}>
Enable auto-merge
</AsyncButton>
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

The button condition !(checks.completed && checks.success) will also show “Enable auto-merge” when checks are already in a terminal failed state (completed === true && success === false). Given the PR description says the button is for checks that “haven’t finished”, and ChecksStatus.completed is documented as true even on failures, this condition doesn’t match the stated behavior. Either change the condition to only target non-completed checks, or update the PR description/UX to explicitly include failed-checks cases.

Copilot uses AI. Check for mistakes.
Comment on lines +109 to 114
async setAutoMerge(projectId: string, reviewId: number, enable: boolean) {
await this.backendApi.endpoints.setAutoMerge.mutate({ projectId, reviewId, enable });
}

async setDraft(projectId: string, reviewId: number, draft: boolean) {
await this.backendApi.endpoints.setDraft.mutate({ projectId, reviewId, draft });
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

Parameter naming is inconsistent with the ForgePrService interface: the interface uses prNumber, but this method uses reviewId. Renaming the parameter to prNumber (or aligning the interface and all implementations on one term) would reduce confusion, especially since there is also a separate projectId parameter.

Suggested change
async setAutoMerge(projectId: string, reviewId: number, enable: boolean) {
await this.backendApi.endpoints.setAutoMerge.mutate({ projectId, reviewId, enable });
}
async setDraft(projectId: string, reviewId: number, draft: boolean) {
await this.backendApi.endpoints.setDraft.mutate({ projectId, reviewId, draft });
async setAutoMerge(projectId: string, prNumber: number, enable: boolean) {
await this.backendApi.endpoints.setAutoMerge.mutate({
projectId,
reviewId: prNumber,
enable,
});
}
async setDraft(projectId: string, prNumber: number, draft: boolean) {
await this.backendApi.endpoints.setDraft.mutate({
projectId,
reviewId: prNumber,
draft,
});

Copilot uses AI. Check for mistakes.
Comment on lines +102 to 107
async setAutoMerge(projectId: string, reviewId: number, enable: boolean) {
await this.backendApi.endpoints.setAutoMergeMR.mutate({ projectId, reviewId, enable });
}

async setDraft(projectId: string, reviewId: number, draft: boolean) {
await this.backendApi.endpoints.setDraftMR.mutate({ projectId, reviewId, draft });
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

Parameter naming is inconsistent with the ForgePrService interface: the interface uses prNumber, but this method uses reviewId. Renaming to prNumber (or aligning terminology across implementations) would make the GitLab and GitHub services more consistent and easier to reason about.

Suggested change
async setAutoMerge(projectId: string, reviewId: number, enable: boolean) {
await this.backendApi.endpoints.setAutoMergeMR.mutate({ projectId, reviewId, enable });
}
async setDraft(projectId: string, reviewId: number, draft: boolean) {
await this.backendApi.endpoints.setDraftMR.mutate({ projectId, reviewId, draft });
async setAutoMerge(projectId: string, prNumber: number, enable: boolean) {
await this.backendApi.endpoints.setAutoMergeMR.mutate({
projectId,
reviewId: prNumber,
enable,
});
}
async setDraft(projectId: string, prNumber: number, draft: boolean) {
await this.backendApi.endpoints.setDraftMR.mutate({
projectId,
reviewId: prNumber,
draft,
});

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants