返回 DeepSeek-Reasonix
manualCreationPresentation.ts
根目录 / desktop / frontend / src / lib / manualCreationPresentation.ts
1 import type { ManualSessionCreationView } from "../generated/desktopContract.generated";
2 import type { DictKey } from "./i18n";
3
4 export function manualCreationPresentation(item: ManualSessionCreationView): { key: DictKey; action?: "retry" | "new" | "project" } {
5 const status = item.progress?.status;
6 // Host recovery supersedes an older durable error. Internal stages are not
7 // user decisions; expose only a meaningful wait or one next action.
8 if (status === "waiting_workspace") return { key: "creation.workspaceUnavailable" };
9 if (status && ["waiting_lock", "retrying_storage", "stopping", "running", "queued"].includes(status)) {
10 return { key: item.progress?.slow ? "creation.slow" : "creation.preparing" };
11 }
12 const code = /session_operation:([^:]+):/.exec(item.error || "")?.[1] || item.progress?.errorCode;
13 if (code === "workspace_removed" || code === "workspace_changed") return { key: "creation.workspaceChanged", action: "project" };
14 if (code === "creation_cancelled" || code === "creation_owner_conflict") return { key: "creation.unavailable", action: "new" };
15 if (status === "blocked" || status === "stopped" || item.phase === "failed") return { key: "creation.failed", action: "retry" };
16 return { key: "creation.preparing" };
17 }
18
18 lines TYPESCRIPT