Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

fix(views): surface backend error messages on mutation failures (MUL-2317) (#2772)

Naiyuan Qing20c2f45b4a8a
diff --git a/packages/core/api/index.ts b/packages/core/api/index.ts
index c1ce2fa7c6..2c33295a46 100644
--- a/packages/core/api/index.ts
+++ b/packages/core/api/index.ts
@@ -13,6 +13,8 @@ export type {
} from "./client";
export { parseWithFallback, setSchemaLogger } from "./schema";
export type { ParseOptions } from "./schema";
+export { DuplicateIssueErrorBodySchema } from "./schemas";
+export type { DuplicateIssueErrorBody } from "./schemas";
export { WSClient } from "./ws-client";
import type { ApiClient as ApiClientType } from "./client";
diff --git a/packages/core/api/schemas.test.ts b/packages/core/api/schemas.test.ts
new file mode 100644
index 0000000000..fdac8748bc
--- /dev/null
+++ b/packages/core/api/schemas.test.ts
@@ -0,0 +1,51 @@
+import { describe, expect, it } from "vitest";
+import { DuplicateIssueErrorBodySchema } from "./schemas";
+
+// The duplicate-issue branch in create-issue.tsx feeds ApiError.body
+// (typed as `unknown`) through this schema. Any future server drift that
+// loses the contract MUST fail the parse so the UI falls back to a normal
+// error toast instead of rendering an empty / partial duplicate card.
+describe("DuplicateIssueErrorBodySchema", () => {
+ const valid = {
+ code: "active_duplicate_issue",
+ error: "An active issue with this title already exists: MUL-12 – Login bug",
+ issue: {
+ id: "11111111-1111-1111-1111-111111111111",
+ identifier: "MUL-12",
+ title: "Login bug",
+ },
+ };
+
+ it("accepts a well-formed body", () => {
+ expect(DuplicateIssueErrorBodySchema.safeParse(valid).success).toBe(true);
+ });
+
+ it("accepts unknown extra fields via .loose()", () => {
+ const forwardCompat = {
+ ...valid,
+ hint: "Try a different title",
+ issue: { ...valid.issue, workspace_id: "ws-1", status: "todo" },
+ };
+ expect(DuplicateIssueErrorBodySchema.safeParse(forwardCompat).success).toBe(true);
+ });
+
+ it("rejects a renamed code (so renames degrade to the generic toast)", () => {
+ const renamed = { ...valid, code: "duplicate_issue" };
+ expect(DuplicateIssueErrorBodySchema.safeParse(renamed).success).toBe(false);
+ });
+
+ it("rejects a missing issue object", () => {
+ const { issue: _omit, ...without } = valid;
+ expect(DuplicateIssueErrorBodySchema.safeParse(without).success).toBe(false);
+ });
+
+ it("rejects a non-string issue.id", () => {
+ const broken = { ...valid, issue: { ...valid.issue, id: 42 } };
+ expect(DuplicateIssueErrorBodySchema.safeParse(broken).success).toBe(false);
+ });
+
+ it("accepts a missing error field (it is optional)", () => {
+ const { error: _omit, ...without } = valid;
+ expect(DuplicateIssueErrorBodySchema.safeParse(without).success).toBe(true);
+ });
+});
diff --git a/packages/core/api/schemas.ts b/packages/core/api/schemas.ts
index 1aee49221f..a1211928f2 100644
--- a/packages/core/api/schemas.ts
+++ b/packages/core/api/schemas.ts
@@ -333,3 +333,45 @@ export const EMPTY_CREATE_AGENT_FROM_TEMPLATE_RESPONSE: CreateAgentFromTemplateR
imported_skill_ids: [],
reused_skill_ids: [],
};
+
+// ---------------------------------------------------------------------------
+// Structured error body — POST /api/workspaces/:wsId/issues 409 conflict.
+//
+// When the server detects an active issue with the same title in the same
+// workspace, it returns `{ code: "active_duplicate_issue", error, issue }`
+// instead of letting the create through. The UI uses the embedded issue ref
+// to offer "view existing" rather than dropping the user into a generic
+// "create failed" toast.
+//
+// Strict guarantees:
+// - `code` is a literal so a future server rename (e.g. `duplicate_issue`)
+// fails the parse and falls back to a normal error toast — drift never
+// ships as a broken duplicate UI.
+// - `issue` is required; without an id/identifier/title the "view existing"
+// button has nothing to point at, so we'd rather fall back than guess.
+// - `issue.status` is intentionally OMITTED: the duplicate toast doesn't
+// render a StatusIcon (which has no fallback for unknown enum values),
+// so a future server-side rename of `status` must not knock this branch
+// out. `.loose()` lets the field pass through unchanged for any other
+// consumer.
+// ---------------------------------------------------------------------------
+
+export const DuplicateIssueErrorBodySchema = z.object({
+ code: z.literal("active_duplicate_issue"),
+ error: z.string().optional(),
+ issue: z.object({
+ id: z.string(),
+ identifier: z.string(),
+ title: z.string(),
+ }).loose(),
+}).loose();
+
+export interface DuplicateIssueErrorBody {
+ code: "active_duplicate_issue";
+ error?: string;
+ issue: {
+ id: string;
+ identifier: string;
+ title: string;
+ };
+}
diff --git a/packages/core/package.json b/packages/core/package.json
index fcfba07787..52ce1cc753 100644
--- a/packages/core/package.json
+++ b/packages/core/package.json
@@ -15,6 +15,7 @@
"./api": "./api/index.ts",
"./api/client": "./api/client.ts",
"./api/schema": "./api/schema.ts",
+ "./api/schemas": "./api/schemas.ts",
"./api/ws-client": "./api/ws-client.ts",
"./config": "./config/index.ts",
"./auth": "./auth/index.ts",
diff --git a/packages/views/agents/components/tabs/custom-args-tab.tsx b/packages/views/agents/components/tabs/custom-args-tab.tsx
index c33456c13b..13bd714e04 100644
--- a/packages/views/agents/components/tabs/custom-args-tab.tsx
+++ b/packages/views/agents/components/tabs/custom-args-tab.tsx
@@ -71,8 +71,12 @@ export function CustomArgsTab({
try {
await onSave({ custom_args: currentArgs });
toast.success(t(($) => $.tab_body.custom_args.saved_toast));
- } catch {
- toast.error(t(($) => $.tab_body.custom_args.save_failed_toast));
+ } catch (err) {
+ toast.error(
+ err instanceof Error && err.message
+ ? err.message
+ : t(($) => $.tab_body.custom_args.save_failed_toast),
+ );
} finally {
setSaving(false);
}
diff --git a/packages/views/agents/components/tabs/env-tab.tsx b/packages/views/agents/components/tabs/env-tab.tsx
index 82d344b7c2..54820f5b0a 100644
--- a/packages/views/agents/components/tabs/env-tab.tsx
+++ b/packages/views/agents/components/tabs/env-tab.tsx
@@ -114,8 +114,12 @@ export function EnvTab({
try {
await onSave({ custom_env: currentEnvMap });
toast.success(t(($) => $.tab_body.env.saved_toast));
- } catch {
- toast.error(t(($) => $.tab_body.env.save_failed_toast));
+ } catch (err) {
+ toast.error(
+ err instanceof Error && err.message
+ ? err.message
+ : t(($) => $.tab_body.env.save_failed_toast),
+ );
} finally {
setSaving(false);
}
diff --git a/packages/views/autopilots/components/autopilot-detail-page.tsx b/packages/views/autopilots/components/autopilot-detail-page.tsx
index 429e618e89..e2b1a9ca7c 100644
--- a/packages/views/autopilots/components/autopilot-detail-page.tsx
+++ b/packages/views/autopilots/components/autopilot-detail-page.tsx
@@ -262,8 +262,12 @@ function TriggerRow({ trigger, autopilotId }: { trigger: AutopilotTrigger; autop
await deleteTrigger.mutateAsync({ autopilotId, triggerId: trigger.id });
toast.success(t(($) => $.trigger_row.toast_deleted));
setConfirmOpen(false);
- } catch {
- toast.error(t(($) => $.trigger_row.toast_delete_failed));
+ } catch (err) {
+ toast.error(
+ err instanceof Error && err.message
+ ? err.message
+ : t(($) => $.trigger_row.toast_delete_failed),
+ );
} finally {
setDeleting(false);
}
@@ -299,8 +303,12 @@ function TriggerRow({ trigger, autopilotId }: { trigger: AutopilotTrigger; autop
await rotateToken.mutateAsync({ autopilotId, triggerId: trigger.id });
toast.success(t(($) => $.trigger_row.toast_rotated));
setRotateOpen(false);
- } catch {
- toast.error(t(($) => $.trigger_row.toast_rotate_failed));
+ } catch (err) {
+ toast.error(
+ err instanceof Error && err.message
+ ? err.message
+ : t(($) => $.trigger_row.toast_rotate_failed),
+ );
}
};
@@ -466,8 +474,12 @@ function AddTriggerDialog({
setKind("schedule");
setConfig(getDefaultTriggerConfig());
setLabel("");
- } catch {
- toast.error(t(($) => $.add_trigger_dialog.toast_add_failed));
+ } catch (err) {
+ toast.error(
+ err instanceof Error && err.message
+ ? err.message
+ : t(($) => $.add_trigger_dialog.toast_add_failed),
+ );
} finally {
setSubmitting(false);
}
@@ -627,8 +639,12 @@ export function AutopilotDetailPage({ autopilotId }: { autopilotId: string }) {
await deleteAutopilot.mutateAsync(autopilotId);
toast.success(t(($) => $.detail.toast_deleted));
router.push(wsPaths.autopilots());
- } catch {
- toast.error(t(($) => $.detail.toast_delete_failed));
+ } catch (err) {
+ toast.error(
+ err instanceof Error && err.message
+ ? err.message
+ : t(($) => $.detail.toast_delete_failed),
+ );
setDeleting(false);
}
};
diff --git a/packages/views/autopilots/components/autopilot-dialog-i18n.test.ts b/packages/views/autopilots/components/autopilot-dialog-i18n.test.ts
new file mode 100644
index 0000000000..9e9a9db274
--- /dev/null
+++ b/packages/views/autopilots/components/autopilot-dialog-i18n.test.ts
@@ -0,0 +1,72 @@
+import { describe, expect, it } from "vitest";
+import type { TFunction } from "i18next";
+import { createI18n } from "@multica/core/i18n/react";
+import enAutopilots from "../../locales/en/autopilots.json";
+import zhAutopilots from "../../locales/zh-Hans/autopilots.json";
+import { formatSchedulePartialFailureToast } from "./autopilot-dialog-toast";
+
+// Contract test for the autopilot-dialog partial-success toast formatting.
+//
+// The dialog routes its partial-success branches through
+// `formatSchedulePartialFailureToast`, so this test drives that exact
+// helper rather than calling `t(...)` independently. That means a regression
+// in either side — the JSON template (e.g. `{reason}` instead of `{{reason}}`)
+// or the call-site variable name (e.g. `{ msg: ... }` instead of
+// `{ reason: ... }`) — fails this test with the substring assertion.
+
+describe("autopilot dialog partial-success toast", () => {
+ const reason = "schedule conflict: 09:00 overlaps existing trigger";
+
+ describe("en", () => {
+ const i18n = createI18n("en", { en: { autopilots: enAutopilots } });
+ const t = i18n.getFixedT("en", "autopilots") as TFunction<"autopilots">;
+
+ it("renders create partial-success with the server reason verbatim", () => {
+ const rendered = formatSchedulePartialFailureToast(t, "create", reason);
+ expect(rendered).toContain(reason);
+ expect(rendered).not.toContain("{{");
+ expect(rendered).not.toContain("{reason}");
+ });
+
+ it("renders update partial-success with the server reason verbatim", () => {
+ const rendered = formatSchedulePartialFailureToast(t, "update", reason);
+ expect(rendered).toContain(reason);
+ expect(rendered).not.toContain("{{");
+ expect(rendered).not.toContain("{reason}");
+ });
+
+ it("falls back to the no-reason create string when reason is null", () => {
+ expect(formatSchedulePartialFailureToast(t, "create", null)).toBe(
+ "Autopilot created, but schedule failed to save",
+ );
+ });
+
+ it("falls back to the no-reason update string when reason is null", () => {
+ expect(formatSchedulePartialFailureToast(t, "update", null)).toBe(
+ "Autopilot updated, but schedule failed to save",
+ );
+ });
+ });
+
+ describe("zh-Hans", () => {
+ const i18n = createI18n("zh-Hans", {
+ "zh-Hans": { autopilots: zhAutopilots },
+ en: { autopilots: enAutopilots },
+ });
+ const t = i18n.getFixedT("zh-Hans", "autopilots") as TFunction<"autopilots">;
+
+ it("renders create partial-success with the server reason verbatim", () => {
+ const rendered = formatSchedulePartialFailureToast(t, "create", reason);
+ expect(rendered).toContain(reason);
+ expect(rendered).not.toContain("{{");
+ expect(rendered).not.toContain("{reason}");
+ });
+
+ it("renders update partial-success with the server reason verbatim", () => {
+ const rendered = formatSchedulePartialFailureToast(t, "update", reason);
+ expect(rendered).toContain(reason);
+ expect(rendered).not.toContain("{{");
+ expect(rendered).not.toContain("{reason}");
+ });
+ });
+});
diff --git a/packages/views/autopilots/components/autopilot-dialog-toast.ts b/packages/views/autopilots/components/autopilot-dialog-toast.ts
new file mode 100644
index 0000000000..692c4353ef
--- /dev/null
+++ b/packages/views/autopilots/components/autopilot-dialog-toast.ts
@@ -0,0 +1,21 @@
+import type { TFunction } from "i18next";
+
+// Centralizes the partial-success toast formatting so the i18n keys and the
+// `{ reason }` placeholder live in one tested place. Without this, the
+// translation contract in `autopilot-dialog-i18n.test.ts` could pass while
+// the dialog's call-site silently passes the wrong variable name and ships
+// a literal `{{reason}}` to users.
+export function formatSchedulePartialFailureToast(
+ t: TFunction<"autopilots">,
+ kind: "create" | "update",
+ reason: string | null,
+): string {
+ if (reason) {
+ return kind === "create"
+ ? t(($) => $.dialog.toast_create_partial_with_reason, { reason })
+ : t(($) => $.dialog.toast_update_partial_with_reason, { reason });
+ }
+ return kind === "create"
+ ? t(($) => $.dialog.toast_create_partial)
+ : t(($) => $.dialog.toast_update_partial);
+}
diff --git a/packages/views/autopilots/components/autopilot-dialog.tsx b/packages/views/autopilots/components/autopilot-dialog.tsx
index 25927fa2c3..82faa655f2 100644
--- a/packages/views/autopilots/components/autopilot-dialog.tsx
+++ b/packages/views/autopilots/components/autopilot-dialog.tsx
@@ -62,6 +62,7 @@ import {
type TriggerFrequency,
} from "./trigger-config";
import { useT } from "../../i18n";
+import { formatSchedulePartialFailureToast } from "./autopilot-dialog-toast";
// ---------------------------------------------------------------------------
// Types
@@ -327,6 +328,7 @@ export function AutopilotDialog(props: AutopilotDialogProps) {
execution_mode: executionMode,
});
let triggerOk = true;
+ let triggerErrMessage: string | null = null;
let webhookTrigger: AutopilotTrigger | null = null;
try {
if (triggerKind === "webhook") {
@@ -342,8 +344,10 @@ export function AutopilotDialog(props: AutopilotDialogProps) {
timezone: triggerConfig.timezone,
});
}
- } catch {
+ } catch (err) {
triggerOk = false;
+ triggerErrMessage =
+ err instanceof Error && err.message ? err.message : null;
}
if (triggerKind === "webhook" && webhookTrigger) {
// Stay in the dialog and surface the URL inline so the user
@@ -353,8 +357,14 @@ export function AutopilotDialog(props: AutopilotDialogProps) {
return;
}
onOpenChange(false);
- if (triggerOk) toast.success(t(($) => $.dialog.toast_created));
- else toast.error(t(($) => $.dialog.toast_create_partial));
+ if (triggerOk) {
+ toast.success(t(($) => $.dialog.toast_created));
+ } else {
+ // Partial success: autopilot saved, schedule failed. Show the
+ // server-provided reason so the user can act on it (cron syntax
+ // error, conflict, etc.) instead of seeing a generic message.
+ toast.error(formatSchedulePartialFailureToast(t, "create", triggerErrMessage));
+ }
} else {
await updateAutopilot.mutateAsync({
id: props.autopilotId,
@@ -364,6 +374,7 @@ export function AutopilotDialog(props: AutopilotDialogProps) {
execution_mode: executionMode,
});
let scheduleOk = true;
+ let scheduleErrMessage: string | null = null;
// Skip the schedule sync when the autopilot's first trigger is a
// webhook — there's no cron to update there, and the schedule
// panel isn't even rendered for webhook autopilots.
@@ -385,19 +396,26 @@ export function AutopilotDialog(props: AutopilotDialogProps) {
timezone: triggerConfig.timezone,
});
}
- } catch {
+ } catch (err) {
scheduleOk = false;
+ scheduleErrMessage =
+ err instanceof Error && err.message ? err.message : null;
}
}
onOpenChange(false);
- if (scheduleOk) toast.success(t(($) => $.dialog.toast_updated));
- else toast.error(t(($) => $.dialog.toast_update_partial));
+ if (scheduleOk) {
+ toast.success(t(($) => $.dialog.toast_updated));
+ } else {
+ toast.error(formatSchedulePartialFailureToast(t, "update", scheduleErrMessage));
+ }
}
- } catch {
+ } catch (err) {
toast.error(
- isCreate
- ? t(($) => $.dialog.toast_create_failed)
- : t(($) => $.dialog.toast_update_failed),
+ err instanceof Error && err.message
+ ? err.message
+ : isCreate
+ ? t(($) => $.dialog.toast_create_failed)
+ : t(($) => $.dialog.toast_update_failed),
);
} finally {
setSubmitting(false);
diff --git a/packages/views/common/actor-issues-panel.tsx b/packages/views/common/actor-issues-panel.tsx
index 454964efdb..a42b56ab87 100644
--- a/packages/views/common/actor-issues-panel.tsx
+++ b/packages/views/common/actor-issues-panel.tsx
@@ -185,7 +185,14 @@ export function ActorIssuesPanel({
(issueId: string, updates: Pick<UpdateIssueRequest, "status" | "assignee_type" | "assignee_id" | "position">) => {
updateIssueMutation.mutate(
{ id: issueId, ...updates },
- { onError: () => toast.error(t(($) => $.page.move_failed)) },
+ {
+ onError: (err) =>
+ toast.error(
+ err instanceof Error && err.message
+ ? err.message
+ : t(($) => $.page.move_failed),
+ ),
+ },
);
},
[updateIssueMutation, t],
diff --git a/packages/views/editor/bubble-menu.tsx b/packages/views/editor/bubble-menu.tsx
index a425872454..018b92be7a 100644
--- a/packages/views/editor/bubble-menu.tsx
+++ b/packages/views/editor/bubble-menu.tsx
@@ -406,8 +406,12 @@ function CreateSubIssueButton({
)
.run();
toast.success(t(($) => $.bubble_menu.sub_issue.created, { identifier: newIssue.identifier }));
- } catch {
- toast.error(t(($) => $.bubble_menu.sub_issue.create_failed));
+ } catch (err) {
+ toast.error(
+ err instanceof Error && err.message
+ ? err.message
+ : t(($) => $.bubble_menu.sub_issue.create_failed),
+ );
} finally {
setPending(false);
}
diff --git a/packages/views/inbox/components/inbox-page.tsx b/packages/views/inbox/components/inbox-page.tsx
index e627f49596..8d7aa5573d 100644
--- a/packages/views/inbox/components/inbox-page.tsx
+++ b/packages/views/inbox/components/inbox-page.tsx
@@ -136,7 +136,12 @@ export function InboxPage() {
useEffect(() => {
if (!selectedId || selectedRead) return;
markReadMutate(selectedId, {
- onError: () => toast.error(t(($) => $.errors.mark_read_failed)),
+ onError: (err) =>
+ toast.error(
+ err instanceof Error && err.message
+ ? err.message
+ : t(($) => $.errors.mark_read_failed),
+ ),
});
}, [selectedId, selectedRead, markReadMutate, t]);
@@ -157,21 +162,36 @@ export function InboxPage() {
setSelectedKey(next ? (next.issue_id ?? next.id) : "");
}
archiveMutation.mutate(id, {
- onError: () => toast.error(t(($) => $.errors.archive_failed)),
+ onError: (err) =>
+ toast.error(
+ err instanceof Error && err.message
+ ? err.message
+ : t(($) => $.errors.archive_failed),
+ ),
});
};
// Batch operations
const handleMarkAllRead = () => {
markAllReadMutation.mutate(undefined, {
- onError: () => toast.error(t(($) => $.errors.mark_all_read_failed)),
+ onError: (err) =>
+ toast.error(
+ err instanceof Error && err.message
+ ? err.message
+ : t(($) => $.errors.mark_all_read_failed),
+ ),
});
};
const handleArchiveAll = () => {
setSelectedKey("");
archiveAllMutation.mutate(undefined, {
- onError: () => toast.error(t(($) => $.errors.archive_all_failed)),
+ onError: (err) =>
+ toast.error(
+ err instanceof Error && err.message
+ ? err.message
+ : t(($) => $.errors.archive_all_failed),
+ ),
});
};
@@ -179,14 +199,24 @@ export function InboxPage() {
const readKeys = items.filter((i) => i.read).map((i) => i.issue_id ?? i.id);
if (readKeys.includes(selectedKey)) setSelectedKey("");
archiveAllReadMutation.mutate(undefined, {
- onError: () => toast.error(t(($) => $.errors.archive_all_read_failed)),
+ onError: (err) =>
+ toast.error(
+ err instanceof Error && err.message
+ ? err.message
+ : t(($) => $.errors.archive_all_read_failed),
+ ),
});
};
const handleArchiveCompleted = () => {
setSelectedKey("");
archiveCompletedMutation.mutate(undefined, {
- onError: () => toast.error(t(($) => $.errors.archive_completed_failed)),
+ onError: (err) =>
+ toast.error(
+ err instanceof Error && err.message
+ ? err.message
+ : t(($) => $.errors.archive_completed_failed),
+ ),
});
};
diff --git a/packages/views/issues/actions/use-issue-actions.ts b/packages/views/issues/actions/use-issue-actions.ts
index 4d9fa8d7e5..a7404e20de 100644
--- a/packages/views/issues/actions/use-issue-actions.ts
+++ b/packages/views/issues/actions/use-issue-actions.ts
@@ -65,7 +65,14 @@ export function useIssueActions(issue: Issue | null): UseIssueActionsResult {
if (!issueId) return;
updateIssue.mutate(
{ id: issueId, ...updates },
- { onError: () => toast.error(t(($) => $.detail.update_failed)) },
+ {
+ onError: (err) =>
+ toast.error(
+ err instanceof Error && err.message
+ ? err.message
+ : t(($) => $.detail.update_failed),
+ ),
+ },
);
// Hint: assigning an agent to a backlog issue won't trigger execution
// until the issue is moved to an active status.
diff --git a/packages/views/issues/components/batch-action-toolbar.tsx b/packages/views/issues/components/batch-action-toolbar.tsx
index 262c9b6b36..b6e1461543 100644
--- a/packages/views/issues/components/batch-action-toolbar.tsx
+++ b/packages/views/issues/components/batch-action-toolbar.tsx
@@ -53,8 +53,12 @@ export function BatchActionToolbar({
try {
await batchUpdate.mutateAsync({ ids, updates });
toast.success(t(($) => $.batch.update_success, { count }));
- } catch {
- toast.error(t(($) => $.batch.update_failed));
+ } catch (err) {
+ toast.error(
+ err instanceof Error && err.message
+ ? err.message
+ : t(($) => $.batch.update_failed),
+ );
}
};
@@ -63,8 +67,12 @@ export function BatchActionToolbar({
await batchDelete.mutateAsync(ids);
clear();
toast.success(t(($) => $.batch.delete_success, { count }));
- } catch {
- toast.error(t(($) => $.batch.delete_failed));
+ } catch (err) {
+ toast.error(
+ err instanceof Error && err.message
+ ? err.message
+ : t(($) => $.batch.delete_failed),
+ );
} finally {
setDeleteOpen(false);
}
diff --git a/packages/views/issues/components/board-card.tsx b/packages/views/issues/components/board-card.tsx
index 54f8b49ab9..e8630151f1 100644
--- a/packages/views/issues/components/board-card.tsx
+++ b/packages/views/issues/components/board-card.tsx
@@ -81,7 +81,14 @@ export const BoardCardContent = memo(function BoardCardContent({
(updates: Partial<UpdateIssueRequest>) => {
updateIssueMutation.mutate(
{ id: issue.id, ...updates },
- { onError: () => toast.error(t(($) => $.card.update_failed)) },
+ {
+ onError: (err) =>
+ toast.error(
+ err instanceof Error && err.message
+ ? err.message
+ : t(($) => $.card.update_failed),
+ ),
+ },
);
},
[issue.id, updateIssueMutation, t],
diff --git a/packages/views/issues/components/comment-card.tsx b/packages/views/issues/components/comment-card.tsx
index e1fdf9f710..4940ec96eb 100644
--- a/packages/views/issues/components/comment-card.tsx
+++ b/packages/views/issues/components/comment-card.tsx
@@ -285,8 +285,12 @@ function CommentRow({
setEditing(false);
setPendingAttachments([]);
clearEditDraft(editDraftKey);
- } catch {
- toast.error(t(($) => $.comment.update_failed));
+ } catch (err) {
+ toast.error(
+ err instanceof Error && err.message
+ ? err.message
+ : t(($) => $.comment.update_failed),
+ );
}
};
@@ -515,8 +519,12 @@ function CommentCardImpl({
setEditing(false);
setParentPendingAttachments([]);
clearParentEditDraft(parentEditDraftKey);
- } catch {
- toast.error(t(($) => $.comment.update_failed));
+ } catch (err) {
+ toast.error(
+ err instanceof Error && err.message
+ ? err.message
+ : t(($) => $.comment.update_failed),
+ );
}
};
diff --git a/packages/views/issues/components/issue-detail.tsx b/packages/views/issues/components/issue-detail.tsx
index 8547170c33..e5324fb1a5 100644
--- a/packages/views/issues/components/issue-detail.tsx
+++ b/packages/views/issues/components/issue-detail.tsx
@@ -496,7 +496,14 @@ function SubIssueRow({ child }: { child: Issue }) {
(updates: Partial<UpdateIssueRequest>) => {
updateIssue.mutate(
{ id: child.id, ...updates },
- { onError: () => toast.error(t(($) => $.detail.update_failed)) },
+ {
+ onError: (err) =>
+ toast.error(
+ err instanceof Error && err.message
+ ? err.message
+ : t(($) => $.detail.update_failed),
+ ),
+ },
);
},
[child.id, updateIssue, t],
diff --git a/packages/views/issues/components/issues-page.tsx b/packages/views/issues/components/issues-page.tsx
index c8b51957f5..f93e06792b 100644
--- a/packages/views/issues/components/issues-page.tsx
+++ b/packages/views/issues/components/issues-page.tsx
@@ -121,7 +121,14 @@ export function IssuesPage() {
(issueId: string, updates: Pick<UpdateIssueRequest, "status" | "assignee_type" | "assignee_id" | "position">) => {
updateIssueMutation.mutate(
{ id: issueId, ...updates },
- { onError: () => toast.error(t(($) => $.page.move_failed)) },
+ {
+ onError: (err) =>
+ toast.error(
+ err instanceof Error && err.message
+ ? err.message
+ : t(($) => $.page.move_failed),
+ ),
+ },
);
},
[updateIssueMutation, t],
diff --git a/packages/views/issues/hooks/use-issue-timeline.ts b/packages/views/issues/hooks/use-issue-timeline.ts
index 54d34f3d54..1d92ee1d30 100644
--- a/packages/views/issues/hooks/use-issue-timeline.ts
+++ b/packages/views/issues/hooks/use-issue-timeline.ts
@@ -265,8 +265,12 @@ export function useIssueTimeline(issueId: string, userId?: string) {
setSubmitting(true);
try {
await createComment({ content, attachmentIds });
- } catch {
- toast.error(t(($) => $.comment.send_failed));
+ } catch (err) {
+ toast.error(
+ err instanceof Error && err.message
+ ? err.message
+ : t(($) => $.comment.send_failed),
+ );
} finally {
setSubmitting(false);
}
@@ -284,8 +288,12 @@ export function useIssueTimeline(issueId: string, userId?: string) {
parentId,
attachmentIds,
});
- } catch {
- toast.error(t(($) => $.comment.send_reply_failed));
+ } catch (err) {
+ toast.error(
+ err instanceof Error && err.message
+ ? err.message
+ : t(($) => $.comment.send_reply_failed),
+ );
}
},
[userId, createComment, t],
@@ -295,8 +303,12 @@ export function useIssueTimeline(issueId: string, userId?: string) {
async (commentId: string, content: string, attachmentIds?: string[]) => {
try {
await updateComment({ commentId, content, attachmentIds });
- } catch {
- toast.error(t(($) => $.comment.update_failed));
+ } catch (err) {
+ toast.error(
+ err instanceof Error && err.message
+ ? err.message
+ : t(($) => $.comment.update_failed),
+ );
}
},
[updateComment, t],
@@ -306,8 +318,12 @@ export function useIssueTimeline(issueId: string, userId?: string) {
async (commentId: string) => {
try {
await deleteCommentAsync(commentId);
- } catch {
- toast.error(t(($) => $.comment.delete_failed));
+ } catch (err) {
+ toast.error(
+ err instanceof Error && err.message
+ ? err.message
+ : t(($) => $.comment.delete_failed),
+ );
}
},
[deleteCommentAsync, t],
@@ -317,11 +333,13 @@ export function useIssueTimeline(issueId: string, userId?: string) {
async (commentId: string, resolved: boolean) => {
try {
await resolveCommentAsync({ commentId, resolved });
- } catch {
+ } catch (err) {
toast.error(
- resolved
- ? t(($) => $.comment.resolve.resolve_failed)
- : t(($) => $.comment.resolve.unresolve_failed),
+ err instanceof Error && err.message
+ ? err.message
+ : resolved
+ ? t(($) => $.comment.resolve.resolve_failed)
+ : t(($) => $.comment.resolve.unresolve_failed),
);
}
},
diff --git a/packages/views/locales/en/autopilots.json b/packages/views/locales/en/autopilots.json
index 03c9261865..f0600eec3f 100644
--- a/packages/views/locales/en/autopilots.json
+++ b/packages/views/locales/en/autopilots.json
@@ -186,9 +186,11 @@
"saving": "Saving...",
"toast_created": "Autopilot created",
"toast_create_partial": "Autopilot created, but schedule failed to save",
+ "toast_create_partial_with_reason": "Autopilot created, but schedule failed to save: {{reason}}",
"toast_create_failed": "Failed to create autopilot",
"toast_updated": "Autopilot updated",
"toast_update_partial": "Autopilot updated, but schedule failed to save",
+ "toast_update_partial_with_reason": "Autopilot updated, but schedule failed to save: {{reason}}",
"toast_update_failed": "Failed to update autopilot",
"section_agent": "Agent",
"select_agent": "Select agent",
diff --git a/packages/views/locales/en/modals.json b/packages/views/locales/en/modals.json
index 5878c8ca59..57150a48f7 100644
--- a/packages/views/locales/en/modals.json
+++ b/packages/views/locales/en/modals.json
@@ -122,6 +122,8 @@
"toast_created": "Issue created",
"view_issue": "View issue",
"toast_failed": "Failed to create issue",
+ "toast_duplicate_title": "Duplicate issue",
+ "toast_duplicate_view": "View existing issue",
"toast_link_subissues_all_failed": "Failed to link sub-issues",
"toast_link_subissues_partial": "Failed to link {{failed}} of {{total}} sub-issues",
"switch_to_agent": "Switch to Agent",
diff --git a/packages/views/locales/zh-Hans/autopilots.json b/packages/views/locales/zh-Hans/autopilots.json
index a8ced69351..4db0f394d3 100644
--- a/packages/views/locales/zh-Hans/autopilots.json
+++ b/packages/views/locales/zh-Hans/autopilots.json
@@ -186,9 +186,11 @@
"saving": "保存中...",
"toast_created": "已创建自动化",
"toast_create_partial": "自动化已创建,但时间表保存失败",
+ "toast_create_partial_with_reason": "自动化已创建,但时间表保存失败:{{reason}}",
"toast_create_failed": "创建自动化失败",
"toast_updated": "已更新自动化",
"toast_update_partial": "自动化已更新,但时间表保存失败",
+ "toast_update_partial_with_reason": "自动化已更新,但时间表保存失败:{{reason}}",
"toast_update_failed": "更新自动化失败",
"section_agent": "智能体",
"select_agent": "选择智能体",
diff --git a/packages/views/locales/zh-Hans/modals.json b/packages/views/locales/zh-Hans/modals.json
index 4eb7aa6dde..2b8d106656 100644
--- a/packages/views/locales/zh-Hans/modals.json
+++ b/packages/views/locales/zh-Hans/modals.json
@@ -122,6 +122,8 @@
"toast_created": "已创建 issue",
"view_issue": "查看 issue",
"toast_failed": "创建 issue 失败",
+ "toast_duplicate_title": "已存在同名 issue",
+ "toast_duplicate_view": "查看已有 issue",
"toast_link_subissues_all_failed": "关联子 issue 失败",
"toast_link_subissues_partial": "{{total}} 个子 issue 中有 {{failed}} 个关联失败",
"switch_to_agent": "切换到智能体",
diff --git a/packages/views/modals/add-child-issue.tsx b/packages/views/modals/add-child-issue.tsx
index f7ec9d0768..9a2ee736de 100644
--- a/packages/views/modals/add-child-issue.tsx
+++ b/packages/views/modals/add-child-issue.tsx
@@ -50,7 +50,14 @@ export function AddChildIssueModal({
onSelect={(selected) => {
updateIssue.mutate(
{ id: selected.id, parent_issue_id: issueId },
- { onError: () => toast.error(t(($) => $.add_child.toast_failed)) },
+ {
+ onError: (err) =>
+ toast.error(
+ err instanceof Error && err.message
+ ? err.message
+ : t(($) => $.add_child.toast_failed),
+ ),
+ },
);
toast.success(t(($) => $.add_child.toast_success, { identifier: selected.identifier }));
}}
diff --git a/packages/views/modals/backlog-agent-hint.tsx b/packages/views/modals/backlog-agent-hint.tsx
index 76be3c3f65..38cc27f97e 100644
--- a/packages/views/modals/backlog-agent-hint.tsx
+++ b/packages/views/modals/backlog-agent-hint.tsx
@@ -29,7 +29,14 @@ export function BacklogAgentHintModal({
if (issueId) {
updateIssue.mutate(
{ id: issueId, status: "todo" },
- { onError: () => toast.error(t(($) => $.backlog_hint.toast_status_failed)) },
+ {
+ onError: (err) =>
+ toast.error(
+ err instanceof Error && err.message
+ ? err.message
+ : t(($) => $.backlog_hint.toast_status_failed),
+ ),
+ },
);
}
onClose();
diff --git a/packages/views/modals/create-issue.test.tsx b/packages/views/modals/create-issue.test.tsx
index 39085f9ea9..b7996c811a 100644
--- a/packages/views/modals/create-issue.test.tsx
+++ b/packages/views/modals/create-issue.test.tsx
@@ -1,6 +1,6 @@
import { forwardRef, useImperativeHandle, useRef, useState, type ReactNode } from "react";
import { describe, it, expect, vi, beforeEach } from "vitest";
-import { render, screen, waitFor } from "@testing-library/react";
+import { fireEvent, render, screen, waitFor } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { I18nProvider } from "@multica/core/i18n/react";
@@ -96,9 +96,45 @@ vi.mock("@multica/core/hooks/use-file-upload", () => ({
useFileUpload: () => ({ uploadWithToast: vi.fn() }),
}));
-vi.mock("@multica/core/api", () => ({
- api: {},
-}));
+// Hoisted ApiError class so both the vi.mock factory and the tests below
+// can construct/instanceof-check the same identity. vi.mock is hoisted, so
+// a normal `class` declaration above it would still be in the TDZ at mock
+// evaluation time.
+const { ApiError } = vi.hoisted(() => {
+ class ApiErrorImpl extends Error {
+ readonly status: number;
+ readonly statusText: string;
+ readonly body?: unknown;
+ constructor(message: string, status: number, statusText: string, body?: unknown) {
+ super(message);
+ this.name = "ApiError";
+ this.status = status;
+ this.statusText = statusText;
+ this.body = body;
+ }
+ }
+ return { ApiError: ApiErrorImpl };
+});
+
+vi.mock("@multica/core/api", async () => {
+ // Pull real `parseWithFallback` + `DuplicateIssueErrorBodySchema` from the
+ // schema modules so the drift-fallback branch in create-issue.tsx runs the
+ // actual validation logic (not a stub). Only `ApiError` is local — the
+ // component imports it from this module and the cross-realm `instanceof`
+ // check requires a single class identity.
+ const { parseWithFallback } = await vi.importActual<typeof import("@multica/core/api/schema")>(
+ "@multica/core/api/schema",
+ );
+ const { DuplicateIssueErrorBodySchema } = await vi.importActual<
+ typeof import("@multica/core/api/schemas")
+ >("@multica/core/api/schemas");
+ return {
+ api: {},
+ ApiError,
+ parseWithFallback,
+ DuplicateIssueErrorBodySchema,
+ };
+});
vi.mock("../editor", () => {
const ContentEditor = forwardRef(({ defaultValue, onUpdate, placeholder }: any, ref: any) => {
@@ -285,7 +321,9 @@ describe("CreateIssueModal", () => {
renderModal(<CreateIssueModal onClose={onClose} />);
- await user.type(screen.getByPlaceholderText("Issue title"), " Ship create issue regression coverage ");
+ fireEvent.change(screen.getByPlaceholderText("Issue title"), {
+ target: { value: " Ship create issue regression coverage " },
+ });
await user.click(screen.getByRole("button", { name: "Create Issue" }));
await waitFor(() => {
@@ -400,6 +438,94 @@ describe("CreateIssueModal", () => {
// Manual → agent must forward the picked project so the new modal pins to
// the same target. Without this the agent panel re-seeds from its own
// persisted `lastProjectId` and silently routes the issue to a stale one.
+ // Reporter scenario: backend rejects same-titled create with a 409 +
+ // structured duplicate body. The user should land on a duplicate toast
+ // pointing at the existing issue, not a generic "create failed" message.
+ it("shows duplicate-issue toast with a working view-existing link", async () => {
+ const user = userEvent.setup();
+ const onClose = vi.fn();
+ mockCreateIssue.mockRejectedValue(
+ new ApiError("An active issue with this title already exists: MUL-7 – Login bug", 409, "Conflict", {
+ code: "active_duplicate_issue",
+ error: "An active issue with this title already exists: MUL-7 – Login bug",
+ issue: {
+ id: "issue-dup",
+ identifier: "MUL-7",
+ title: "Login bug",
+ },
+ }),
+ );
+
+ renderModal(<CreateIssueModal onClose={onClose} />);
+ await user.type(screen.getByPlaceholderText("Issue title"), "Login bug");
+ await user.click(screen.getByRole("button", { name: "Create Issue" }));
+
+ await waitFor(() => expect(mockToastCustom).toHaveBeenCalledTimes(1));
+ expect(mockToastError).not.toHaveBeenCalled();
+ expect(onClose).not.toHaveBeenCalled();
+
+ const renderToast = mockToastCustom.mock.calls[0]?.[0];
+ expect(typeof renderToast).toBe("function");
+ render(renderToast("toast-dup"));
+
+ expect(screen.getByText("Duplicate issue")).toBeInTheDocument();
+ expect(screen.getByText(/MUL-7/)).toBeInTheDocument();
+ expect(screen.getByText(/Login bug/)).toBeInTheDocument();
+
+ await user.click(screen.getByRole("button", { name: "View existing issue" }));
+ expect(mockPush).toHaveBeenCalledWith("/ws-test/issues/issue-dup");
+ expect(mockToastDismiss).toHaveBeenCalledWith("toast-dup");
+ });
+
+ // Schema drift safety: server returns a 409 with a body that doesn't match
+ // the duplicate schema (renamed code, missing issue object, etc.). UI must
+ // not throw — it must fall back to a normal error toast carrying the
+ // backend message so the user still sees a useful reason.
+ it("falls back to a normal error toast when a 409 body does not match the duplicate schema", async () => {
+ const user = userEvent.setup();
+ mockCreateIssue.mockRejectedValue(
+ new ApiError("Backend says title is taken", 409, "Conflict", {
+ code: "renamed_duplicate_marker",
+ }),
+ );
+
+ renderModal(<CreateIssueModal onClose={vi.fn()} />);
+ await user.type(screen.getByPlaceholderText("Issue title"), "Login bug");
+ await user.click(screen.getByRole("button", { name: "Create Issue" }));
+
+ await waitFor(() => expect(mockToastError).toHaveBeenCalledTimes(1));
+ expect(mockToastError).toHaveBeenCalledWith("Backend says title is taken");
+ expect(mockToastCustom).not.toHaveBeenCalled();
+ });
+
+ // Non-409 errors with a real message: surface the backend reason rather
+ // than the generic i18n fallback. This is the whole point of the issue.
+ it("surfaces err.message verbatim for non-duplicate errors", async () => {
+ const user = userEvent.setup();
+ mockCreateIssue.mockRejectedValue(new Error("Server is overloaded, try again"));
+
+ renderModal(<CreateIssueModal onClose={vi.fn()} />);
+ await user.type(screen.getByPlaceholderText("Issue title"), "Anything");
+ await user.click(screen.getByRole("button", { name: "Create Issue" }));
+
+ await waitFor(() => expect(mockToastError).toHaveBeenCalledTimes(1));
+ expect(mockToastError).toHaveBeenCalledWith("Server is overloaded, try again");
+ });
+
+ // Non-Error throws (string, plain object) have no `.message`. Fall back to
+ // the i18n key so the user always sees something readable.
+ it("falls back to the generic toast when the thrown value is not an Error", async () => {
+ const user = userEvent.setup();
+ mockCreateIssue.mockRejectedValue("network exploded");
+
+ renderModal(<CreateIssueModal onClose={vi.fn()} />);
+ await user.type(screen.getByPlaceholderText("Issue title"), "Anything");
+ await user.click(screen.getByRole("button", { name: "Create Issue" }));
+
+ await waitFor(() => expect(mockToastError).toHaveBeenCalledTimes(1));
+ expect(mockToastError).toHaveBeenCalledWith("Failed to create issue");
+ });
+
it("forwards the picked project when switching to agent mode", async () => {
const user = userEvent.setup();
const onSwitchMode = vi.fn();
diff --git a/packages/views/modals/create-issue.tsx b/packages/views/modals/create-issue.tsx
index 14979506e9..fb5060b50c 100644
--- a/packages/views/modals/create-issue.tsx
+++ b/packages/views/modals/create-issue.tsx
@@ -4,6 +4,7 @@ import { useState, useRef } from "react";
import { useQuery } from "@tanstack/react-query";
import { useNavigation } from "../navigation";
import {
+ AlertTriangle,
ArrowDown,
ArrowLeftRight,
ArrowUp,
@@ -43,7 +44,13 @@ import { useQuickCreateStore } from "@multica/core/issues/stores/quick-create-st
import { issueDetailOptions } from "@multica/core/issues/queries";
import { useCreateIssue, useUpdateIssue } from "@multica/core/issues/mutations";
import { useFileUpload } from "@multica/core/hooks/use-file-upload";
-import { api } from "@multica/core/api";
+import {
+ api,
+ ApiError,
+ DuplicateIssueErrorBodySchema,
+ type DuplicateIssueErrorBody,
+ parseWithFallback,
+} from "@multica/core/api";
import { FileUploadButton } from "@multica/ui/components/common/file-upload-button";
import { PillButton } from "../common/pill-button";
import { IssuePickerModal } from "./issue-picker-modal";
@@ -211,6 +218,15 @@ export function ManualCreatePanel({
}),
),
);
+ // Aggregate fan-out: N independent requests can fail for N different
+ // reasons. The user-facing toast stays count-based (any single
+ // err.message would mislead), but log each rejection so developers
+ // still have signal in dev-tools / Sentry.
+ for (const result of results) {
+ if (result.status === "rejected") {
+ console.error("[create-issue] sub-issue link failed", result.reason);
+ }
+ }
const failed = results.filter((r) => r.status === "rejected").length;
if (failed > 0) {
toast.error(
@@ -265,8 +281,55 @@ export function ManualCreatePanel({
</div>
), { duration: 5000 });
}
- } catch {
- toast.error(t(($) => $.create_issue.toast_failed));
+ } catch (err) {
+ // Duplicate-issue is the only structured 409 the create endpoint
+ // returns. We schema-guard the body (ApiError.body is `unknown`) so a
+ // future server-side rename / drop of `code` / `issue` degrades to the
+ // normal error toast instead of throwing inside the toast renderer.
+ if (err instanceof ApiError && err.status === 409) {
+ const dup = parseWithFallback<DuplicateIssueErrorBody | null>(
+ err.body,
+ DuplicateIssueErrorBodySchema,
+ null,
+ { endpoint: "POST /api/workspaces/:wsId/issues (active_duplicate_issue)" },
+ );
+ if (dup) {
+ toast.custom(
+ (toastId) => (
+ <div className="bg-popover text-popover-foreground border rounded-lg shadow-lg p-4 w-[360px]">
+ <div className="flex items-center gap-2 mb-2">
+ <div className="flex items-center justify-center size-5 rounded-full bg-amber-500/15 text-amber-500">
+ <AlertTriangle className="size-3" />
+ </div>
+ <span className="text-sm font-medium">
+ {t(($) => $.create_issue.toast_duplicate_title)}
+ </span>
+ </div>
+ <div className="flex items-center gap-2 text-sm text-muted-foreground ml-7">
+ <span className="truncate">{dup.issue.identifier} – {dup.issue.title}</span>
+ </div>
+ <button
+ type="button"
+ className="ml-7 mt-2 text-sm text-primary hover:underline cursor-pointer"
+ onClick={() => {
+ router.push(p.issueDetail(dup.issue.id));
+ toast.dismiss(toastId);
+ }}
+ >
+ {t(($) => $.create_issue.toast_duplicate_view)}
+ </button>
+ </div>
+ ),
+ { duration: 5000 },
+ );
+ return;
+ }
+ }
+ toast.error(
+ err instanceof Error && err.message
+ ? err.message
+ : t(($) => $.create_issue.toast_failed),
+ );
} finally {
setSubmitting(false);
}
@@ -312,7 +375,14 @@ export function ManualCreatePanel({
onMoveToTodo={() => {
updateIssueMutation.mutate(
{ id: backlogHintIssueId, status: "todo" },
- { onError: () => toast.error(t(($) => $.backlog_hint.toast_status_failed)) },
+ {
+ onError: (err) =>
+ toast.error(
+ err instanceof Error && err.message
+ ? err.message
+ : t(($) => $.backlog_hint.toast_status_failed),
+ ),
+ },
);
setBacklogHintIssueId(null);
onClose();
diff --git a/packages/views/modals/create-project.tsx b/packages/views/modals/create-project.tsx
index b130b887d7..43e3a1886c 100644
--- a/packages/views/modals/create-project.tsx
+++ b/packages/views/modals/create-project.tsx
@@ -188,8 +188,12 @@ export function CreateProjectModal({ onClose }: { onClose: () => void }) {
onClose();
toast.success(t(($) => $.create_project.toast_created));
router.push(wsPaths.projectDetail(project.id));
- } catch {
- toast.error(t(($) => $.create_project.toast_failed));
+ } catch (err) {
+ toast.error(
+ err instanceof Error && err.message
+ ? err.message
+ : t(($) => $.create_project.toast_failed),
+ );
} finally {
setSubmitting(false);
}
diff --git a/packages/views/modals/delete-issue-confirm.tsx b/packages/views/modals/delete-issue-confirm.tsx
index b3bc7af634..ffe254d9de 100644
--- a/packages/views/modals/delete-issue-confirm.tsx
+++ b/packages/views/modals/delete-issue-confirm.tsx
@@ -38,8 +38,12 @@ export function DeleteIssueConfirmModal({
toast.success(t(($) => $.delete_issue.toast_deleted));
onClose();
if (navigateTo) navigation.push(navigateTo);
- } catch {
- toast.error(t(($) => $.delete_issue.toast_delete_failed));
+ } catch (err) {
+ toast.error(
+ err instanceof Error && err.message
+ ? err.message
+ : t(($) => $.delete_issue.toast_delete_failed),
+ );
setDeleting(false);
}
};
diff --git a/packages/views/modals/quick-create-issue.tsx b/packages/views/modals/quick-create-issue.tsx
index 891809ad1e..7da62199f6 100644
--- a/packages/views/modals/quick-create-issue.tsx
+++ b/packages/views/modals/quick-create-issue.tsx
@@ -333,7 +333,11 @@ export function AgentCreatePanel({
return;
}
}
- setError(t(($) => $.create_issue.agent.error_unknown));
+ setError(
+ e instanceof Error && e.message
+ ? e.message
+ : t(($) => $.create_issue.agent.error_unknown),
+ );
} finally {
setSubmitting(false);
}
diff --git a/packages/views/modals/set-parent-issue.tsx b/packages/views/modals/set-parent-issue.tsx
index eb4c4b3c2a..d6a392cee7 100644
--- a/packages/views/modals/set-parent-issue.tsx
+++ b/packages/views/modals/set-parent-issue.tsx
@@ -39,7 +39,14 @@ export function SetParentIssueModal({
onSelect={(selected) => {
updateIssue.mutate(
{ id: issueId, parent_issue_id: selected.id },
- { onError: () => toast.error(t(($) => $.set_parent.toast_failed)) },
+ {
+ onError: (err) =>
+ toast.error(
+ err instanceof Error && err.message
+ ? err.message
+ : t(($) => $.set_parent.toast_failed),
+ ),
+ },
);
toast.success(t(($) => $.set_parent.toast_success, { identifier: selected.identifier }));
}}
diff --git a/packages/views/my-issues/components/my-issues-page.tsx b/packages/views/my-issues/components/my-issues-page.tsx
index e4c2f150cc..9a3dc6426b 100644
--- a/packages/views/my-issues/components/my-issues-page.tsx
+++ b/packages/views/my-issues/components/my-issues-page.tsx
@@ -136,7 +136,14 @@ export function MyIssuesPage() {
(issueId: string, updates: Pick<UpdateIssueRequest, "status" | "assignee_type" | "assignee_id" | "position">) => {
updateIssueMutation.mutate(
{ id: issueId, ...updates },
- { onError: () => toast.error(t(($) => $.errors.move_failed)) },
+ {
+ onError: (err) =>
+ toast.error(
+ err instanceof Error && err.message
+ ? err.message
+ : t(($) => $.errors.move_failed),
+ ),
+ },
);
},
[updateIssueMutation, t],
diff --git a/packages/views/onboarding/steps/step-workspace.tsx b/packages/views/onboarding/steps/step-workspace.tsx
index 3d91063155..3ccd5dec48 100644
--- a/packages/views/onboarding/steps/step-workspace.tsx
+++ b/packages/views/onboarding/steps/step-workspace.tsx
@@ -139,7 +139,11 @@ export function StepWorkspace({
toast.error(t(($) => $.step_workspace.slug_conflict_toast));
return;
}
- toast.error(t(($) => $.step_workspace.create_failed_toast));
+ toast.error(
+ error instanceof Error && error.message
+ ? error.message
+ : t(($) => $.step_workspace.create_failed_toast),
+ );
},
},
);
diff --git a/packages/views/projects/components/project-detail.tsx b/packages/views/projects/components/project-detail.tsx
index 4049a30120..585d489d8c 100644
--- a/packages/views/projects/components/project-detail.tsx
+++ b/packages/views/projects/components/project-detail.tsx
@@ -149,7 +149,14 @@ function ProjectIssuesContent({
(issueId: string, updates: Pick<UpdateIssueRequest, "status" | "assignee_type" | "assignee_id" | "position">) => {
updateIssueMutation.mutate(
{ id: issueId, ...updates },
- { onError: () => toast.error(t(($) => $.detail.toast_move_issue_failed)) },
+ {
+ onError: (err) =>
+ toast.error(
+ err instanceof Error && err.message
+ ? err.message
+ : t(($) => $.detail.toast_move_issue_failed),
+ ),
+ },
);
},
[updateIssueMutation, t],
diff --git a/packages/views/projects/components/project-resources-section.tsx b/packages/views/projects/components/project-resources-section.tsx
index c4c0244d03..8e9f29544c 100644
--- a/packages/views/projects/components/project-resources-section.tsx
+++ b/packages/views/projects/components/project-resources-section.tsx
@@ -69,8 +69,12 @@ export function ProjectResourcesSection({ projectId }: { projectId: string }) {
try {
await deleteResource.mutateAsync(resource.id);
toast.success(t(($) => $.resources.toast_removed));
- } catch {
- toast.error(t(($) => $.resources.toast_remove_failed));
+ } catch (err) {
+ toast.error(
+ err instanceof Error && err.message
+ ? err.message
+ : t(($) => $.resources.toast_remove_failed),
+ );
}
};
diff --git a/packages/views/runtimes/components/runtime-detail.tsx b/packages/views/runtimes/components/runtime-detail.tsx
index 5734f13419..0d876b6c65 100644
--- a/packages/views/runtimes/components/runtime-detail.tsx
+++ b/packages/views/runtimes/components/runtime-detail.tsx
@@ -611,8 +611,12 @@ function VisibilityEditor({ runtime }: { runtime: AgentRuntime }) {
visibility: t(($) => $.detail.visibility_label[next]),
}),
),
- onError: () =>
- toast.error(t(($) => $.detail.visibility_toast_failed)),
+ onError: (err) =>
+ toast.error(
+ err instanceof Error && err.message
+ ? err.message
+ : t(($) => $.detail.visibility_toast_failed),
+ ),
},
);
};
@@ -709,8 +713,12 @@ function TimezoneEditor({ runtime }: { runtime: AgentRuntime }) {
{
onSuccess: () =>
toast.success(t(($) => $.detail.timezone_toast_updated, { tz: next })),
- onError: () =>
- toast.error(t(($) => $.detail.timezone_toast_failed)),
+ onError: (err) =>
+ toast.error(
+ err instanceof Error && err.message
+ ? err.message
+ : t(($) => $.detail.timezone_toast_failed),
+ ),
},
);
};
diff --git a/packages/views/settings/components/notifications-tab.tsx b/packages/views/settings/components/notifications-tab.tsx
index a2e7698328..6885ed9714 100644
--- a/packages/views/settings/components/notifications-tab.tsx
+++ b/packages/views/settings/components/notifications-tab.tsx
@@ -39,7 +39,12 @@ export function NotificationsTab() {
delete updated[key];
}
mutation.mutate(updated, {
- onError: () => toast.error(t(($) => $.notifications.toast_failed)),
+ onError: (err) =>
+ toast.error(
+ err instanceof Error && err.message
+ ? err.message
+ : t(($) => $.notifications.toast_failed),
+ ),
});
};
diff --git a/packages/views/squads/components/squad-detail-page.tsx b/packages/views/squads/components/squad-detail-page.tsx
index 48d97a946f..3fe3391a58 100644
--- a/packages/views/squads/components/squad-detail-page.tsx
+++ b/packages/views/squads/components/squad-detail-page.tsx
@@ -120,13 +120,15 @@ export function SquadDetailPage() {
role: input.role?.trim() || undefined,
}),
onSuccess: () => { refetchMembers(); toast.success("Member added"); },
- onError: () => toast.error("Failed to add member"),
+ onError: (err) =>
+ toast.error(err instanceof Error && err.message ? err.message : "Failed to add member"),
});
const removeMemberMut = useMutation({
mutationFn: (m: SquadMember) => api.removeSquadMember(squadId, { member_type: m.member_type, member_id: m.member_id }),
onSuccess: () => { refetchMembers(); toast.success("Member removed"); },
- onError: () => toast.error("Failed to remove member"),
+ onError: (err) =>
+ toast.error(err instanceof Error && err.message ? err.message : "Failed to remove member"),
});
const updateRoleMut = useMutation({
@@ -137,7 +139,8 @@ export function SquadDetailPage() {
role: input.role,
}),
onSuccess: () => { refetchMembers(); toast.success("Role updated"); },
- onError: () => toast.error("Failed to update role"),
+ onError: (err) =>
+ toast.error(err instanceof Error && err.message ? err.message : "Failed to update role"),
});
const setLeaderMut = useMutation({
@@ -148,13 +151,15 @@ export function SquadDetailPage() {
queryClient.invalidateQueries({ queryKey: workspaceKeys.squads(wsId) });
toast.success("Leader updated");
},
- onError: () => toast.error("Failed to update leader"),
+ onError: (err) =>
+ toast.error(err instanceof Error && err.message ? err.message : "Failed to update leader"),
});
const deleteMut = useMutation({
mutationFn: () => api.deleteSquad(squadId),
onSuccess: () => { queryClient.invalidateQueries({ queryKey: workspaceKeys.squads(wsId) }); push(p.squads()); toast.success("Squad archived"); },
- onError: () => toast.error("Failed to archive squad"),
+ onError: (err) =>
+ toast.error(err instanceof Error && err.message ? err.message : "Failed to archive squad"),
});
// CreateAgentDialog's onCreate contract: hit POST /api/agents and
diff --git a/packages/views/workspace/create-workspace-form.tsx b/packages/views/workspace/create-workspace-form.tsx
index 13b39401e3..121632f02f 100644
--- a/packages/views/workspace/create-workspace-form.tsx
+++ b/packages/views/workspace/create-workspace-form.tsx
@@ -67,7 +67,11 @@ export function CreateWorkspaceForm({ onSuccess }: CreateWorkspaceFormProps) {
toast.error(t(($) => $.create_form.errors.slug_conflict_toast));
return;
}
- toast.error(t(($) => $.create_form.errors.create_failed));
+ toast.error(
+ error instanceof Error && error.message
+ ? error.message
+ : t(($) => $.create_form.errors.create_failed),
+ );
},
},
);