fix(ui/captures): failures read from the error catalogue
This commit is contained in:
15 files changed
+72
-26
No files matched your search
@@ -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. -->
|
||||
<Alert v-if="error" variant="destructive">
|
||||
<TriangleAlert />
|
||||
<AlertTitle>Archie is not responding</AlertTitle>
|
||||
<AlertTitle>{{ errors.captures.list.unresponsive }}</AlertTitle>
|
||||
<AlertDescription>{{ error }}</AlertDescription>
|
||||
</Alert>
|
||||
|
||||
|
||||
@@ -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<void> {
|
||||
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<void> {
|
||||
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<void> {
|
||||
await api.eventTypeDelete(t.id);
|
||||
await loadEventTypes();
|
||||
} catch (err) {
|
||||
eventTypesError.value = (err as Error).message || String(err);
|
||||
eventTypesError.value = describeError(err, errors.common.unknown);
|
||||
}
|
||||
}
|
||||
@@ -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<void> {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -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<void> {
|
||||
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<ChannelStatus[]>([]);
|
||||
@@ -151,7 +152,7 @@ function setAllowedUsers(ids: string[]) {
|
||||
</AlertDescription></Alert>
|
||||
|
||||
<Alert v-if="statusError" variant="destructive" class="mb-4"><AlertDescription>
|
||||
Couldn't load channel status
|
||||
{{ errors.channels.status.load }}
|
||||
<Button variant="link" size="xs" @click="loadStatus">Retry</Button>
|
||||
</AlertDescription></Alert>
|
||||
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
export const captures = {
|
||||
list: {
|
||||
unresponsive: "Archie is not responding",
|
||||
},
|
||||
} as const;
|
||||
@@ -0,0 +1,8 @@
|
||||
export const channels = {
|
||||
agents: {
|
||||
unknown: (id: string) => `${id} (unknown)`,
|
||||
},
|
||||
status: {
|
||||
load: "Couldn't load channel status",
|
||||
},
|
||||
} as const;
|
||||
@@ -0,0 +1,5 @@
|
||||
export const curators = {
|
||||
page: {
|
||||
unresponsive: "Archie is not responding",
|
||||
},
|
||||
} as const;
|
||||
@@ -0,0 +1 @@
|
||||
export const events = {} as const;
|
||||
@@ -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;
|
||||
@@ -0,0 +1,5 @@
|
||||
export const skills = {
|
||||
page: {
|
||||
unresponsive: "Archie is not responding",
|
||||
},
|
||||
} as const;
|
||||
@@ -0,0 +1,6 @@
|
||||
export const sources = {
|
||||
panel: {
|
||||
writeFailed: "That did not take effect",
|
||||
loadFailed: "Couldn't load sources",
|
||||
},
|
||||
} as const;
|
||||
@@ -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);
|
||||
>
|
||||
<Empty v-if="loadError">
|
||||
<EmptyHeader>
|
||||
<EmptyTitle>Archie is not responding</EmptyTitle>
|
||||
<EmptyTitle>{{ errors.curators.page.unresponsive }}</EmptyTitle>
|
||||
<EmptyDescription>{{ loadError }}</EmptyDescription>
|
||||
</EmptyHeader>
|
||||
</Empty>
|
||||
|
||||
@@ -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(() => {
|
||||
>
|
||||
<Empty v-if="loadError">
|
||||
<EmptyHeader>
|
||||
<EmptyTitle>Archie is not responding</EmptyTitle>
|
||||
<EmptyTitle>{{ errors.skills.page.unresponsive }}</EmptyTitle>
|
||||
<EmptyDescription>{{ loadError }}</EmptyDescription>
|
||||
</EmptyHeader>
|
||||
</Empty>
|
||||
|
||||
@@ -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 {
|
||||
</form>
|
||||
|
||||
<Alert v-if="failure" variant="destructive">
|
||||
<AlertTitle>That did not take effect</AlertTitle>
|
||||
<AlertTitle>{{ errors.sources.panel.writeFailed }}</AlertTitle>
|
||||
<AlertDescription>{{ failure }}</AlertDescription>
|
||||
</Alert>
|
||||
|
||||
<Alert v-if="loadError" variant="destructive">
|
||||
<AlertTitle>Couldn't load sources</AlertTitle>
|
||||
<AlertTitle>{{ errors.sources.panel.loadFailed }}</AlertTitle>
|
||||
<AlertDescription>{{ loadError }} <Button variant="link" size="xs" @click="load">Retry</Button></AlertDescription>
|
||||
</Alert>
|
||||
|
||||
|
||||
@@ -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<Record<string, SourceRefusals>>({});
|
||||
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<void> {
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user