返回 DeepSeek-Reasonix
worktreeCleanupNotice.ts
根目录 / desktop / frontend / src / lib / worktreeCleanupNotice.ts
1 import { writeClipboardText } from "./clipboard";
2 import type { Translator } from "./i18n";
3 import type { ToastContextValue } from "./toast";
4 import type { WorktreeCleanupResult } from "./types";
5
6 export function showWorktreeCleanupNotice(
7 cleanup: WorktreeCleanupResult,
8 t: Translator,
9 showToast: ToastContextValue["showToast"],
10 ): void {
11 const lateContent = cleanup.blockers.find((blocker) => blocker.code === "late_content_preserved");
12 if (cleanup.recoveryRetained && cleanup.recoveryRoot) {
13 const recoveryRoot = cleanup.recoveryRoot;
14 const detail = cleanup.error || lateContent?.message;
15 showToast(
16 `${t("worktree.recoveryRetained", { path: recoveryRoot })}${detail ? ` ${detail}` : ""}`,
17 detail ? "error" : "info",
18 {
19 durationMs: 12000,
20 actionLabel: t("worktree.copyRecoveryPath"),
21 onAction: () => {
22 void writeClipboardText(recoveryRoot).then((copied) => {
23 showToast(copied ? t("worktree.recoveryPathCopied") : t("diag.copyFailed"), copied ? "info" : "error");
24 });
25 },
26 },
27 );
28 return;
29 }
30 if (cleanup.completed) {
31 showToast(t("worktree.mergeAndCleanupDone"), "info");
32 return;
33 }
34 showToast(cleanup.error || t("worktree.cleanupPreserved"), "error", { durationMs: 9000 });
35 }
36
36 lines TYPESCRIPT