Skip to content

Lite: add ability to remove branches#13125

Closed
OliverJAsh wants to merge 4 commits intomasterfrom
push-rxkwlmrvmxvv
Closed

Lite: add ability to remove branches#13125
OliverJAsh wants to merge 4 commits intomasterfrom
push-rxkwlmrvmxvv

Conversation

@OliverJAsh
Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI review requested due to automatic review settings March 31, 2026 16:29
@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 31, 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 Mar 31, 2026 4:30pm

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 branch removal support to the Lite workspace UI by wiring a new removeBranch IPC/mutation through the Electron preload/main layers, and exposing it via both the branch context/menu UI and a keyboard shortcut.

Changes:

  • Add a new removeBranch IPC channel + Electron API surface, and a React Query mutation that invalidates caches on success.
  • Add “Remove branch” to the branch segment menu plus a confirmation AlertDialog.
  • Add a Backspace shortcut to trigger the remove-branch flow; minor AbsorptionDialog prop rename (isAbsorbingisPending) for consistency.

Reviewed changes

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

Show a summary per file
File Description
apps/lite/ui/src/routes/project/$id/workspace/route.tsx Adds menu item + confirmation dialog and wires remove-branch mutation into workspace UI.
apps/lite/ui/src/routes/project/$id/workspace/route.module.css Adds dialog action button layout styling.
apps/lite/ui/src/routes/project/$id/workspace/-WorkspaceShortcuts.ts Adds Backspace binding and callback plumbing for “Remove branch”.
apps/lite/ui/src/routes/project/$id/workspace/-Absorption.tsx Renames dialog pending prop for API consistency.
apps/lite/ui/src/api/mutations.ts Introduces removeBranchMutationOptions (invalidate queries on success).
apps/lite/electron/src/preload.cts Exposes window.lite.removeBranch() to the UI.
apps/lite/electron/src/main.ts Registers IPC handler for workspace:remove-branch.
apps/lite/electron/src/ipc.ts Adds RemoveBranchParams, API typing, and IPC channel constant.

Comment on lines 1650 to +1654
<SegmentMenuPopup
canRename={branchName !== null && !isRenamePending}
onRename={startEditing}
canRemoveBranch={branchName !== null}
canRenameBranch={branchName !== null && !isRenamePending}
onRemoveBranch={requestRemoveBranch}
onRenameBranch={startEditing}
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

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

canRemoveBranch is currently enabled for any segment with a branchName, but the backend removeBranch(projectId, stackId, branchName) is only valid for certain segments (e.g. not the top-most segment unless it’s empty, and only when the stack has multiple segments). As-is, users can trigger “Remove branch” on unsupported segments and will just get an error toast.

Consider deriving canRemoveBranch from the stack/segment context (e.g. segmentIndex > 0 && stack.segments.length > 1 OR segment.commits.length === 0), and only call onRequestRemoveBranch when that condition holds.

Copilot uses AI. Check for mistakes.
Comment on lines 1670 to +1674
<SegmentMenuPopup
canRename={branchName !== null && !isRenamePending}
onRename={startEditing}
canRemoveBranch={branchName !== null}
canRenameBranch={branchName !== null && !isRenamePending}
onRemoveBranch={requestRemoveBranch}
onRenameBranch={startEditing}
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

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

Same as the ContextMenu version: canRemoveBranch is enabled based only on branchName !== null, but removeBranch isn’t valid for every named segment. Please compute canRemoveBranch using stack/segment context (e.g. stack size + segmentIndex + whether the segment is empty) so the menu doesn’t offer an action that is guaranteed to fail for top/solo segments.

Copilot uses AI. Check for mistakes.
Comment on lines 535 to 548
const handleBranchSegmentAction = (action: BranchSegmentAction, selection: SegmentItem) =>
Match.value(action).pipe(
Match.tags({
RenameBranch: () => {
setEditing({
_tag: "BranchName",
subject: {
stackId: selection.stackId,
segmentIndex: selection.segmentIndex,
},
});
},
RemoveBranch: () => onRemoveBranch(selection),
}),
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

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

The RemoveBranch keyboard shortcut always calls onRemoveBranch(selection) for any selected branch segment. Since the backend removal has restrictions (not every branch segment can be removed), this shortcut can open a removal flow that is guaranteed to fail for unsupported segments.

Please gate this action the same way as the UI menu (derive a canRemoveBranch from headInfo/stack context or make onRemoveBranch handle validation and no-op/show a specific message when removal isn’t allowed).

Copilot uses AI. Check for mistakes.
@OliverJAsh OliverJAsh marked this pull request as draft March 31, 2026 16:56
@OliverJAsh OliverJAsh closed this Apr 7, 2026
@OliverJAsh OliverJAsh deleted the push-rxkwlmrvmxvv branch April 7, 2026 15:58
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