Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions apps/lite/electron/src/ipc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ export interface UpdateBranchNameParams {
newName: string;
}

export interface RemoveBranchParams {
projectId: string;
stackId: string;
branchName: string;
}

export interface TearOffBranchParams {
projectId: string;
subjectBranch: string;
Expand Down Expand Up @@ -182,6 +188,7 @@ export interface LiteElectronApi {
) => Promise<Array<BranchListing>>;
listProjects: () => Promise<Array<ProjectForFrontend>>;
moveBranch: (params: MoveBranchParams) => Promise<UIMoveBranchResult>;
removeBranch: (params: RemoveBranchParams) => Promise<void>;
updateBranchName: (params: UpdateBranchNameParams) => Promise<void>;
tearOffBranch: (params: TearOffBranchParams) => Promise<UIMoveBranchResult>;
ping: (input: string) => Promise<string>;
Expand Down Expand Up @@ -214,6 +221,7 @@ export const liteIpcChannels = {
listBranches: "workspace:list-branches",
listProjects: "projects:list",
moveBranch: "workspace:move-branch",
removeBranch: "workspace:remove-branch",
updateBranchName: "workspace:update-branch-name",
tearOffBranch: "workspace:tear-off-branch",
ping: "lite:ping",
Expand Down
7 changes: 7 additions & 0 deletions apps/lite/electron/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
type CommitUncommitChangesParams,
type MoveBranchParams,
type PushStackLegacyParams,
type RemoveBranchParams,
type TearOffBranchParams,
type TreeChangeDiffParams,
type UpdateBranchNameParams,
Expand Down Expand Up @@ -45,6 +46,7 @@ import {
listProjectsStateless,
moveBranch,
pushStackLegacy,
removeBranch,
tearOffBranch,
treeChangeDiffs,
unapplyStack,
Expand Down Expand Up @@ -138,6 +140,11 @@ function registerIpcHandlers(): void {
(_e, { projectId, subjectBranch, targetBranch }: MoveBranchParams) =>
moveBranch(projectId, subjectBranch, targetBranch),
);
ipcMain.handle(
liteIpcChannels.removeBranch,
(_e, { projectId, stackId, branchName }: RemoveBranchParams) =>
removeBranch(projectId, stackId, branchName),
);
ipcMain.handle(
liteIpcChannels.updateBranchName,
(_e, { projectId, stackId, branchName, newName }: UpdateBranchNameParams) =>
Expand Down
1 change: 1 addition & 0 deletions apps/lite/electron/src/preload.cts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ const api: LiteElectronApi = {
listProjects: () => ipcRenderer.invoke("projects:list") as Promise<Array<ProjectForFrontend>>,
moveBranch: (params) =>
ipcRenderer.invoke("workspace:move-branch", params) as Promise<UIMoveBranchResult>,
removeBranch: (params) => ipcRenderer.invoke("workspace:remove-branch", params) as Promise<void>,
updateBranchName: (params) =>
ipcRenderer.invoke("workspace:update-branch-name", params) as Promise<void>,
tearOffBranch: (params) =>
Expand Down
7 changes: 7 additions & 0 deletions apps/lite/ui/src/api/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ export const moveBranchMutationOptions = mutationOptions({
},
});

export const removeBranchMutationOptions = mutationOptions({
mutationFn: window.lite.removeBranch,
onSuccess: async (_data, _input, _ctx, { client }) => {
await client.invalidateQueries();
},
});

export const updateBranchNameMutationOptions = mutationOptions({
mutationFn: window.lite.updateBranchName,
onSuccess: async (_data, _input, _ctx, { client }) => {
Expand Down
8 changes: 4 additions & 4 deletions apps/lite/ui/src/routes/project/$id/workspace/-Absorption.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ const describeAbsorptionReason = (reason: AbsorptionReason): string | null => {

export const AbsorptionDialog: FC<{
absorptionPlan: Array<CommitAbsorption>;
isAbsorbing: boolean;
isPending: boolean;
onConfirm: () => void;
onOpenChange: (open: boolean) => void;
}> = ({ absorptionPlan, isAbsorbing, onConfirm, onOpenChange }) => (
}> = ({ absorptionPlan, isPending, onConfirm, onOpenChange }) => (
<AlertDialog.Root open onOpenChange={onOpenChange}>
<AlertDialog.Portal>
<AlertDialog.Backdrop className={uiStyles.dialogBackdrop} />
Expand Down Expand Up @@ -57,14 +57,14 @@ export const AbsorptionDialog: FC<{
))}
</ul>
<div className={styles.actions}>
<AlertDialog.Close className={uiStyles.button} disabled={isAbsorbing}>
<AlertDialog.Close className={uiStyles.button} disabled={isPending}>
Cancel
</AlertDialog.Close>
<button
type="button"
className={uiStyles.button}
onClick={onConfirm}
disabled={absorptionPlan.length === 0 || isAbsorbing}
disabled={absorptionPlan.length === 0 || isPending}
>
Absorb changes
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,17 +135,24 @@ const commitDetailsBindings: Array<ShortcutBinding<CommitDetailsAction>> = [
closeCommitDetailsBinding,
];

type BranchSegmentAction = SelectionAction | { _tag: "RenameBranch" };
type BranchSegmentAction = SelectionAction | { _tag: "RenameBranch" } | { _tag: "RemoveBranch" };

const branchSegmentBindings: Array<ShortcutBinding<BranchSegmentAction>> = [
...selectionBindings,
{
id: "segment-rename-branch",
id: "branch-segment-rename",
description: "Rename",
keys: ["Enter"],
action: { _tag: "RenameBranch" },
repeat: false,
},
{
id: "branch-segment-remove",
description: "Remove branch",
keys: ["Backspace"],
action: { _tag: "RemoveBranch" },
repeat: false,
},
];

type FullscreenPreviewAction = { _tag: "Close" };
Expand Down Expand Up @@ -409,6 +416,7 @@ export const useWorkspaceShortcuts = ({
setEditing,
commonBaseCommitId,
onAbsorbChanges,
onRemoveBranch,
}: {
projectId: string;
showFullscreenPreview: boolean;
Expand All @@ -418,6 +426,7 @@ export const useWorkspaceShortcuts = ({
setEditing: (selection: Editing | null) => void;
commonBaseCommitId?: string;
onAbsorbChanges: (changes: Array<TreeChange>, stackId: string | null) => void;
onRemoveBranch: (selection: SegmentItem) => void;
}) => {
const { data: headInfo } = useSuspenseQuery(headInfoQueryOptions(projectId));
const { data: worktreeChanges } = useSuspenseQuery(changesInWorktreeQueryOptions(projectId));
Expand Down Expand Up @@ -535,6 +544,7 @@ export const useWorkspaceShortcuts = ({
},
});
},
RemoveBranch: () => onRemoveBranch(selection),
}),
Match.orElse((action) => handleSelectionAction(action, { _tag: "Segment", ...selection })),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,12 @@
font-family: monospace;
}

.dialogActions {
display: flex;
column-gap: 8px;
justify-content: flex-end;
}

.editCommitMessageInput {
field-sizing: content;
box-sizing: content-box;
Expand Down
Loading
Loading