feat: add file manager context actions (#3027)

* feat(app): add file manager context actions

* fix: reshape file context actions

---------

Co-authored-by: Mohamed Boudra <boudra.moha@gmail.com>
This commit is contained in:
nikuscs
2026-08-10 18:18:23 +02:00
committed by GitHub
co-authored by Mohamed Boudra
parent a98d154b6b
commit ca2b633286
36 changed files with 4159 additions and 227 deletions
+20 -1
View File
@@ -24,7 +24,8 @@ export type CheckoutGitAsyncActionId =
| "enable-pr-auto-merge-rebase"
| "disable-pr-auto-merge"
| "merge-branch"
| "merge-from-base";
| "merge-from-base"
| "discard-changes";
type CheckoutKey = string;
type StatusMap = Partial<Record<CheckoutGitAsyncActionId, CheckoutGitActionStatus>>;
@@ -119,6 +120,7 @@ interface CheckoutGitActionsStoreState {
disablePrAutoMerge: (params: { serverId: string; cwd: string }) => Promise<void>;
mergeBranch: (params: { serverId: string; cwd: string; baseRef: string }) => Promise<void>;
mergeFromBase: (params: { serverId: string; cwd: string; baseRef: string }) => Promise<void>;
discardChanges: (params: { serverId: string; cwd: string; paths: string[] }) => Promise<void>;
}
async function runCheckoutAction({
@@ -366,6 +368,23 @@ export const useCheckoutGitActionsStore = create<CheckoutGitActionsStoreState>()
},
});
},
discardChanges: async ({ serverId, cwd, paths }) => {
await runCheckoutAction({
serverId,
cwd,
actionId: "discard-changes",
run: async () => {
const client = resolveClient(serverId);
const payload = await client.checkoutDiscardChanges(cwd, { paths });
if (!payload.success) {
throw new Error(
payload.error?.message ?? i18n.t("workspace.fileActions.confirmRevert.failed"),
);
}
},
});
},
}));
export function __resetCheckoutGitActionsStoreForTests() {