Lite: add ability to remove branches#13125
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
b266aea to
130ff93
Compare
There was a problem hiding this comment.
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
removeBranchIPC 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 (
isAbsorbing→isPending) 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. |
| <SegmentMenuPopup | ||
| canRename={branchName !== null && !isRenamePending} | ||
| onRename={startEditing} | ||
| canRemoveBranch={branchName !== null} | ||
| canRenameBranch={branchName !== null && !isRenamePending} | ||
| onRemoveBranch={requestRemoveBranch} | ||
| onRenameBranch={startEditing} |
There was a problem hiding this comment.
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.
| <SegmentMenuPopup | ||
| canRename={branchName !== null && !isRenamePending} | ||
| onRename={startEditing} | ||
| canRemoveBranch={branchName !== null} | ||
| canRenameBranch={branchName !== null && !isRenamePending} | ||
| onRemoveBranch={requestRemoveBranch} | ||
| onRenameBranch={startEditing} |
There was a problem hiding this comment.
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.
| 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), | ||
| }), |
There was a problem hiding this comment.
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).
No description provided.