fix(renderer): preserve desktop error codes
This commit is contained in:
1 parent
eec26a09a3
commit
1453a8fa95
15 files changed
+326
-40
No files matched your search
@@ -2,6 +2,7 @@ import { AnimatePresence, motion } from "framer-motion"
|
||||
import { CheckCircle, Warning, X, XCircle } from "./ui/icons"
|
||||
import { useAppStore } from "../state/store"
|
||||
import { useReducedMotion } from "./ui"
|
||||
import type { Toast } from "../state/slices/ui"
|
||||
|
||||
const TONE_CONFIG = {
|
||||
success: { icon: CheckCircle, className: "bg-success-muted border-success text-success" },
|
||||
@@ -34,9 +35,7 @@ export default function ToastContainer() {
|
||||
className={`flex w-[320px] items-start gap-2.5 rounded-lg border px-4 py-3 shadow-lg ${cfg.className}`}
|
||||
>
|
||||
<Icon size={16} weight="fill" className="mt-px shrink-0" />
|
||||
<span className="max-h-[6.5rem] min-w-0 flex-1 overflow-y-auto break-words text-[13px] font-medium leading-relaxed">
|
||||
{toast.message}
|
||||
</span>
|
||||
<ToastMessage message={toast.message} />
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => dismiss(toast.id)}
|
||||
@@ -52,3 +51,25 @@ export default function ToastContainer() {
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function ToastMessage({ message }: { message: Toast["message"] }) {
|
||||
if (typeof message === "string") {
|
||||
return (
|
||||
<span className="max-h-[6.5rem] min-w-0 flex-1 overflow-y-auto break-words text-[13px] font-medium leading-relaxed">
|
||||
{message}
|
||||
</span>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="max-h-[7.5rem] min-w-0 flex-1 overflow-y-auto">
|
||||
<div className="flex min-w-0 flex-wrap items-center gap-1.5">
|
||||
<span className="rounded bg-background/80 px-1.5 py-0.5 font-mono text-[10px] font-semibold uppercase tracking-[0.08em]">
|
||||
{message.code}
|
||||
</span>
|
||||
<span className="min-w-0 break-words text-[12px] font-semibold leading-5">{message.actionHint}</span>
|
||||
</div>
|
||||
<div className="mt-1 break-words text-[12px] leading-5 opacity-80">{message.message}</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useCallback, useEffect, useState } from "react";
|
||||
import type { AgentRecord, SkillRecord } from "@shared/types";
|
||||
import { useAppStore } from "../../state/store";
|
||||
import { formatDesktopResultError } from "../../lib/desktop";
|
||||
|
||||
type SkillAgentTogglesProps =
|
||||
| { mode: "skill"; companyId: string; skillId: string; agents: AgentRecord[] }
|
||||
@@ -48,7 +49,7 @@ export function SkillAgentToggles(props: SkillAgentTogglesProps) {
|
||||
return next;
|
||||
});
|
||||
} else {
|
||||
addToast(result.error.message, "danger");
|
||||
addToast(formatDesktopResultError(result.error), "danger");
|
||||
}
|
||||
setTogglingId(null);
|
||||
},
|
||||
|
||||
@@ -14,6 +14,7 @@ import { ActionButton, StatusPill, Eyebrow } from "../ui";
|
||||
import { SkillAgentToggles } from "./SkillAgentToggles";
|
||||
import { buildTree, SkillFileTree } from "./SkillFileTree";
|
||||
import { useT, type TranslationFn } from "../../i18n";
|
||||
import { formatDesktopResultError } from "../../lib/desktop";
|
||||
|
||||
const sourceIconMap: Record<string, typeof GithubLogo> = {
|
||||
github: GithubLogo,
|
||||
@@ -114,7 +115,7 @@ export function SkillDetail({
|
||||
if (result.ok) {
|
||||
setDetail(result.data);
|
||||
} else {
|
||||
addToast(result.error.message, "danger");
|
||||
addToast(formatDesktopResultError(result.error), "danger");
|
||||
}
|
||||
}
|
||||
void load();
|
||||
@@ -147,7 +148,7 @@ export function SkillDetail({
|
||||
if (result.ok) {
|
||||
setUpdateStatus(result.data);
|
||||
} else {
|
||||
addToast(result.error.message, "danger");
|
||||
addToast(formatDesktopResultError(result.error), "danger");
|
||||
}
|
||||
}, [companyId, skillId, detail, addToast]);
|
||||
|
||||
@@ -157,7 +158,7 @@ export function SkillDetail({
|
||||
addToast(t("skill.deleted"), "success");
|
||||
onDeleted();
|
||||
} else {
|
||||
addToast(result.error.message, "danger");
|
||||
addToast(formatDesktopResultError(result.error), "danger");
|
||||
}
|
||||
}, [companyId, skillId, addToast, onDeleted, t]);
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
import { Modal, ActionButton, Input } from "../ui";
|
||||
import { useAppStore } from "../../state/store";
|
||||
import { useT } from "../../i18n";
|
||||
import { describeDesktopError, formatDesktopResultError } from "../../lib/desktop";
|
||||
|
||||
type TabId = "github" | "local" | "url" | "skills_sh";
|
||||
|
||||
@@ -95,10 +96,10 @@ export function SkillImportModal({
|
||||
onImported();
|
||||
handleClose();
|
||||
} else {
|
||||
addToast(result.error.message, "danger");
|
||||
addToast(formatDesktopResultError(result.error), "danger");
|
||||
}
|
||||
} catch (error) {
|
||||
addToast(error instanceof Error ? error.message : t("skillImport.failed"), "danger");
|
||||
addToast(describeDesktopError(error), "danger");
|
||||
} finally {
|
||||
setIsImporting(false);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import { SkillList } from "./SkillList";
|
||||
import { SkillImportModal } from "./SkillImportModal";
|
||||
import { SkillDetail } from "./SkillDetail";
|
||||
import { useT } from "../../i18n";
|
||||
import { describeDesktopError, formatDesktopResultError } from "../../lib/desktop";
|
||||
|
||||
export function SkillsSection({
|
||||
companyId,
|
||||
@@ -37,10 +38,10 @@ export function SkillsSection({
|
||||
if (result.ok) {
|
||||
setSkills(result.data);
|
||||
} else {
|
||||
addToast(result.error.message, "danger");
|
||||
addToast(formatDesktopResultError(result.error), "danger");
|
||||
}
|
||||
} catch (error) {
|
||||
addToast(error instanceof Error ? error.message : "Failed to load skills", "danger");
|
||||
addToast(describeDesktopError(error), "danger");
|
||||
}
|
||||
}, [companyId, setSkills, addToast]);
|
||||
|
||||
|
||||
Reference in new issue
Block a user