diff --git a/ui/src/bindings/BindingEditor.vue b/ui/src/bindings/BindingEditor.vue index 17811a6f5..cbc341925 100644 --- a/ui/src/bindings/BindingEditor.vue +++ b/ui/src/bindings/BindingEditor.vue @@ -1,4 +1,5 @@ diff --git a/ui/src/bindings/DispatchLinks.vue b/ui/src/bindings/DispatchLinks.vue index 16dd12202..0d792179a 100644 --- a/ui/src/bindings/DispatchLinks.vue +++ b/ui/src/bindings/DispatchLinks.vue @@ -2,6 +2,7 @@ import { ref, watch } from "vue"; import { api } from "@/lib/api"; +import { errors } from "@/copy/errors"; import { Empty, EmptyHeader, EmptyTitle } from "@/components/ui/empty"; import { Timestamp } from "@/components/ui/timestamp"; @@ -54,7 +55,7 @@ const captureLink = (id: string) => ({ - Dispatches unavailable. + {{ errors.bindings.dispatchLinks.unavailable }} ({ class="text-foreground hover:underline" >task #{{ d.task_id }} - {{ d.reason || "claimed, no task recorded" }} + {{ d.reason || errors.bindings.dispatchLinks.noTask }} diff --git a/ui/src/bindings/use-bindings.ts b/ui/src/bindings/use-bindings.ts index 90a00ca50..932047a58 100644 --- a/ui/src/bindings/use-bindings.ts +++ b/ui/src/bindings/use-bindings.ts @@ -1,7 +1,8 @@ import { ref } from "vue"; import { useEventsStore } from "@/stores/events"; -import { api, ApiError } from "@/lib/api"; +import { api, ApiError, describeError } from "@/lib/api"; +import { errors } from "@/copy/errors"; import type { EventType } from "@/captures/event-types"; import { bindingPayload, @@ -25,7 +26,7 @@ export interface LoadFailure { function failureFor(err: unknown): LoadFailure { const message = - err instanceof Error && err.message ? err.message : String(err); + describeError(err, errors.common.unknown); const status = err instanceof ApiError ? err.status : undefined; return { kind: status === 501 || status === 503 ? "unconfigured" : "failed", @@ -93,7 +94,7 @@ export function useBindings() { return true; } catch (err) { saveFailure.value = - err instanceof Error && err.message ? err.message : String(err); + describeError(err, errors.common.unknown); return false; } finally { saving.value = false; diff --git a/ui/src/copy/errors/bindings.ts b/ui/src/copy/errors/bindings.ts new file mode 100644 index 000000000..3972ffe4b --- /dev/null +++ b/ui/src/copy/errors/bindings.ts @@ -0,0 +1,17 @@ +// Failure copy for the bindings folder: the list, its editor and dispatch links. +export const bindings = { + page: { + actionNotApplied: "That did not take effect", + }, + editor: { + saveFailed: "Could not save", + }, + table: { + notConfigured: "Bindings are not configured", + unreachable: "Archie is not responding", + }, + dispatchLinks: { + unavailable: "Dispatches unavailable.", + noTask: "claimed, no task recorded", + }, +} as const; diff --git a/ui/src/copy/errors/index.ts b/ui/src/copy/errors/index.ts index 89257ae1f..58fe49650 100644 --- a/ui/src/copy/errors/index.ts +++ b/ui/src/copy/errors/index.ts @@ -6,6 +6,7 @@ import { alerts } from "./alerts.ts"; import { app } from "./app.ts"; import { audit } from "./audit.ts"; import { base } from "./base.ts"; +import { bindings } from "./bindings.ts"; import { captures } from "./captures.ts"; import { channels } from "./channels.ts"; import { chat } from "./chat.ts"; @@ -16,13 +17,16 @@ import { dashboard } from "./dashboard.ts"; import { events } from "./events.ts"; import { lib } from "./lib.ts"; import { logs } from "./logs.ts"; +import { mappings } from "./mappings.ts"; import { org } from "./org.ts"; import { router } from "./router.ts"; +import { schedules } from "./schedules.ts"; import { settings } from "./settings.ts"; import { skills } from "./skills.ts"; import { sources } from "./sources.ts"; import { stores } from "./stores.ts"; import { tasks } from "./tasks.ts"; +import { workflows } from "./workflows.ts"; export const errors = { accounts, @@ -30,6 +34,7 @@ export const errors = { app, audit, base, + bindings, captures, channels, chat, @@ -40,11 +45,14 @@ export const errors = { events, lib, logs, + mappings, org, router, + schedules, settings, skills, sources, stores, tasks, + workflows, } as const; diff --git a/ui/src/copy/errors/mappings.ts b/ui/src/copy/errors/mappings.ts new file mode 100644 index 000000000..34390fa84 --- /dev/null +++ b/ui/src/copy/errors/mappings.ts @@ -0,0 +1,24 @@ +// Failure copy for the mappings folder: the list, the form and the preview. +export const mappings = { + draft: { + payloadNotJson: "This capture's body is not valid JSON.", + }, + preview: { + noCapture: "Pick a captured event to preview against.", + }, + actionError: { + title: { + sessionExpired: "Session expired", + refused: "Archie refused that", + incomplete: "Not ready to preview", + unknown: "Archie could not complete that", + }, + }, + form: { + eventTypesNotLoaded: "Couldn't load event types", + capturesNotLoaded: "Couldn't load captured events", + }, + table: { + unreachable: "Archie is not responding", + }, +} as const; diff --git a/ui/src/copy/errors/schedules.ts b/ui/src/copy/errors/schedules.ts new file mode 100644 index 000000000..8261f37ac --- /dev/null +++ b/ui/src/copy/errors/schedules.ts @@ -0,0 +1,3 @@ +// Schedules report every failure through describeError, so this folder has no +// copy of its own yet. +export const schedules = {} as const; diff --git a/ui/src/copy/errors/workflows.ts b/ui/src/copy/errors/workflows.ts new file mode 100644 index 000000000..7cb1f004e --- /dev/null +++ b/ui/src/copy/errors/workflows.ts @@ -0,0 +1,79 @@ +// Failure copy for the workflows folder: the editor, the run canvas, triggers, +// the transcript and YAML or branch validation. +export const workflows = { + bindingSave: { + cannotSave: (blocker: string) => `Cannot save: ${blocker}`, + inputRequired: (input: string) => `${input} is required`, + }, + bindEvent: { + formNotLoaded: "Couldn't load the bind form", + bindingsNotLoaded: "The bindings list did not load, so this edit cannot tell whether the mapping is shared. Retry the load first.", + blocker: { + pickSource: "pick a source", + createSourceFirst: "create the source first", + noEvent: (source: string) => `no event from ${source} yet to preview against`, + bodyNotJson: "the picked event's body is not JSON", + }, + problem: { + repositoryUnresolved: "the repository path does not resolve", + inputFailed: (input: string, reason: string) => `${input}: ${reason}`, + inputType: (input: string, type: string, value: string) => `${input} is ${type}, but ${value} is not`, + }, + }, + scheduleTrigger: { + pickSchedule: "pick a schedule", + }, + triggers: { + notLoaded: "Couldn't load triggers", + }, + runs: { + stagesNotLoaded: "Couldn't load the run's stages", + }, + editor: { + restartFailed: "Restart failed", + draftNotSaved: "Draft not saved — your edit is still in the editor.", + recentRunsNotLoaded: (detail: string) => `Could not load recent runs: ${detail}`, + watchedStagesNotLoaded: (detail: string) => `Could not load the watched run's stages: ${detail}`, + }, + page: { + notEnabled: (id: string, detail: string) => `${id} not enabled: ${detail}`, + notDisabled: (id: string, detail: string) => `${id} not disabled: ${detail}`, + notDuplicated: (id: string, detail: string) => `${id} not duplicated: ${detail}`, + saveFailed: "save failed", + }, + history: { + notLoaded: "Could not load history", + }, + transcript: { + notLoaded: "Could not load the transcript", + stepFailed: (step: number, detail: string) => `Step ${step} failed: ${detail}`, + tool: { + failedToRun: "Failed to run", + failedToRead: "Failed to read", + gateFailed: "Gate failed", + }, + }, + stepRun: { + activityNotLoaded: "Could not load step activity", + changesNotLoaded: "Could not load captured changes", + }, + edit: { + readOnlyBranch: "Branches allow only read-only agents and workflow calls.", + caseValue: "A case is the value it matches, without a slash.", + branchName: "Use a lowercase branch name with letters, digits, dots or dashes.", + noBranches: "This step has no branches.", + branchExists: (name: string) => `Branch ${name} already exists.`, + branchMissing: (name: string) => `Branch ${name} does not exist.`, + parallelBranches: "Parallel needs at least two branches.", + switchCase: "A switch needs at least one case.", + }, + yaml: { + notMapping: "A workflow is a mapping with an id and steps.", + invalid: "invalid YAML", + line: (line: number, message: string) => `Line ${line}: ${message}`, + stepNeedsType: "Needs a type", + unknownStepType: (type: string) => `Unknown step type "${type}"`, + needsRepository: (type: string, repository: string) => + `"${type}" needs a repository, but the workflow's repository is ${repository}`, + }, +} as const; diff --git a/ui/src/mappings/MappingForm.vue b/ui/src/mappings/MappingForm.vue index 4d33050dc..98c2271cb 100644 --- a/ui/src/mappings/MappingForm.vue +++ b/ui/src/mappings/MappingForm.vue @@ -1,4 +1,5 @@ @@ -215,7 +216,7 @@ async function remove(): Promise { {{ error }} - Cannot save: {{ blockers[0] }} + {{ errors.workflows.bindingSave.cannotSave(blockers[0] ?? "") }} Save trigger Approve diff --git a/ui/src/workflows/StepEditor.vue b/ui/src/workflows/StepEditor.vue index 0e2703c75..e53e46983 100644 --- a/ui/src/workflows/StepEditor.vue +++ b/ui/src/workflows/StepEditor.vue @@ -1,4 +1,6 @@
Dispatches unavailable.
{{ errors.bindings.dispatchLinks.unavailable }}
Cannot save: {{ blockers[0] }}
{{ errors.workflows.bindingSave.cannotSave(blockers[0] ?? "") }}