diff --git a/ui/src/captures/CapturesList.vue b/ui/src/captures/CapturesList.vue index caee58d2b..c94306814 100644 --- a/ui/src/captures/CapturesList.vue +++ b/ui/src/captures/CapturesList.vue @@ -17,6 +17,7 @@ import { TableHeader, TableRow, } from "@/components/ui/table"; +import { errors } from "@/copy/errors"; import CaptureRow from "./CaptureRow.vue"; import { captures, enabled, error, loading } from "./state"; @@ -33,7 +34,7 @@ import { captures, enabled, error, loading } from "./state"; what the server said rather than borrowing an empty state. --> - Archie is not responding + {{ errors.captures.list.unresponsive }} {{ error }} diff --git a/ui/src/captures/event-type-state.ts b/ui/src/captures/event-type-state.ts index 3ba25cb7e..5b56e8997 100644 --- a/ui/src/captures/event-type-state.ts +++ b/ui/src/captures/event-type-state.ts @@ -1,7 +1,8 @@ import { ref } from "vue"; import { useEventsStore } from "@/stores/events"; -import { api } from "@/lib/api"; +import { errors } from "@/copy/errors"; +import { api, describeError } from "@/lib/api"; import { captures } from "./state"; import { cleanRule, @@ -61,7 +62,7 @@ export async function loadEventTypes(): Promise { eventTypesError.value = null; } catch (err) { if (current !== generation) return; - eventTypesError.value = (err as Error).message || String(err); + eventTypesError.value = describeError(err, errors.common.unknown); } finally { eventTypesLoading.value = false; } @@ -147,7 +148,7 @@ export async function saveDraft(): Promise { draft.value = null; await loadEventTypes(); } catch (err) { - saveError.value = (err as Error).message || String(err); + saveError.value = describeError(err, errors.common.unknown); } finally { saving.value = false; } @@ -164,6 +165,6 @@ export async function confirmDelete(): Promise { await api.eventTypeDelete(t.id); await loadEventTypes(); } catch (err) { - eventTypesError.value = (err as Error).message || String(err); + eventTypesError.value = describeError(err, errors.common.unknown); } } diff --git a/ui/src/captures/state.ts b/ui/src/captures/state.ts index 429184288..26d2116e6 100644 --- a/ui/src/captures/state.ts +++ b/ui/src/captures/state.ts @@ -1,6 +1,7 @@ import { ref } from "vue"; -import { api } from "@/lib/api"; +import { errors } from "@/copy/errors"; +import { api, describeError } from "@/lib/api"; import { keepRows } from "@/lib/keep-unchanged"; import { useLiveResource } from "@/stores/session"; import { loadEventTypes } from "./event-type-state"; @@ -75,7 +76,7 @@ export async function load(): Promise { if (current !== generation) return; // The server's own message is the only part of a failure an operator can // act on, so it is what the list says instead of the captures. - error.value = (err as Error).message || String(err); + error.value = describeError(err, errors.common.unknown); } finally { loading.value = false; } diff --git a/ui/src/channels/ChannelsPage.vue b/ui/src/channels/ChannelsPage.vue index edcd31ebd..988f39926 100644 --- a/ui/src/channels/ChannelsPage.vue +++ b/ui/src/channels/ChannelsPage.vue @@ -18,7 +18,8 @@ import { TagsInputItemDelete, TagsInputItemText, } from "@/components/ui/tags-input"; -import { api } from "@/lib/api"; +import { errors } from "@/copy/errors"; +import { api, describeError } from "@/lib/api"; import OptionSelect from "@/workflows/OptionSelect.vue"; import { useOrgStore, type Identity } from "@/stores/org"; import { Section } from "@/components/ui/section"; @@ -72,13 +73,13 @@ async function loadAgents(): Promise { agents.value = response.agents.filter((agent) => agent.lifecycle === "active"); } catch (cause) { if (current !== agentsGeneration) return; - agentsError.value = String((cause as Error).message || cause); + agentsError.value = describeError(cause, errors.common.unknown); } } const agentOptions = computed(() => { const current = chat.value?.agent ?? ""; const options = agents.value.map((agent) => ({ value: agent.id, label: agent.display_name })); - return current && !agents.value.some((agent) => agent.id === current) ? [{ value: current, label: `${current} (unknown)`, disabled: true }, ...options] : options; + return current && !agents.value.some((agent) => agent.id === current) ? [{ value: current, label: errors.channels.agents.unknown(current), disabled: true }, ...options] : options; }); const statuses = ref([]); @@ -151,7 +152,7 @@ function setAllowedUsers(ids: string[]) { - Couldn't load channel status + {{ errors.channels.status.load }} diff --git a/ui/src/copy/errors/captures.ts b/ui/src/copy/errors/captures.ts new file mode 100644 index 000000000..f4afd845a --- /dev/null +++ b/ui/src/copy/errors/captures.ts @@ -0,0 +1,5 @@ +export const captures = { + list: { + unresponsive: "Archie is not responding", + }, +} as const; diff --git a/ui/src/copy/errors/channels.ts b/ui/src/copy/errors/channels.ts new file mode 100644 index 000000000..9d3a21b76 --- /dev/null +++ b/ui/src/copy/errors/channels.ts @@ -0,0 +1,8 @@ +export const channels = { + agents: { + unknown: (id: string) => `${id} (unknown)`, + }, + status: { + load: "Couldn't load channel status", + }, +} as const; diff --git a/ui/src/copy/errors/curators.ts b/ui/src/copy/errors/curators.ts new file mode 100644 index 000000000..82e0daee4 --- /dev/null +++ b/ui/src/copy/errors/curators.ts @@ -0,0 +1,5 @@ +export const curators = { + page: { + unresponsive: "Archie is not responding", + }, +} as const; diff --git a/ui/src/copy/errors/events.ts b/ui/src/copy/errors/events.ts new file mode 100644 index 000000000..e2cb0f4fd --- /dev/null +++ b/ui/src/copy/errors/events.ts @@ -0,0 +1 @@ +export const events = {} as const; diff --git a/ui/src/copy/errors/index.ts b/ui/src/copy/errors/index.ts index 4f9699b34..75c116849 100644 --- a/ui/src/copy/errors/index.ts +++ b/ui/src/copy/errors/index.ts @@ -1,16 +1,28 @@ // Every failure message the dashboard writes itself, by feature. Call sites // dot-walk it, e.g. errors.chat.composer.microphoneUnavailable, so the copy is // changed here and nowhere else. +import { captures } from "./captures.ts"; +import { channels } from "./channels.ts"; import { chat } from "./chat.ts"; import { common } from "./common.ts"; +import { curators } from "./curators.ts"; import { dashboard } from "./dashboard.ts"; +import { events } from "./events.ts"; import { logs } from "./logs.ts"; +import { skills } from "./skills.ts"; +import { sources } from "./sources.ts"; import { tasks } from "./tasks.ts"; export const errors = { + captures, + channels, chat, common, + curators, dashboard, + events, logs, + skills, + sources, tasks, } as const; diff --git a/ui/src/copy/errors/skills.ts b/ui/src/copy/errors/skills.ts new file mode 100644 index 000000000..2fb7e8ab0 --- /dev/null +++ b/ui/src/copy/errors/skills.ts @@ -0,0 +1,5 @@ +export const skills = { + page: { + unresponsive: "Archie is not responding", + }, +} as const; diff --git a/ui/src/copy/errors/sources.ts b/ui/src/copy/errors/sources.ts new file mode 100644 index 000000000..5347ad8a5 --- /dev/null +++ b/ui/src/copy/errors/sources.ts @@ -0,0 +1,6 @@ +export const sources = { + panel: { + writeFailed: "That did not take effect", + loadFailed: "Couldn't load sources", + }, +} as const; diff --git a/ui/src/curators/CuratorsPage.vue b/ui/src/curators/CuratorsPage.vue index 0b62cbf49..f43552daf 100644 --- a/ui/src/curators/CuratorsPage.vue +++ b/ui/src/curators/CuratorsPage.vue @@ -22,7 +22,8 @@ import { EmptyHeader, EmptyTitle, } from "@/components/ui/empty"; -import { api } from "@/lib/api"; +import { errors } from "@/copy/errors"; +import { api, describeError } from "@/lib/api"; import { useLiveResource } from "@/stores/session"; import CuratorCard, { type Curator } from "./CuratorCard.vue"; @@ -80,7 +81,7 @@ async function load() { loadError.value = null; } catch (err) { if (current !== loadGeneration) return; - loadError.value = String((err as Error).message || err); + loadError.value = describeError(err, errors.common.unknown); } finally { if (current === loadGeneration) curatorsLoaded.value = true; } @@ -216,7 +217,7 @@ onMounted(load); > - Archie is not responding + {{ errors.curators.page.unresponsive }} {{ loadError }} diff --git a/ui/src/skills/SkillsPage.vue b/ui/src/skills/SkillsPage.vue index 85ac4083e..aff1d6ba6 100644 --- a/ui/src/skills/SkillsPage.vue +++ b/ui/src/skills/SkillsPage.vue @@ -13,7 +13,8 @@ import { EmptyTitle, } from "@/components/ui/empty"; import { Input } from "@/components/ui/input"; -import { api } from "@/lib/api"; +import { errors } from "@/copy/errors"; +import { api, describeError } from "@/lib/api"; import { useLiveResource } from "@/stores/session"; import SkillCard, { type Skill } from "./SkillCard.vue"; @@ -32,7 +33,7 @@ async function load() { loadError.value = null; } catch (err) { if (current !== loadGeneration) return; - loadError.value = String((err as Error).message || err); + loadError.value = describeError(err, errors.common.unknown); } finally { if (current === loadGeneration) loaded.value = true; } @@ -71,7 +72,7 @@ const filtered = computed(() => { > - Archie is not responding + {{ errors.skills.page.unresponsive }} {{ loadError }} diff --git a/ui/src/sources/SourcesPanel.vue b/ui/src/sources/SourcesPanel.vue index 5016b3e0c..c31d73c4c 100644 --- a/ui/src/sources/SourcesPanel.vue +++ b/ui/src/sources/SourcesPanel.vue @@ -22,6 +22,7 @@ import { TooltipContent, TooltipTrigger, } from "@/components/ui/tooltip"; +import { errors } from "@/copy/errors"; import { useLiveResource } from "@/stores/session"; import { signingKind, @@ -96,12 +97,12 @@ function url(source: Source): string { - That did not take effect + {{ errors.sources.panel.writeFailed }} {{ failure }} - Couldn't load sources + {{ errors.sources.panel.loadFailed }} {{ loadError }} diff --git a/ui/src/sources/use-sources.ts b/ui/src/sources/use-sources.ts index ded37ac41..20a4d286f 100644 --- a/ui/src/sources/use-sources.ts +++ b/ui/src/sources/use-sources.ts @@ -1,7 +1,8 @@ import { ref } from "vue"; import { useEventsStore } from "@/stores/events"; -import { api } from "@/lib/api"; +import { errors } from "@/copy/errors"; +import { api, describeError } from "@/lib/api"; import type { Source, SourceRefusals } from "./source-signing"; /** @@ -20,10 +21,6 @@ export function useSources() { const refusals = ref>({}); const busy = ref(false); - function message(err: unknown): string { - return err instanceof Error && err.message ? err.message : String(err); - } - let generation = 0; async function load(): Promise { const current = ++generation; @@ -39,7 +36,7 @@ export function useSources() { loadError.value = null; } catch (err) { if (current !== generation) return; - loadError.value = message(err); + loadError.value = describeError(err, errors.common.unknown); } } @@ -51,7 +48,7 @@ export function useSources() { if (result?.secret) revealed.value = result; await load(); } catch (err) { - failure.value = message(err); + failure.value = describeError(err, errors.common.unknown); } finally { busy.value = false; }