From ea6385879fbe27a7925bc85024f65ee98d7e544d Mon Sep 17 00:00:00 2001 From: Sam Catlow Date: Fri, 27 Nov 2026 19:02:30 +1100 Subject: [PATCH] fix(ui): stop calling operations the binary does not serve (#2121) The dashboard is embedded in the single binary, which serves api/openapi.yaml. It was still calling the old services' routes, so pages that read them answered with a not-found: the task board, its activity feed and setup panel, logs, alerts, audit and its export, bindings, schedules, channels, repositories, skills, curators, the control-plane settings pages, identities and org agents, the org switcher, secret-reference checks, task metadata, and the audit, usage, summary and version reads. Each of those surfaces is removed, and a test compares every /api path in the dashboard's source with api/openapi.yaml so the next one fails the gate instead of the browser. Settings that the binary does serve (model providers, instructions, policies, members) keep their pages. --- ui/pages/pages.json | 90 --- ui/src/App.vue | 16 +- ui/src/alerts/AlertsBell.vue | 93 --- ui/src/alerts/alerts.ts | 37 -- ui/src/alerts/use-alerts.ts | 83 --- ui/src/audit/AuditDetail.vue | 42 -- ui/src/audit/AuditExportMenu.vue | 36 -- ui/src/audit/AuditFilters.vue | 244 ------- ui/src/audit/audit.ts | 504 --------------- ui/src/audit/store.ts | 165 ----- .../command-palette/CommandPalette.vue | 60 +- ui/src/components/topbar/AccountMenu.vue | 3 +- ui/src/components/topbar/OrgCrumb.vue | 42 +- ui/src/components/topbar/SectionCrumb.vue | 17 - ui/src/copy/errors/alerts.ts | 5 - ui/src/copy/errors/audit.ts | 13 - ui/src/copy/errors/bindings.ts | 19 - ui/src/copy/errors/index.ts | 8 - ui/src/copy/errors/logs.ts | 10 - ui/src/copy/errors/org.ts | 3 - ui/src/curators/CuratorAction.vue | 33 - ui/src/curators/CuratorCard.vue | 73 --- ui/src/dashboard/ActivityRow.vue | 64 -- ui/src/dashboard/QuickTask.vue | 104 --- ui/src/dashboard/SetupPanel.vue | 52 -- ui/src/dashboard/activity-detail.ts | 60 -- ui/src/dashboard/activity-filter.ts | 65 -- ui/src/dashboard/activity-group.ts | 67 -- ui/src/dashboard/setup-preference.ts | 32 - ui/src/dashboard/state.ts | 8 - ui/src/lib/api.ts | 155 +---- ui/src/lib/task-meta-snapshot.ts | 103 +-- ui/src/lib/task-meta.ts | 127 +--- ui/src/lib/webmcp-tools.ts | 145 +---- ui/src/logs/LogActions.vue | 27 - ui/src/logs/LogFilters.vue | 122 ---- ui/src/logs/LogList.vue | 72 --- ui/src/logs/LogStatus.vue | 18 - ui/src/logs/LogStream.vue | 28 - ui/src/logs/LogsEmpty.vue | 24 - ui/src/logs/log-entries.ts | 71 --- ui/src/logs/logs-empty.ts | 27 - ui/src/logs/state.ts | 190 ------ ui/src/org/NewOrgDialog.vue | 12 +- ui/src/org/UserReference.vue | 13 +- ui/src/pages/events.vue | 2 - .../bindings/components/BindingEditor.vue | 202 ------ .../events/bindings/components/BindingRow.vue | 73 --- .../components/BindingStatusBadge.vue | 15 - .../bindings/components/BindingsTable.vue | 101 --- .../components/DeleteBindingDialog.vue | 48 -- .../bindings/components/DispatchLinks.vue | 89 --- .../bindings/components/TriggerRuns.vue | 90 --- ui/src/pages/events/bindings/index.vue | 129 ---- .../events/bindings/lib/binding-draft.ts | 258 -------- .../events/bindings/lib/binding-trigger.ts | 104 --- .../pages/events/bindings/lib/use-bindings.ts | 125 ---- .../inspector/components/CaptureDetail.vue | 5 - ui/src/pages/events/lib/counts.ts | 14 +- ui/src/pages/events/lib/tab-selection.ts | 6 +- .../mappings/components/MappingForm.vue | 2 +- ui/src/pages/index.vue | 2 - ui/src/pages/logs.vue | 24 - ui/src/pages/org.vue | 2 +- ui/src/pages/org/agents.vue | 235 ------- ui/src/pages/org/audit.vue | 601 ------------------ ui/src/pages/org/channels.vue | 225 ------- ui/src/pages/org/index.vue | 1 - ui/src/pages/org/issue-routing.vue | 129 ---- ui/src/pages/org/repositories.vue | 360 ----------- ui/src/pages/org/scheduling-policy.vue | 202 ------ ui/src/pages/org/usage.vue | 345 ---------- ui/src/pages/settings/agent-profiles.vue | 113 ---- ui/src/pages/settings/channels.vue | 230 ------- ui/src/pages/settings/container-runtime.vue | 384 ----------- ui/src/pages/settings/curators.vue | 243 ------- ui/src/pages/settings/plugins.vue | 75 --- ui/src/pages/settings/skills.vue | 111 ---- ui/src/pages/settings/task-execution.vue | 166 ----- ui/src/pages/settings/tools.vue | 284 --------- ui/src/pages/tasks/[id].vue | 88 --- ui/src/pages/tasks/index.vue | 244 ------- ui/src/schedules/CronRuleBuilder.vue | 199 ------ ui/src/schedules/ScheduleEditor.vue | 105 --- ui/src/schedules/cron-rule.ts | 85 --- ui/src/schedules/schedule.ts | 177 ------ ui/src/settings/ApplyStatusRows.vue | 47 -- ui/src/settings/CardAccordion.vue | 47 -- ui/src/settings/CommandListEditor.vue | 48 -- ui/src/settings/DraftHint.vue | 22 - ui/src/settings/ExtensionChannelSettings.vue | 100 --- ui/src/settings/HistoryLink.vue | 15 - ui/src/settings/IdentityGrantsCard.vue | 82 --- ui/src/settings/KindGate.vue | 26 - ui/src/settings/McpServerEditor.vue | 112 ---- ui/src/settings/RestartPendingBanner.vue | 25 - ui/src/settings/SecretRefField.vue | 25 - ui/src/settings/SettingsSaveBar.vue | 36 +- ui/src/settings/SettingsShell.vue | 4 +- ui/src/settings/apply-status.ts | 70 -- ui/src/settings/model-choices.ts | 15 - ui/src/settings/settings-form.ts | 105 --- ui/src/settings/types.ts | 21 - ui/src/skills/SkillCard.vue | 34 - ui/src/stores/org.ts | 116 +--- ui/src/stores/session.ts | 8 - ui/src/stores/settings.ts | 492 +------------- ui/src/stores/tasks.ts | 88 --- ui/src/tasks/AttemptConfig.vue | 63 -- ui/src/tasks/ChangeCapture.vue | 71 --- ui/src/tasks/ChangeFileTable.vue | 87 --- ui/src/tasks/ChangedFiles.vue | 68 -- ui/src/tasks/DebugView.vue | 35 - ui/src/tasks/JsonBlock.vue | 17 - ui/src/tasks/NewTaskDialog.vue | 32 - ui/src/tasks/NewTaskForm.vue | 172 ----- ui/src/tasks/PanelError.vue | 21 - ui/src/tasks/PanelLoading.vue | 11 - ui/src/tasks/PlanDocument.vue | 75 --- ui/src/tasks/StageRail.vue | 156 ----- ui/src/tasks/StageRow.vue | 133 ---- ui/src/tasks/TabBar.vue | 31 - ui/src/tasks/TaskApproval.vue | 104 --- ui/src/tasks/TaskDetailNotice.vue | 61 -- ui/src/tasks/TaskFilters.vue | 74 --- ui/src/tasks/TaskHeader.vue | 205 ------ ui/src/tasks/TaskLogFilters.vue | 99 --- ui/src/tasks/TaskLogs.vue | 285 --------- ui/src/tasks/TaskNotes.vue | 38 -- ui/src/tasks/TaskRail.vue | 77 --- ui/src/tasks/TaskReviewGate.vue | 59 -- ui/src/tasks/TaskRowActions.vue | 437 ------------- ui/src/tasks/TaskRunPanels.vue | 72 --- ui/src/tasks/TaskTable.vue | 114 ---- ui/src/tasks/TasksState.vue | 65 -- ui/src/tasks/attempt-config.ts | 52 -- ui/src/tasks/changed-files.ts | 42 -- ui/src/tasks/file-tree.ts | 45 -- ui/src/tasks/first-line.ts | 5 - ui/src/tasks/retry-mode.ts | 84 --- ui/src/tasks/review-gate.ts | 30 - ui/src/tasks/stage-rail.ts | 7 +- ui/src/tasks/task-actions.ts | 55 -- ui/src/tasks/task-filter.ts | 47 -- ui/src/tasks/task-run.ts | 254 -------- ui/src/tasks/task.ts | 44 -- ui/src/tasks/timeline-event.ts | 12 +- ui/src/tasks/use-task-run.ts | 393 ------------ ui/src/typed-router.d.ts | 301 --------- ui/src/workflows/bind-event.ts | 132 ---- ui/test/activity-detail.test.ts | 10 - ui/test/activity-group.test.ts | 27 - ui/test/api-paths.test.ts | 97 +++ ui/test/binding-event-types.test.ts | 153 ----- ui/test/changes.test.ts | 86 --- ui/test/control-plane.test.ts | 206 ------ ui/test/dashboard-panels.test.ts | 26 - ui/test/describe-error.test.ts | 4 +- ui/test/events-counts.test.ts | 5 +- ui/test/events-tabs.test.ts | 21 +- ui/test/model-choices.test.ts | 22 - ui/test/retry-mode.test.ts | 44 -- ui/test/schedule-rule.test.ts | 53 -- ui/test/settings-apply-status.test.ts | 66 -- ui/test/setup-panel.test.ts | 19 - ui/test/task-actions.test.ts | 160 ----- ui/test/task-filter.test.ts | 61 -- ui/test/task-time-limit.test.ts | 24 - ui/test/webmcp.test.ts | 157 +---- 169 files changed, 245 insertions(+), 15774 deletions(-) delete mode 100644 ui/src/alerts/AlertsBell.vue delete mode 100644 ui/src/alerts/alerts.ts delete mode 100644 ui/src/alerts/use-alerts.ts delete mode 100644 ui/src/audit/AuditDetail.vue delete mode 100644 ui/src/audit/AuditExportMenu.vue delete mode 100644 ui/src/audit/AuditFilters.vue delete mode 100644 ui/src/audit/audit.ts delete mode 100644 ui/src/audit/store.ts delete mode 100644 ui/src/copy/errors/alerts.ts delete mode 100644 ui/src/copy/errors/audit.ts delete mode 100644 ui/src/copy/errors/bindings.ts delete mode 100644 ui/src/copy/errors/logs.ts delete mode 100644 ui/src/curators/CuratorAction.vue delete mode 100644 ui/src/curators/CuratorCard.vue delete mode 100644 ui/src/dashboard/ActivityRow.vue delete mode 100644 ui/src/dashboard/QuickTask.vue delete mode 100644 ui/src/dashboard/SetupPanel.vue delete mode 100644 ui/src/dashboard/activity-detail.ts delete mode 100644 ui/src/dashboard/activity-filter.ts delete mode 100644 ui/src/dashboard/activity-group.ts delete mode 100644 ui/src/dashboard/setup-preference.ts delete mode 100644 ui/src/dashboard/state.ts delete mode 100644 ui/src/logs/LogActions.vue delete mode 100644 ui/src/logs/LogFilters.vue delete mode 100644 ui/src/logs/LogList.vue delete mode 100644 ui/src/logs/LogStatus.vue delete mode 100644 ui/src/logs/LogStream.vue delete mode 100644 ui/src/logs/LogsEmpty.vue delete mode 100644 ui/src/logs/log-entries.ts delete mode 100644 ui/src/logs/logs-empty.ts delete mode 100644 ui/src/logs/state.ts delete mode 100644 ui/src/pages/events/bindings/components/BindingEditor.vue delete mode 100644 ui/src/pages/events/bindings/components/BindingRow.vue delete mode 100644 ui/src/pages/events/bindings/components/BindingStatusBadge.vue delete mode 100644 ui/src/pages/events/bindings/components/BindingsTable.vue delete mode 100644 ui/src/pages/events/bindings/components/DeleteBindingDialog.vue delete mode 100644 ui/src/pages/events/bindings/components/DispatchLinks.vue delete mode 100644 ui/src/pages/events/bindings/components/TriggerRuns.vue delete mode 100644 ui/src/pages/events/bindings/index.vue delete mode 100644 ui/src/pages/events/bindings/lib/binding-draft.ts delete mode 100644 ui/src/pages/events/bindings/lib/binding-trigger.ts delete mode 100644 ui/src/pages/events/bindings/lib/use-bindings.ts delete mode 100644 ui/src/pages/logs.vue delete mode 100644 ui/src/pages/org/agents.vue delete mode 100644 ui/src/pages/org/audit.vue delete mode 100644 ui/src/pages/org/channels.vue delete mode 100644 ui/src/pages/org/issue-routing.vue delete mode 100644 ui/src/pages/org/repositories.vue delete mode 100644 ui/src/pages/org/scheduling-policy.vue delete mode 100644 ui/src/pages/org/usage.vue delete mode 100644 ui/src/pages/settings/agent-profiles.vue delete mode 100644 ui/src/pages/settings/channels.vue delete mode 100644 ui/src/pages/settings/container-runtime.vue delete mode 100644 ui/src/pages/settings/curators.vue delete mode 100644 ui/src/pages/settings/plugins.vue delete mode 100644 ui/src/pages/settings/skills.vue delete mode 100644 ui/src/pages/settings/task-execution.vue delete mode 100644 ui/src/pages/settings/tools.vue delete mode 100644 ui/src/pages/tasks/[id].vue delete mode 100644 ui/src/pages/tasks/index.vue delete mode 100644 ui/src/schedules/CronRuleBuilder.vue delete mode 100644 ui/src/schedules/ScheduleEditor.vue delete mode 100644 ui/src/schedules/cron-rule.ts delete mode 100644 ui/src/schedules/schedule.ts delete mode 100644 ui/src/settings/ApplyStatusRows.vue delete mode 100644 ui/src/settings/CardAccordion.vue delete mode 100644 ui/src/settings/CommandListEditor.vue delete mode 100644 ui/src/settings/DraftHint.vue delete mode 100644 ui/src/settings/ExtensionChannelSettings.vue delete mode 100644 ui/src/settings/HistoryLink.vue delete mode 100644 ui/src/settings/IdentityGrantsCard.vue delete mode 100644 ui/src/settings/KindGate.vue delete mode 100644 ui/src/settings/McpServerEditor.vue delete mode 100644 ui/src/settings/RestartPendingBanner.vue delete mode 100644 ui/src/settings/apply-status.ts delete mode 100644 ui/src/settings/model-choices.ts delete mode 100644 ui/src/settings/settings-form.ts delete mode 100644 ui/src/settings/types.ts delete mode 100644 ui/src/skills/SkillCard.vue delete mode 100644 ui/src/stores/tasks.ts delete mode 100644 ui/src/tasks/AttemptConfig.vue delete mode 100644 ui/src/tasks/ChangeCapture.vue delete mode 100644 ui/src/tasks/ChangeFileTable.vue delete mode 100644 ui/src/tasks/ChangedFiles.vue delete mode 100644 ui/src/tasks/DebugView.vue delete mode 100644 ui/src/tasks/JsonBlock.vue delete mode 100644 ui/src/tasks/NewTaskDialog.vue delete mode 100644 ui/src/tasks/NewTaskForm.vue delete mode 100644 ui/src/tasks/PanelError.vue delete mode 100644 ui/src/tasks/PanelLoading.vue delete mode 100644 ui/src/tasks/PlanDocument.vue delete mode 100644 ui/src/tasks/StageRail.vue delete mode 100644 ui/src/tasks/StageRow.vue delete mode 100644 ui/src/tasks/TabBar.vue delete mode 100644 ui/src/tasks/TaskApproval.vue delete mode 100644 ui/src/tasks/TaskDetailNotice.vue delete mode 100644 ui/src/tasks/TaskFilters.vue delete mode 100644 ui/src/tasks/TaskHeader.vue delete mode 100644 ui/src/tasks/TaskLogFilters.vue delete mode 100644 ui/src/tasks/TaskLogs.vue delete mode 100644 ui/src/tasks/TaskNotes.vue delete mode 100644 ui/src/tasks/TaskRail.vue delete mode 100644 ui/src/tasks/TaskReviewGate.vue delete mode 100644 ui/src/tasks/TaskRowActions.vue delete mode 100644 ui/src/tasks/TaskRunPanels.vue delete mode 100644 ui/src/tasks/TaskTable.vue delete mode 100644 ui/src/tasks/TasksState.vue delete mode 100644 ui/src/tasks/attempt-config.ts delete mode 100644 ui/src/tasks/changed-files.ts delete mode 100644 ui/src/tasks/file-tree.ts delete mode 100644 ui/src/tasks/first-line.ts delete mode 100644 ui/src/tasks/retry-mode.ts delete mode 100644 ui/src/tasks/review-gate.ts delete mode 100644 ui/src/tasks/task-actions.ts delete mode 100644 ui/src/tasks/task-filter.ts delete mode 100644 ui/src/tasks/task-run.ts delete mode 100644 ui/src/tasks/task.ts delete mode 100644 ui/src/tasks/use-task-run.ts delete mode 100644 ui/src/workflows/bind-event.ts delete mode 100644 ui/test/activity-detail.test.ts delete mode 100644 ui/test/activity-group.test.ts create mode 100644 ui/test/api-paths.test.ts delete mode 100644 ui/test/binding-event-types.test.ts delete mode 100644 ui/test/changes.test.ts delete mode 100644 ui/test/control-plane.test.ts delete mode 100644 ui/test/dashboard-panels.test.ts delete mode 100644 ui/test/model-choices.test.ts delete mode 100644 ui/test/retry-mode.test.ts delete mode 100644 ui/test/schedule-rule.test.ts delete mode 100644 ui/test/settings-apply-status.test.ts delete mode 100644 ui/test/setup-panel.test.ts delete mode 100644 ui/test/task-actions.test.ts delete mode 100644 ui/test/task-filter.test.ts delete mode 100644 ui/test/task-time-limit.test.ts diff --git a/ui/pages/pages.json b/ui/pages/pages.json index c587bb8a4..88b4e47d6 100644 --- a/ui/pages/pages.json +++ b/ui/pages/pages.json @@ -34,11 +34,6 @@ "label": "Events", "description": "Received events, their sources, and the triggers that start workflows." }, - { - "path": "/events/bindings", - "label": "Bindings", - "description": "Bindings that decide which workflow an event starts." - }, { "path": "/events/inspector", "label": "Inspector", @@ -59,11 +54,6 @@ "label": "Triggers", "description": "Triggers that start workflows from events and schedules." }, - { - "path": "/logs", - "label": "Logs", - "description": "Daemon log by level and component." - }, { "path": "/memory", "label": "Personal memory", @@ -74,11 +64,6 @@ "label": "Organisation", "description": "Members, identities, connections, models and automation." }, - { - "path": "/org/agents", - "label": "Agents", - "description": "Execution identities, their permissions and commit author." - }, { "path": "/org/alerts", "label": "Alert webhook", @@ -89,16 +74,6 @@ "label": "Approvals", "description": "Default owner, escalation path and approval deadline." }, - { - "path": "/org/audit", - "label": "Audit", - "description": "Settings, access, identity and runtime events." - }, - { - "path": "/org/channels", - "label": "Channels", - "description": "Chat channels." - }, { "path": "/org/connections", "label": "Connections", @@ -119,11 +94,6 @@ "label": "Instructions", "description": "Standing instructions given to every agent in the organisation." }, - { - "path": "/org/issue-routing", - "label": "Issue routing", - "description": "Which workflow an issue runs by its labels." - }, { "path": "/org/members", "label": "Members", @@ -144,26 +114,11 @@ "label": "Policies", "description": "Access rules for the organisation." }, - { - "path": "/org/repositories", - "label": "Repositories", - "description": "Repository connections, access checks and execution policies." - }, { "path": "/org/schedules", "label": "Schedules", "description": "Time triggers that start workflows." }, - { - "path": "/org/scheduling-policy", - "label": "Scheduling policy", - "description": "Work discovery and forge labels." - }, - { - "path": "/org/usage", - "label": "Usage", - "description": "Token spend by model, identity and period." - }, { "path": "/org/workspaces", "label": "Workspaces", @@ -184,36 +139,16 @@ "label": "Instance", "description": "Every instance-wide setting: models, prompts, connections, runtime and status." }, - { - "path": "/settings/agent-profiles", - "label": "Agent profiles", - "description": "Execution profiles: the image and tools each agent runs with." - }, { "path": "/settings/authentication", "label": "Authentication", "description": "Instance URL and single sign-on providers." }, - { - "path": "/settings/channels", - "label": "Channels", - "description": "Chat channel connections and session defaults." - }, - { - "path": "/settings/container-runtime", - "label": "Container runtime", - "description": "How task containers run: runtime, image, limits and egress hosts." - }, { "path": "/settings/credentials", "label": "Credentials", "description": "Sealed credentials extensions and models use." }, - { - "path": "/settings/curators", - "label": "Curators", - "description": "Scheduled memory and capture curation." - }, { "path": "/settings/extensions", "label": "Extensions", @@ -244,41 +179,16 @@ "label": "Organisations", "description": "The organisations on this instance, and which one is active." }, - { - "path": "/settings/plugins", - "label": "Plugins", - "description": "Extension directories loaded at startup." - }, { "path": "/settings/secret-engines", "label": "Secret engines", "description": "Where secrets are read from: engines, their keys and health." }, - { - "path": "/settings/skills", - "label": "Skills", - "description": "Skills Archie can activate." - }, { "path": "/settings/status", "label": "Status", "description": "Module, connector and runner health, and the running version." }, - { - "path": "/settings/task-execution", - "label": "Task execution", - "description": "Statuses, operator actions, budgets." - }, - { - "path": "/settings/tools", - "label": "Tools & MCP", - "description": "Agent tools and MCP servers." - }, - { - "path": "/tasks", - "label": "Tasks", - "description": "Picked-up issues and their status." - }, { "path": "/workflows", "label": "Workflows", diff --git a/ui/src/App.vue b/ui/src/App.vue index 61b8a3083..7fd2e3ec6 100644 --- a/ui/src/App.vue +++ b/ui/src/App.vue @@ -7,7 +7,6 @@ import AccountEntry from "@/accounts/AccountEntry.vue"; import { useAccountsStore } from "@/accounts/accounts"; import ChatDock from "@/chat/ChatDock.vue"; -import AlertsBell from "@/alerts/AlertsBell.vue"; import CommandPalette from "@/components/command-palette/CommandPalette.vue"; import AccountMenu from "@/components/topbar/AccountMenu.vue"; import OrgCrumb from "@/components/topbar/OrgCrumb.vue"; @@ -21,11 +20,9 @@ import { Breadcrumb, BreadcrumbItem, BreadcrumbList, BreadcrumbPage, BreadcrumbS import { Alert, AlertDescription } from "@/components/ui/alert"; import { Card } from "@/components/ui/card"; import { SidebarInset, SidebarProvider } from "@/components/ui/sidebar"; -import NewTaskDialog from "@/tasks/NewTaskDialog.vue"; import { layoutComponent, resolveLayout } from "@/layouts"; import { TooltipProvider } from "@/components/ui/tooltip"; import { hiddenPaths, navTree } from "@/lib/nav"; -import { loadTaskMeta } from "@/lib/task-meta"; import { useSessionStore } from "@/stores/session"; import { Toaster } from "vue-sonner"; import "vue-sonner/style.css"; @@ -55,7 +52,6 @@ void router.isReady().then(() => { routerReady.value = true; }); const main = ref(null); -const newTaskOpen = ref(false); // A page the caller may not open is not reachable by URL either: the nav drops // it, so a bookmark or a chat link must not land on a form whose saves the // control plane refuses. @@ -94,14 +90,6 @@ watch(() => accounts.status?.user, (user) => { // loses the entries this process cannot back a moment later, rather than // holding the page behind a request. A failed read hides nothing. void session.loadCapabilities(); - - // The lifecycle vocabulary -- status labels, pill severity, "needs you" - // grouping, and the operator actions -- is served by /api/task-meta. Asked - // for once, after the shell is up: the freeze-dried defaults paint - // immediately and this replaces them, so a catalogue change on the server - // reaches the browser without a UI release. loadTaskMeta never throws (a - // failed read keeps the defaults), so it needs no catch here. - void loadTaskMeta(); }); @@ -139,10 +127,8 @@ watch(() => accounts.status?.user, (user) => {
- - + -
diff --git a/ui/src/alerts/AlertsBell.vue b/ui/src/alerts/AlertsBell.vue deleted file mode 100644 index f6118bdcc..000000000 --- a/ui/src/alerts/AlertsBell.vue +++ /dev/null @@ -1,93 +0,0 @@ - - - diff --git a/ui/src/alerts/alerts.ts b/ui/src/alerts/alerts.ts deleted file mode 100644 index 2887d1501..000000000 --- a/ui/src/alerts/alerts.ts +++ /dev/null @@ -1,37 +0,0 @@ -/** Operator alerts as the dashboard reads them: what needs attention, by severity. */ - -export type AlertSeverity = "action" | "warning" | "info"; - -interface AlertDelivery { - event: string; - state: string; - attempts: { n: number; at: string; status_code?: number; error?: string }[]; -} - -export interface OperatorAlert { - id: number; - kind: string; - severity: AlertSeverity; - title: string; - body: string; - link?: string; - condition: boolean; - count: number; - first_raised: string; - last_seen: string; - deliveries: AlertDelivery[]; -} - -/** Most urgent first, as the list groups them. */ -const SEVERITY_GROUPS: { severity: AlertSeverity; label: string }[] = [ - { severity: "action", label: "Needs attention" }, - { severity: "warning", label: "Warnings" }, - { severity: "info", label: "Info" }, -]; - -export function groupBySeverity(alerts: readonly OperatorAlert[]) { - return SEVERITY_GROUPS.map((group) => ({ - ...group, - alerts: alerts.filter((alert) => alert.severity === group.severity), - })).filter((group) => group.alerts.length > 0); -} diff --git a/ui/src/alerts/use-alerts.ts b/ui/src/alerts/use-alerts.ts deleted file mode 100644 index 90dca2ca6..000000000 --- a/ui/src/alerts/use-alerts.ts +++ /dev/null @@ -1,83 +0,0 @@ -import { storeToRefs } from "pinia"; -import { onMounted, ref, watch } from "vue"; - -import { api, describeError } from "@/lib/api"; -import { errors } from "@/copy/errors"; -import { useSessionStore } from "@/stores/session"; -import type { OperatorAlert } from "./alerts"; - -/** - * The open alerts, shared by every caller (the bell and the dashboard card - * must not hold separate copies): the refs live at module scope, like - * captures/state.ts, and the stream wiring is registered once. The store - * records every alert change as an event, so the newest alert event's id - * moving means the list moved. A reconnect re-reads, since events may have - * been missed. - */ -const alerts = ref([]); -const failed = ref(false); -const loaded = ref(false); -const dismissError = ref(""); -// Loads overlap when alert events arrive close together; only the newest -// may land, or an older list overwrites a newer one. -let latest = 0; -let wired = false; -// A reconnect replays the backlog, one alert event at a time; read the list -// once per burst instead of once per event. -let pending: ReturnType | undefined; - -function scheduleLoad() { - clearTimeout(pending); - pending = setTimeout(load, 500); -} - -async function load() { - const seq = ++latest; - try { - const next = (await api.alerts<{ alerts: OperatorAlert[] }>()).alerts; - if (seq !== latest) return; - alerts.value = next; - failed.value = false; - } catch { - if (seq === latest) failed.value = true; - } finally { - if (seq === latest) loaded.value = true; - } -} - -async function dismiss(alert: OperatorAlert) { - latest++; - dismissError.value = ""; - try { - await api.dismissAlert(alert.id); - alerts.value = alerts.value.filter((a) => a.id !== alert.id); - } catch (err) { - // The dismiss failed: the alert stays and the reason is shown. - dismissError.value = errors.alerts.dismiss(describeError(err, errors.common.unknown)); - await load(); - } -} - -async function dismissAll() { - const ids = alerts.value.map((a) => a.id); - dismissError.value = ""; - const results = await Promise.allSettled(ids.map((id) => api.dismissAlert(id))); - const rejected = results.find((r) => r.status === "rejected"); - if (rejected && rejected.status === "rejected") { - dismissError.value = errors.alerts.dismiss(describeError(rejected.reason, errors.common.unknown)); - await load(); - return; - } - alerts.value = []; -} - -export function useAlerts() { - if (!wired) { - wired = true; - const { activity, connectionRevision } = storeToRefs(useSessionStore()); - watch(() => activity.value.find((event) => event.kind === "alert")?.id, scheduleLoad); - watch(connectionRevision, scheduleLoad); - onMounted(load); - } - return { alerts, failed, loaded, dismissError, dismiss, dismissAll }; -} diff --git a/ui/src/audit/AuditDetail.vue b/ui/src/audit/AuditDetail.vue deleted file mode 100644 index 1fd84cb3e..000000000 --- a/ui/src/audit/AuditDetail.vue +++ /dev/null @@ -1,42 +0,0 @@ - - - diff --git a/ui/src/audit/AuditExportMenu.vue b/ui/src/audit/AuditExportMenu.vue deleted file mode 100644 index fceb5444d..000000000 --- a/ui/src/audit/AuditExportMenu.vue +++ /dev/null @@ -1,36 +0,0 @@ - - - diff --git a/ui/src/audit/AuditFilters.vue b/ui/src/audit/AuditFilters.vue deleted file mode 100644 index 32acaa7ea..000000000 --- a/ui/src/audit/AuditFilters.vue +++ /dev/null @@ -1,244 +0,0 @@ - - - diff --git a/ui/src/audit/audit.ts b/ui/src/audit/audit.ts deleted file mode 100644 index c0dfb4c40..000000000 --- a/ui/src/audit/audit.ts +++ /dev/null @@ -1,504 +0,0 @@ -import type { LocationQuery } from "vue-router"; - -import type { QueryParams } from "@/lib/api"; -import { formatValue, type Change } from "@/lib/changes"; -import { exactTime } from "../lib/format.ts"; -import { useAppearanceStore } from "../stores/appearance"; - -/** One actor as the audit feed reports it. */ -interface AuditActor { - id: string; - name?: string; - kind?: string; - principal_id?: string; -} - -/** The thing the event happened to; `href` is a same-origin dashboard route. */ -export interface AuditTarget { - kind: string; - id: string; - label?: string; - href?: string; -} - -interface AuditField { - field: string; - old?: unknown; - new?: unknown; -} - -/** Per-event context. A settings change carries `fields`; a runtime event - * carries `data`. */ -export interface AuditDetail { - fields?: AuditField[]; - data?: Record | null; - version?: number; - request_id?: string; - source?: string; - table?: string; -} - -type AuditCategory = "settings" | "access" | "identity" | "runtime" | "automation"; -type AuditSeverity = "info" | "warning" | "error"; -type AuditOutcome = "success" | "denied" | "failure"; - -export interface AuditRecord { - /** Composite and opaque, e.g. "1:42". */ - id: string; - at: string; - category: AuditCategory; - action: string; - kind: string; - severity: AuditSeverity; - outcome: AuditOutcome; - actor: AuditActor; - target: AuditTarget; - summary: string; - detail?: AuditDetail; -} - -/** One settings kind the feed can name, with its catalog title. */ -interface SettingsKind { - kind: string; - title: string; -} - -/** The server's closed vocabularies, so the UI never invents one. */ -export interface AuditFacets { - categories: string[]; - severities: string[]; - outcomes: string[]; - target_kinds: string[]; - settings_kinds: SettingsKind[]; - /** The runtime event kinds the instance's audit retention can window. */ - retention_kinds: string[]; -} - -export interface AuditResponse { - records: AuditRecord[]; - next_cursor?: string | null; - has_more: boolean; - facets?: AuditFacets; -} - -export function emptyFacets(): AuditFacets { - return { - categories: [], - severities: [], - outcomes: [], - target_kinds: [], - settings_kinds: [], - retention_kinds: [], - }; -} - -/** The filter state carried in the URL. */ -export interface AuditQuery { - q?: string; - categories: string[]; - kinds: string[]; - actions: string[]; - actor?: string; - target_kind?: string; - target_id?: string; - severity?: string; - outcome?: string; - /** 24h, 7d, 30d or any. Absent means the default 30 days. */ - since?: string; - /** Custom range, in datetime-local form. */ - from?: string; - to?: string; -} - -const PRESET_MS: Record = { - "24h": 86_400_000, - "7d": 604_800_000, - "30d": 2_592_000_000, -}; - -/** The default window: what the time select shows when the URL is bare. */ -const DEFAULT_SINCE = "30d"; - -/** Export names its own start when the operator chose Any time. */ -const EPOCH = "1970-01-01T00:00:00Z"; - -function text(value: LocationQuery[string] | undefined): string | undefined { - const first = Array.isArray(value) ? value[0] : value; - const trimmed = first == null ? "" : String(first).trim(); - return trimmed || undefined; -} - -function list(value: LocationQuery[string] | undefined): string[] { - if (value == null) return []; - const raw = Array.isArray(value) ? value : [value]; - return raw - .flatMap((item) => String(item).split(",")) - .map((item) => item.trim()) - .filter(Boolean); -} - -/** Reads the URL into a query. `section` is the pre-Audit deep-link name for - * the resource-kind filter, and still wins when `kind` is absent. */ -export function queryFromRoute(query: LocationQuery): AuditQuery { - const kinds = list(query.kind); - return { - q: text(query.q), - categories: list(query.categories), - kinds: kinds.length ? kinds : list(query.section), - actions: list(query.actions), - actor: text(query.actor), - target_kind: text(query.target_kind), - target_id: text(query.target_id), - severity: text(query.severity), - outcome: text(query.outcome), - since: text(query.since), - from: text(query.from), - to: text(query.to), - }; -} - -/** Writes a query back as URL values: arrays are comma-joined so a shared or - * bookmarked URL stays readable. */ -export function routeQueryFor(query: AuditQuery): Record { - const out: Record = {}; - const put = (key: string, value: string | undefined) => { - if (value) out[key] = value; - }; - put("q", query.q?.trim()); - put("categories", query.categories.join(",")); - put("actions", query.actions.join(",")); - put("kind", query.kinds.join(",")); - put("actor", query.actor?.trim()); - put("target_kind", query.target_kind); - put("target_id", query.target_id?.trim()); - put("severity", query.severity); - put("outcome", query.outcome); - put("since", query.since); - put("from", query.from); - put("to", query.to); - return out; -} - -function instant(value: string | undefined): string | undefined { - if (!value) return undefined; - const date = new Date(value); - return Number.isNaN(date.getTime()) ? undefined : date.toISOString(); -} - -function presetMs(since?: string): number { - return PRESET_MS[since ?? DEFAULT_SINCE] ?? PRESET_MS[DEFAULT_SINCE]; -} - -/** Resolves the explicit window once per load. The cursor is bound to these - * exact bounds, so pagination must not recompute them. */ -function timeBounds( - query: AuditQuery, - now = Date.now(), -): { from?: string; to?: string } { - const from = instant(query.from); - const to = instant(query.to); - if (from || to) return { from, to }; - if (query.since === "any") return {}; - return { from: new Date(now - presetMs(query.since)).toISOString() }; -} - -/** The server filter for one page. Arrays become repeated parameters. */ -export function apiParams(query: AuditQuery, now = Date.now()): QueryParams { - const { from, to } = timeBounds(query, now); - return { - q: query.q?.trim() || undefined, - categories: query.categories.length ? query.categories : undefined, - actions: query.actions.length ? query.actions : undefined, - kind: query.kinds.length ? query.kinds : undefined, - actor: query.actor?.trim() || undefined, - target_kind: query.target_kind, - target_id: query.target_id?.trim() || undefined, - severity: query.severity, - outcome: query.outcome, - from, - to, - }; -} - -/** Export takes both ends explicitly: the server refuses to guess a window. - * An open start is the epoch sentinel, and both preset and default windows - * resolve to concrete timestamps. */ -export function exportFilterParams(query: AuditQuery, now = Date.now()): QueryParams { - const params = apiParams(query, now); - const to = instant(query.to) ?? new Date(now).toISOString(); - const from = - instant(query.from) ?? - (query.since === "any" - ? EPOCH - : new Date(now - presetMs(query.since)).toISOString()); - return { ...params, from, to }; -} - -export function hasFilters(query: AuditQuery): boolean { - return !!( - query.q || - query.categories.length || - query.kinds.length || - query.actions.length || - query.actor || - query.target_kind || - query.target_id || - query.severity || - query.outcome || - query.from || - query.to - ); -} - -/** What the table says when the server returned no rows. An empty feed and a - * filter that matched nothing must not read the same. */ -export function emptyMessage(query: AuditQuery): string { - if (hasFilters(query)) return "No records match these filters."; - if (query.since === "any") return "No audit records yet."; - if (query.from || query.to) return "No records in this range."; - const window = query.since === "24h" ? "24 hours" : query.since === "7d" ? "7 days" : "30 days"; - return `No records in the last ${window}.`; -} - -export function presetLabel(query: AuditQuery): string { - if (query.from || query.to) return "Custom range"; - switch (query.since) { - case "any": - return "Any time"; - case "24h": - return "Last 24 hours"; - case "7d": - return "Last 7 days"; - default: - return "Last 30 days"; - } -} - -export interface AuditChip { - key: - | "kind" - | "action" - | "actor" - | "severity" - | "outcome" - | "target_kind" - | "target_id" - | "from" - | "to"; - value: string; - text: string; -} - -/** A server value read as a label: "access_policies" -> "Access policies". */ -export function valueLabel(value: string): string { - const words = value.replaceAll("_", " ").replaceAll("-", " "); - return words ? words.charAt(0).toUpperCase() + words.slice(1) : value; -} - -function settingsKindLabel(options: SettingsKind[], value: string): string { - return options.find((option) => option.kind === value)?.title ?? value; -} - -function localTime(value: string): string { - const date = new Date(value); - // In the zone chosen under Appearance, like Timestamp, not the browser's. - return Number.isNaN(date.getTime()) ? value : exactTime(date, useAppearanceStore().timeZone); -} - -/** The advanced and deep-link filters as removable chips. */ -export function filterChips(query: AuditQuery, facets: AuditFacets): AuditChip[] { - return [ - ...query.kinds.map((value) => ({ - key: "kind" as const, - value, - text: `Kind: ${settingsKindLabel(facets.settings_kinds, value)}`, - })), - ...query.actions.map((value) => ({ - key: "action" as const, - value, - text: `Action: ${value}`, - })), - ...(query.actor ? [{ key: "actor" as const, value: query.actor, text: `Actor: ${query.actor}` }] : []), - ...(query.severity - ? [ - { - key: "severity" as const, - value: query.severity, - text: `Severity: ${valueLabel(query.severity)}`, - }, - ] - : []), - // Denied has its own toggle; any other outcome is reachable only by URL, - // so it gets a chip or it would filter invisibly. - ...(query.outcome && query.outcome !== "denied" - ? [ - { - key: "outcome" as const, - value: query.outcome, - text: `Outcome: ${valueLabel(query.outcome)}`, - }, - ] - : []), - ...(query.target_kind - ? [ - { - key: "target_kind" as const, - value: query.target_kind, - text: `Target kind: ${valueLabel(query.target_kind)}`, - }, - ] - : []), - ...(query.target_id - ? [{ key: "target_id" as const, value: query.target_id, text: `Target: ${query.target_id}` }] - : []), - ...(query.from ? [{ key: "from" as const, value: query.from, text: `From: ${localTime(query.from)}` }] : []), - ...(query.to ? [{ key: "to" as const, value: query.to, text: `To: ${localTime(query.to)}` }] : []), - ]; -} - -export type AuditBadgeVariant = "danger" | "warn" | "info"; - -/** A textual badge carries severity; colour alone never does. An error is a - * failure of the event whether or not its outcome says success. */ -export function badgeFor(record: AuditRecord): { label: string; variant: AuditBadgeVariant } | null { - if (record.outcome === "denied") return { label: "Denied", variant: "danger" }; - if (record.outcome === "failure" || record.severity === "error") - return { label: "Failed", variant: "danger" }; - if (record.severity === "warning") return { label: "Warning", variant: "warn" }; - return null; -} - -/** One leaf per changed field, in the shape ChangeList renders. */ -export function changesFromFields(detail?: AuditDetail): Change[] { - return (detail?.fields ?? []).map((field, index) => ({ - path: field.field || `field ${index + 1}`, - before: field.old, - after: field.new, - })); -} - -export interface AuditMetadataRow { - key: string; - label: string; - value?: string; - mono?: boolean; -} - -function humanise(field: string): string { - return field.replaceAll("_", " ").replaceAll("-", " "); -} - -/** Label/value rows for a runtime event: its target, its data and how it was - * recorded. A settings change shows its diff instead. */ -export function metadataRows(record: AuditRecord): AuditMetadataRow[] { - const detail = record.detail ?? {}; - const rows: AuditMetadataRow[] = []; - if (!detail.fields?.length && hasTarget(record.target)) { - rows.push({ - key: "target", - label: "Target", - value: record.target?.label || record.target?.id || "", - }); - } - if (detail.data && typeof detail.data === "object" && !Array.isArray(detail.data)) { - for (const [key, value] of Object.entries(detail.data as Record)) { - rows.push({ - key: `data.${key}`, - label: humanise(key), - value: formatValue(value), - mono: typeof value !== "string", - }); - } - } else if (detail.data != null) { - rows.push({ key: "data", label: "Data", value: formatValue(detail.data), mono: true }); - } - if (detail.table) rows.push({ key: "table", label: "Table", value: detail.table, mono: true }); - if (detail.source) rows.push({ key: "source", label: "Source", value: detail.source, mono: true }); - if ((detail.version ?? 0) > 0) - rows.push({ key: "version", label: "Version", value: String(detail.version), mono: true }); - if (detail.request_id) - rows.push({ key: "request", label: "Request", value: detail.request_id, mono: true }); - return rows; -} - -export function recordKey(record: AuditRecord): string { - return record.id; -} - -/** A target exists when it names anything; an event may have none. */ -export function hasTarget(target?: AuditTarget): boolean { - return !!target && !!(target.kind || target.id); -} - -/** The dashboard route for a target. A task route is built from its id, so an - * older server href cannot send the operator to the wrong page. */ -export function targetHref(target?: AuditTarget): string { - if (target?.kind === "task" && target.id) - return `/tasks/${encodeURIComponent(target.id)}`; - return target?.href ?? ""; -} - -/** The target's own id when it adds anything beyond the label: the settings - * resource kind, a record key, or a task id. */ -export function targetDetail(target?: AuditTarget): string { - if (!target?.id) return ""; - const label = target.label ?? ""; - if (label && (label === target.id || label.endsWith(target.id))) return ""; - return target.id; -} - -/** Keeps the first occurrence, so a live page and an older page cannot show - * the same event twice. */ -export function dedupeRecords(records: AuditRecord[]): AuditRecord[] { - const seen = new Set(); - return records.filter((record) => { - const key = recordKey(record); - if (seen.has(key)) return false; - seen.add(key); - return true; - }); -} - -/** Saved views live in this browser, keyed by the signed-in identity. */ -export interface SavedAuditView { - name: string; - query: Record; -} - -function savedViewsKey(identityId: string): string { - return `archie.audit.views.${identityId}`; -} - -export function readSavedViews(identityId: string): SavedAuditView[] { - if (!identityId) return []; - try { - const raw = localStorage.getItem(savedViewsKey(identityId)); - if (!raw) return []; - const parsed: unknown = JSON.parse(raw); - if (!Array.isArray(parsed)) return []; - return parsed.flatMap((entry): SavedAuditView[] => { - if (!entry || typeof entry !== "object") return []; - const candidate = entry as { name?: unknown; query?: unknown }; - if (typeof candidate.name !== "string" || !candidate.name.trim()) return []; - if (!candidate.query || typeof candidate.query !== "object") return []; - const query = Object.fromEntries( - Object.entries(candidate.query as Record).map(([key, value]) => [ - key, - String(value), - ]), - ); - return [{ name: candidate.name, query }]; - }); - } catch { - return []; - } -} - -export function writeSavedViews(identityId: string, views: SavedAuditView[]): void { - if (!identityId) return; - try { - localStorage.setItem(savedViewsKey(identityId), JSON.stringify(views)); - } catch { - // The view still applies for this page; only persistence is lost. - } -} diff --git a/ui/src/audit/store.ts b/ui/src/audit/store.ts deleted file mode 100644 index 7edbab1da..000000000 --- a/ui/src/audit/store.ts +++ /dev/null @@ -1,165 +0,0 @@ -import { defineStore } from "pinia"; -import { ref } from "vue"; - -import { errors } from "@/copy/errors"; -import { ApiError, api, describeError, type QueryParams } from "@/lib/api"; -import { - apiParams, - dedupeRecords, - emptyFacets, - recordKey, - type AuditFacets, - type AuditQuery, - type AuditRecord, - type AuditResponse, -} from "./audit"; - -const PAGE_SIZE = 100; - -function failure(err: unknown): string { - if (err instanceof ApiError && err.status === 503) return errors.audit.unavailable; - return describeError(err, errors.audit.load); -} - -/** The server's vocabularies arrive with the first page; a later page that - * omits one must not blank the filters the operator is using. */ -function facetsFrom(next: AuditFacets | undefined, current: AuditFacets): AuditFacets { - if (!next) return current; - const pick = (incoming: T[] | undefined, previous: T[]): T[] => - incoming?.length ? incoming : previous; - return { - categories: pick(next.categories, current.categories), - severities: pick(next.severities, current.severities), - outcomes: pick(next.outcomes, current.outcomes), - target_kinds: pick(next.target_kinds, current.target_kinds), - settings_kinds: pick(next.settings_kinds, current.settings_kinds), - retention_kinds: pick(next.retention_kinds, current.retention_kinds), - }; -} - -/** One loaded audit feed. Filters live in the URL; this store owns only the - * pages fetched for the current filter. */ -export const useAuditStore = defineStore("audit", () => { - const records = ref([]); - const facets = ref(emptyFacets()); - const loading = ref(false); - const loadingMore = ref(false); - const error = ref(""); - const moreError = ref(""); - const nextCursor = ref(null); - const hasMore = ref(false); - - let generation = 0; - let pages = 1; - // Resolved once per filter load: the cursor is bound to these exact bounds. - let params: QueryParams = {}; - - async function load(query: AuditQuery): Promise { - const token = ++generation; - params = apiParams(query); - loading.value = true; - loadingMore.value = false; - error.value = ""; - moreError.value = ""; - records.value = []; - nextCursor.value = null; - hasMore.value = false; - pages = 1; - try { - const response = await api.audit({ ...params, limit: PAGE_SIZE }); - if (token !== generation) return; - records.value = dedupeRecords(response.records ?? []); - facets.value = facetsFrom(response.facets, facets.value); - nextCursor.value = response.next_cursor || null; - hasMore.value = !!response.has_more; - } catch (err) { - if (token !== generation) return; - error.value = failure(err); - } finally { - if (token === generation) loading.value = false; - } - } - - async function loadMore(): Promise { - if (!nextCursor.value || loading.value || loadingMore.value) return; - const token = generation; - loadingMore.value = true; - moreError.value = ""; - try { - const response = await api.audit({ - ...params, - cursor: nextCursor.value, - limit: PAGE_SIZE, - }); - if (token !== generation) return; - records.value = dedupeRecords([...records.value, ...(response.records ?? [])]); - nextCursor.value = response.next_cursor || null; - hasMore.value = !!response.has_more; - pages += 1; - } catch (err) { - if (token === generation) moreError.value = failure(err); - } finally { - if (token === generation) loadingMore.value = false; - } - } - - /** Merges a fresh page one into the loaded feed: an id already on screen - * keeps its place, replaced when the server now sends different content (a - * coalesced access decision count, for example). An unseen id is returned so the page can - * prepend it or hold it behind the new-events button. */ - function mergePageOne(incoming: AuditRecord[]): AuditRecord[] { - const positions = new Map(records.value.map((record, index) => [recordKey(record), index])); - const merged = records.value.slice(); - const added: AuditRecord[] = []; - let replaced = false; - for (const record of dedupeRecords(incoming)) { - const at = positions.get(recordKey(record)); - if (at === undefined) { - added.push(record); - continue; - } - if (JSON.stringify(merged[at]) === JSON.stringify(record)) continue; - merged[at] = record; - replaced = true; - } - if (replaced) records.value = merged; - return added; - } - - /** Re-reads page one after a live head. Returns the records this page did - * not already hold; the page decides whether to prepend or hold them. */ - async function refresh(): Promise { - if (loading.value || error.value) return []; - const token = generation; - const response = await api.audit({ ...params, limit: PAGE_SIZE }); - if (token !== generation) return []; - facets.value = facetsFrom(response.facets, facets.value); - // Only a single-page feed can take the new page-one cursor: a loaded older - // page is keyed to the cursor the operator is paging from. - if (pages === 1) { - nextCursor.value = response.next_cursor || null; - hasMore.value = !!response.has_more; - } - return mergePageOne(response.records ?? []); - } - - function prepend(incoming: AuditRecord[]): void { - if (!incoming.length) return; - records.value = dedupeRecords([...incoming, ...records.value]); - } - - return { - records, - facets, - loading, - loadingMore, - error, - moreError, - nextCursor, - hasMore, - load, - loadMore, - refresh, - prepend, - }; -}); diff --git a/ui/src/components/command-palette/CommandPalette.vue b/ui/src/components/command-palette/CommandPalette.vue index ddb979515..810af9e9b 100644 --- a/ui/src/components/command-palette/CommandPalette.vue +++ b/ui/src/components/command-palette/CommandPalette.vue @@ -16,16 +16,13 @@ import { Kbd } from "@/components/ui/kbd"; import { api } from "@/lib/api"; import { errors } from "@/copy/errors"; import { navEntries } from "@/lib/nav"; -import { statusLabel } from "@/lib/task-meta"; -import { useSessionStore } from "@/stores/session"; /** - * Jump to a page, a task or a workflow by name. Opened from the top bar, with - * Cmd/Ctrl+K, or with '/' when no field has focus. Tasks and workflows are - * read when the palette opens, so it never shows a stale list for long. + * Jump to a page or a workflow by name. Opened from the top bar, with + * Cmd/Ctrl+K, or with '/' when no field has focus. Workflows are read when the + * palette opens, so it never shows a stale list for long. */ const props = defineProps<{ hidden: string[] }>(); -const emit = defineEmits<{ newTask: [] }>(); const router = useRouter(); const open = ref(false); @@ -36,35 +33,19 @@ function onCloseAutoFocus(event: Event): void { document.getElementById("main-content")?.focus({ preventScroll: true }); } -interface TaskEntry { - id: number | string; - title?: string; - status?: string; -} - const pages = computed(() => navEntries(props.hidden)); -const tasks = ref([]); const workflows = ref<{ id: string; name: string }[]>([]); const shortcut = navigator.platform.startsWith("Mac") ? "⌘K" : "Ctrl K"; -const session = useSessionStore(); const showWorkflows = computed(() => !props.hidden.includes("/workflows")); -const showTasks = computed(() => !props.hidden.includes("/tasks")); -const showNewTask = computed(() => session.sections?.work_requests !== false); // A failed read shows as an error item with Retry in that group, not as a // missing group: the pages still work either way. -const tasksError = ref(false); const workflowsError = ref(false); let entriesGeneration = 0; async function loadEntries(): Promise { const current = ++entriesGeneration; - const [taskPage, workflowList] = await Promise.all([ - showTasks.value ? api.taskPage({ limit: 100 }).catch(() => null) : { tasks: [] }, - showWorkflows.value ? api.workflowList().catch(() => null) : [], - ]); + const workflowList = showWorkflows.value ? await api.workflowList().catch(() => null) : []; if (current !== entriesGeneration) return; - tasksError.value = taskPage === null; - tasks.value = taskPage?.tasks ?? []; workflowsError.value = workflowList === null; workflows.value = (workflowList ?? []).map(({ id, name }) => ({ id, name })); } @@ -78,11 +59,6 @@ function go(path: string): void { void router.push(path); } -function newTask(): void { - open.value = false; - emit("newTask"); -} - function onGlobalKeydown(event: KeyboardEvent): void { if ((event.metaKey || event.ctrlKey) && event.key.toLowerCase() === "k") { event.preventDefault(); @@ -106,17 +82,10 @@ onUnmounted(() => document.removeEventListener("keydown", onGlobalKeydown)); Jump to {{ shortcut }} - - + + No matches. - - New task - - - Tasks in progress - Tasks needing attention - document.removeEventListener("keydown", onGlobalKeydown)); {{ workflow.name }} - - {{ errors.components.commandPalette.tasks }} - - - - #{{ task.id }} - {{ task.title }} - {{ - statusLabel(task.status) - }} - - diff --git a/ui/src/components/topbar/AccountMenu.vue b/ui/src/components/topbar/AccountMenu.vue index 5cbc2b885..a22b84f27 100644 --- a/ui/src/components/topbar/AccountMenu.vue +++ b/ui/src/components/topbar/AccountMenu.vue @@ -1,5 +1,5 @@ diff --git a/ui/src/components/topbar/SectionCrumb.vue b/ui/src/components/topbar/SectionCrumb.vue index 73510882f..1f862b434 100644 --- a/ui/src/components/topbar/SectionCrumb.vue +++ b/ui/src/components/topbar/SectionCrumb.vue @@ -1,10 +1,8 @@ @@ -55,7 +40,6 @@ const hover = useHoverOpen(); @@ -64,7 +48,6 @@ const hover = useHoverOpen(); diff --git a/ui/src/copy/errors/alerts.ts b/ui/src/copy/errors/alerts.ts deleted file mode 100644 index 2b2847ca9..000000000 --- a/ui/src/copy/errors/alerts.ts +++ /dev/null @@ -1,5 +0,0 @@ -export const alerts = { - load: "Alerts could not be loaded.", - dismiss: (detail: string) => `Dismiss failed: ${detail}`, - webhookDelivery: "Webhook delivery failed.", -} as const; diff --git a/ui/src/copy/errors/audit.ts b/ui/src/copy/errors/audit.ts deleted file mode 100644 index bed9c5b6f..000000000 --- a/ui/src/copy/errors/audit.ts +++ /dev/null @@ -1,13 +0,0 @@ -export const audit = { - unavailable: "Audit is unavailable.", - load: "Audit could not be loaded.", - refresh: "Audit could not refresh.", - revert: { - resourceLoad: "That resource could not be loaded.", - unavailable: "That earlier version is no longer available.", - }, - retention: { - unavailable: "Retention settings are unavailable.", - save: "Retention could not be saved.", - }, -} as const; diff --git a/ui/src/copy/errors/bindings.ts b/ui/src/copy/errors/bindings.ts deleted file mode 100644 index f8c8ea4bb..000000000 --- a/ui/src/copy/errors/bindings.ts +++ /dev/null @@ -1,19 +0,0 @@ -// 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", - }, - dispatchLinks: { - unavailable: "Dispatches unavailable.", - noTask: "claimed, no task recorded", - noReason: "no reason recorded", - accessDenied: "access policy refused to start", - workflowDisabled: "is disabled", - }, -} as const; diff --git a/ui/src/copy/errors/index.ts b/ui/src/copy/errors/index.ts index 7c48f2a4d..542a1f2e1 100644 --- a/ui/src/copy/errors/index.ts +++ b/ui/src/copy/errors/index.ts @@ -2,17 +2,13 @@ // dot-walk it, e.g. errors.chat.turn.stop, so the copy is // changed here and nowhere else. import { accounts } from "./accounts.ts"; -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 { channels } from "./channels.ts"; import { chat } from "./chat.ts"; import { common } from "./common.ts"; import { components } from "./components.ts"; import { dashboard } from "./dashboard.ts"; -import { logs } from "./logs.ts"; import { mappings } from "./mappings.ts"; import { org } from "./org.ts"; import { settings } from "./settings.ts"; @@ -22,17 +18,13 @@ import { workflows } from "./workflows.ts"; export const errors = { accounts, - alerts, app, - audit, base, - bindings, channels, chat, common, components, dashboard, - logs, mappings, org, settings, diff --git a/ui/src/copy/errors/logs.ts b/ui/src/copy/errors/logs.ts deleted file mode 100644 index 27c9137df..000000000 --- a/ui/src/copy/errors/logs.ts +++ /dev/null @@ -1,10 +0,0 @@ -// Failure and empty-state copy for the log page. -export const logs = { - read: { - unreadable: "Cannot read logs", - }, - empty: { - streamUnavailable: "Log stream unavailable", - streamUnavailableDetail: "This process is not delivering live daemon logs.", - }, -} as const; diff --git a/ui/src/copy/errors/org.ts b/ui/src/copy/errors/org.ts index bdce12224..e2c8b4ec7 100644 --- a/ui/src/copy/errors/org.ts +++ b/ui/src/copy/errors/org.ts @@ -1,7 +1,4 @@ export const org = { - identities: { - unavailable: "Unavailable identity", - }, rename: { conflict: (name: string) => `The name is now “${name}”. Save again to replace it.`, }, diff --git a/ui/src/curators/CuratorAction.vue b/ui/src/curators/CuratorAction.vue deleted file mode 100644 index a0cc0c4ae..000000000 --- a/ui/src/curators/CuratorAction.vue +++ /dev/null @@ -1,33 +0,0 @@ - - - - - diff --git a/ui/src/curators/CuratorCard.vue b/ui/src/curators/CuratorCard.vue deleted file mode 100644 index 82e9a7775..000000000 --- a/ui/src/curators/CuratorCard.vue +++ /dev/null @@ -1,73 +0,0 @@ - - - - - diff --git a/ui/src/dashboard/ActivityRow.vue b/ui/src/dashboard/ActivityRow.vue deleted file mode 100644 index f1fe61e6b..000000000 --- a/ui/src/dashboard/ActivityRow.vue +++ /dev/null @@ -1,64 +0,0 @@ - - - diff --git a/ui/src/dashboard/QuickTask.vue b/ui/src/dashboard/QuickTask.vue deleted file mode 100644 index ccfb7b43a..000000000 --- a/ui/src/dashboard/QuickTask.vue +++ /dev/null @@ -1,104 +0,0 @@ - - - diff --git a/ui/src/dashboard/SetupPanel.vue b/ui/src/dashboard/SetupPanel.vue deleted file mode 100644 index 108772f13..000000000 --- a/ui/src/dashboard/SetupPanel.vue +++ /dev/null @@ -1,52 +0,0 @@ - - - diff --git a/ui/src/dashboard/activity-detail.ts b/ui/src/dashboard/activity-detail.ts deleted file mode 100644 index ec39ac63b..000000000 --- a/ui/src/dashboard/activity-detail.ts +++ /dev/null @@ -1,60 +0,0 @@ -// Live activity's detail column. -// -// The daemon puts whatever a stage produced into an event's detail, so the -// column holds anything from "session-memory" to a few thousand characters of -// agent transcript. Printed raw, one row would dwarf the table. -// -// The rule is one line in the cell, the whole payload still available. The cut -// happens here rather than in CSS because the row also needs to know whether -// there is more to show. - -// Long enough for a useful parked reason, short enough that every row is the -// same height at the widths the table is used at. -const CELL_LIMIT = 160; - -/** An activity event, as far as this column reads it. Deliberately narrower - * than the event the dashboard holds: this is the whole of what the cell - * renders, so a caller can pass anything carrying either field. */ -export interface ActivityDetailInput { - detail?: unknown; - message?: unknown; - actor_id?: string; - principal_id?: string; -} - -/** The cell's content: the rendered line, the payload, and whether they differ. */ -export interface ActivityDetail { - text: string; - full: string; - truncated: boolean; -} - -/** - * activityDetail returns `{ text, full, truncated }` for one event: - * `text` is the single line the cell renders, `full` the untouched payload, - * and `truncated` whether the two differ. - */ -export function activityDetail( - event: ActivityDetailInput | undefined, - identityName?: (id: string) => string, -): ActivityDetail { - let full = String(event?.detail || event?.message || ""); - if (identityName) { - for (const id of [event?.actor_id, event?.principal_id]) - if (id) full = full.replaceAll(id, identityName(id)); - } - if (!full) return { text: "", full: "", truncated: false }; - - // The first line that says something: agent output often opens with blanks. - const firstLine = - full - .split("\n") - .map((line) => line.trim()) - .find(Boolean) || ""; - const clipped = - firstLine.length > CELL_LIMIT - ? `${firstLine.slice(0, CELL_LIMIT).trimEnd()}…` - : firstLine; - - return { text: clipped, full, truncated: clipped !== full }; -} diff --git a/ui/src/dashboard/activity-filter.ts b/ui/src/dashboard/activity-filter.ts deleted file mode 100644 index 685df39eb..000000000 --- a/ui/src/dashboard/activity-filter.ts +++ /dev/null @@ -1,65 +0,0 @@ -/** - * The live activity feed's filter. - * - * Every event the dashboard receives belongs either to a task run or to the - * daemon's own background work, and the two are read for different reasons: - * "what is my work doing" against "what is the daemon doing". A task event is - * one that resolves to a task -- the same test the table's rows already use to - * link an event to a task -- so the filter can never disagree with the links - * inside the rows it is filtering. - */ - -export type ActivityFilter = "all" | "tasks" | "system"; - -/** An event as far as the filter reads it: the task it belongs to, if any. */ -export interface ActivityFilterInput { - task_id?: number | string | null; -} - -/** The three views, in the order the header renders them. */ -export const ACTIVITY_FILTERS: { value: ActivityFilter; label: string }[] = [ - { value: "tasks", label: "Tasks" }, - { value: "system", label: "System" }, - { value: "all", label: "All" }, -]; - -/** belongsToTask is the same test the rows use to point an event at a task. */ -function belongsToTask( - event: ActivityFilterInput | null | undefined, -): boolean { - return (Number(event?.task_id) || 0) > 0; -} - -/** matchesActivityFilter decides one event, so a group row can be judged by the - * events it stands for. */ -export function matchesActivityFilter( - event: ActivityFilterInput | null | undefined, - filter: ActivityFilter, -): boolean { - if (filter === "tasks") return belongsToTask(event); - if (filter === "system") return !belongsToTask(event); - return true; -} - -/** filterActivity keeps the events a view is about, in arrival order. The two - * narrow views partition the feed: nothing shows in both, nothing in neither. */ -export function filterActivity( - events: readonly T[], - filter: ActivityFilter, -): T[] { - return events.filter((event) => matchesActivityFilter(event, filter)); -} - -/** - * activityEmptyTitle words the empty state. A feed with nothing in it and a - * feed this view emptied are different facts, and a blank title means there are - * rows to show, so the caller renders no empty state at all. - */ -export function activityEmptyTitle( - visible: number, - filter: ActivityFilter, -): string { - if (visible > 0) return ""; - if (filter === "all") return "No activity yet"; - return filter === "tasks" ? "Archie is waiting for a task" : "No system events yet"; -} diff --git a/ui/src/dashboard/activity-group.ts b/ui/src/dashboard/activity-group.ts deleted file mode 100644 index 7b440fbad..000000000 --- a/ui/src/dashboard/activity-group.ts +++ /dev/null @@ -1,67 +0,0 @@ -import type { ActivityEvent } from "../stores/tasks.ts"; -import { activityDetail } from "./activity-detail.ts"; - -/** - * The live activity feed's grouping projection. - * - * The daemon emits high-frequency background telemetry that arrives as dozens - * of same-shape rows an hour, often as an interleave of kinds (a curator - * cycle emits curator_run, session-memory and curator_action events that all - * carry the same payload). Printed raw, the table stops being scannable and - * real milestones drown. - * - * The rule: a *run of consecutive* events sharing one task and one rendered - * detail collapses into a single group row. Kind is deliberately not part of - * the key: an interleave of kinds over one payload is one cycle of noise, - * not three events, so anything else stays on its own line, and a milestone - * is never merged with an event carrying different information. The grouping - * is consecutive, not global, so interleaved events keep their order and - * nothing is reordered under the operator. - * - * This is a pure view projection over the store's raw stream: the store keeps - * every event, and this module decides only how the feed presents them. - */ - -/** One displayed row: either a single event (count 1) or a collapsed run. */ -export interface ActivityGroup { - /** Stable identity of the run: the grouping key of its first event. */ - key: string; - /** The resolved label the row shows, matching the Event column's fallback. */ - label: string; - /** The task the group's events resolve to, or 0 for none. */ - taskID: number; - /** How many events the group carries; 1 means an uncollapsed row. */ - count: number; - /** The newest event of the run -- what the row shows while collapsed. */ - representative: ActivityEvent; - /** Every event in the run, newest first. */ - events: ActivityEvent[]; -} - -function groupKey(detail: string, taskID: number | undefined): string { - return `${detail}:${taskID ?? 0}`; -} - -export function groupActivity(events: ActivityEvent[]): ActivityGroup[] { - const groups: ActivityGroup[] = []; - for (const event of events) { - const label = event.kind || event.type || "event"; - const taskID = Number(event.task_id) || 0; - const key = groupKey(activityDetail(event).text, taskID); - const last = groups[groups.length - 1]; - if (last && last.key === key) { - last.count += 1; - last.events.push(event); - continue; - } - groups.push({ - key, - label, - taskID, - count: 1, - representative: event, - events: [event], - }); - } - return groups; -} diff --git a/ui/src/dashboard/setup-preference.ts b/ui/src/dashboard/setup-preference.ts deleted file mode 100644 index 36f045f18..000000000 --- a/ui/src/dashboard/setup-preference.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** One setup step as the daemon reports it. */ -interface SetupStep { - title: string; - detail?: string; - done: boolean; - /** The page that fixes an unfinished step, so the checklist is a set of - * links rather than a description of work with nowhere to go. */ - path?: string; -} - -export interface Setup { - steps: SetupStep[]; -} - -export interface SetupPanelState { - /** omit: nothing to show, either no setup data or setup fully done. */ - kind: "omit" | "incomplete"; - remaining: SetupStep[]; -} - -// setupPanelState distinguishes the only two states worth rendering: there is -// setup work left (the checklist), or there is not (nothing: a configured -// daemon is the absence of a problem, not a card announcing it). -export function setupPanelState( - setup: Setup | null | undefined, -): SetupPanelState { - const remaining = (setup?.steps ?? []).filter((step) => !step.done); - if (!setup?.steps?.length || !remaining.length) { - return { kind: "omit", remaining: [] }; - } - return { kind: "incomplete", remaining }; -} diff --git a/ui/src/dashboard/state.ts b/ui/src/dashboard/state.ts deleted file mode 100644 index 70b7e92a6..000000000 --- a/ui/src/dashboard/state.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { onMounted } from "vue"; - -import { useTasksStore } from "@/stores/tasks"; - -/** Fetches the board when the page opens; the shell keeps it live. */ -export function useDashboard(): void { - onMounted(useTasksStore().load); -} diff --git a/ui/src/lib/api.ts b/ui/src/lib/api.ts index e48effa1e..f002f67d8 100644 --- a/ui/src/lib/api.ts +++ b/ui/src/lib/api.ts @@ -371,7 +371,6 @@ export const api = { deletePasskey: (id:string) => request(`/api/account/passkeys/${encodeURIComponent(id)}`,{method:"DELETE",body:{},parse:false}), beginPasskey: (registration:boolean) => request(registration?"/api/account/passkeys/begin":"/api/auth/passkey/begin",{method:"POST",body:{}}), finishPasskey: (registration:boolean,credential:unknown,name:string) => request(registration?"/api/account/passkeys/finish":"/api/auth/passkey/finish",{method:"POST",body:{credential,name}}), - checkSecret: (ref: { engine: string; key: string }) => request<{ resolved: boolean; process: string }>("/api/secret-references/check", { method: "POST", body: ref }), notes: () => request("/api/memory/notes"), rememberNote: (text: string) => request("/api/memory/notes", { method: "POST", body: { text } }), correctNote: (id: string, text: string) => @@ -401,21 +400,7 @@ export const api = { request<{ version: number }>("/api/access/policies", { method: "PUT", body: policy }), deletePolicy: (policy: unknown) => request("/api/access/policies", { method: "DELETE", body: policy, parse: false }), - schedules: () => request("/api/schedules"), - // scheduleSave creates or replaces the schedule with this id. - scheduleSave: (id: string, schedule: unknown) => - request(`/api/schedules/${encodeURIComponent(id)}`, { method: "PUT", body: schedule }), - scheduleDelete: (id: string) => - request(`/api/schedules/${encodeURIComponent(id)}`, { method: "DELETE", parse: false }), - scheduleRunNow: (id: string) => - request(`/api/schedules/${encodeURIComponent(id)}/runs`, { method: "POST", body: {} }), - scheduleRuns: (id: string) => - request(`/api/schedules/${encodeURIComponent(id)}/runs`), orgs: () => request("/api/orgs"), - // orgSelect sets the org the caller's tasks, workflows and settings act in; - // the server refuses one the caller is not a member of. - orgSelect: (id: string) => - request("/api/orgs/current", { method: "PUT", body: { id }, parse: false }), // orgCreate makes an org with its default workspace and first owner; only // an instance admin may. orgCreate: (org: { id: string; name: string; owner_identity: string }) => @@ -447,7 +432,6 @@ export const api = { // orgHistory lists the org's appended name changes, newest first. orgHistory: (id: string) => request(`/api/orgs/${encodeURIComponent(id)}/history`), - orgAgents: (id: string) => request(`/api/orgs/${encodeURIComponent(id)}/agents`), orgMembers: (id: string) => request(`/api/orgs/${encodeURIComponent(id)}/members`), orgMemberCandidates: (id: string) => @@ -486,14 +470,6 @@ export const api = { `/api/orgs/${encodeURIComponent(id)}/members/${encodeURIComponent(identity)}/reactivate`, { method: "POST", parse: false }, ), - assignOrgAgent: (id: string, identity: string) => - request( - `/api/orgs/${encodeURIComponent(id)}/agents/${encodeURIComponent(identity)}`, - { method: "PUT" }, - ), - alerts: () => request("/api/alerts"), - dismissAlert: (id: number) => - request(`/api/alerts/${id}/dismiss`, { method: "POST", parse: false }), channelLinks: () => request("/api/account/channels"), /** Issues a single-use code and returns the URL that sends it to the channel. */ beginChannelLink: (connector: string) => @@ -503,95 +479,8 @@ export const api = { method: "DELETE", parse: false, }), - identities: () => request("/api/identities"), - identityCreate: (identity: { display_name: string; kind: string }) => - request("/api/identities", { method: "POST", body: identity }), - // identityCommand runs one lifecycle command (rename, suspend, reactivate, - // retire) against the version the caller last read. - identityCommand: (id: string, command: string, body: { expected_version: number; display_name: string }) => - request(`/api/identities/${encodeURIComponent(id)}/${encodeURIComponent(command)}`, { method: "POST", body }), - summary: () => request("/api/summary"), - // usage reads the org's model usage for the last days. The server derives - // the org from the caller and clamps days to 1..365. - usage: (days = 30) => request("/api/usage" + qs({ days })), - tasks: () => request("/api/tasks"), - // taskPage reads one page of the board; next is the cursor for the page - // after it, or null when this page was the last. - taskPage: async (params: QueryParams) => { - const res = await send("/api/tasks" + qs(params), { - headers: { Accept: "application/json" }, - signal: AbortSignal.timeout(DEFAULT_TIMEOUT_MS), - }); - return { - tasks: (await res.json()) as T[], - next: res.headers.get("X-Next-Cursor"), - }; - }, - taskMeta: () => request("/api/task-meta"), - task: (id: string) => - request(`/api/tasks/${encodeURIComponent(id)}`), - taskAttempts: (id: string) => - request(`/api/tasks/${encodeURIComponent(id)}/attempts`), - taskChanges: (id: string, params?: QueryParams) => - request(`/api/tasks/${encodeURIComponent(id)}/changes` + qs(params)), - taskDebug: (id: string, params?: QueryParams) => - request(`/api/tasks/${encodeURIComponent(id)}/debug` + qs(params)), - taskTranscript: (id: string, params?: QueryParams) => - request(`/api/tasks/${encodeURIComponent(id)}/transcript` + qs(params)), - // taskAction posts an operator action. A review-gate answer may carry a - // payload: the instructions a rereview requires, and the finding keys an - // approve posts (an absent selection means every offered finding). A retry - // carries the worktree mode the operator chose, and may name the step it - // resumes from. Every other action sends - // none. - taskAction: ( - id: string, - action: string, - payload?: { - instructions?: string; - findings?: string[]; - retry_mode?: string; - resume_from?: string; - current_definition?: boolean; - }, - ) => - request(`/api/tasks/${encodeURIComponent(id)}/action`, { - method: "POST", - body: { action, ...payload }, - }), - setup: () => request("/api/setup"), - capabilities: () => request("/api/capabilities"), workflows: () => request("/api/workflows"), - checkRepository: (input: { owner: string; repository: string; identity_id: string }) => request("/api/control-plane/resources/repository-policies/check", { method: "POST", body: input, timeoutMs: 35000 }), - repositories: () => request("/api/repositories"), - workRequest: (workRequest: Payload) => - request("/api/work-requests", { method: "POST", body: workRequest }), - skills: () => request("/api/skills"), - channels: () => request("/api/channels"), - curators: () => request("/api/curators"), - channelReload: (id: string) => - request(`/api/channels/${encodeURIComponent(id)}/reload`, { - method: "POST", - body: {}, - }), - config: () => request("/api/config"), - // The audit feed is filtered and paginated on the server; export is a - // browser navigation, so its URL is built here beside the request. - audit: (params: QueryParams = {}) => request("/api/audit" + qs(params)), - auditExportURL: (format: "csv" | "json", params: QueryParams = {}) => - "/api/audit/export" + qs({ ...params, format }), - logs: (params?: QueryParams) => - request("/api/logs" + qs(params)), - taskLogs: (id: string, params?: QueryParams) => - request(`/api/tasks/${encodeURIComponent(id)}/logs` + qs(params)), - // A download is a navigation, not a fetch: the browser must own the - // Content-Disposition filename and stream the body to disk rather than hold - // a whole log in memory. The URL builder is the client-side contract, and - // log-row keeps it beside the panel that uses it. - taskLogDownloadURL: (id: string, attempt?: number | null) => - `/api/tasks/${encodeURIComponent(id)}/logs/download` + - (attempt == null ? "" : `?attempt=${attempt}`), - version: () => request("/api/version"), + capabilities: () => request("/api/capabilities"), captures: (limit?: number) => request("/api/captures" + qs({ limit })), eventTypes: () => request("/api/event-types"), @@ -626,32 +515,6 @@ export const api = { method: "POST", body: { capture_id: captureId, fields }, }), - bindings: (workspace?: string) => - request("/api/bindings" + qs({ workspace })), - dispatches: (kind: "bindings" | "captures" | "tasks", id: string) => - request(`/api/${kind}/${encodeURIComponent(id)}/dispatches`), - bindingCreate: (binding: Payload) => - request("/api/bindings", { method: "POST", body: binding }), - bindingUpdate: (id: string, binding: Payload) => - request(`/api/bindings/${encodeURIComponent(id)}`, { - method: "PATCH", - body: binding, - }), - bindingDelete: (id: string) => - request(`/api/bindings/${encodeURIComponent(id)}`, { - method: "DELETE", - parse: false, - }), - bindingApprove: (id: string) => - request(`/api/bindings/${encodeURIComponent(id)}/approve`, { - method: "POST", - }), - // bindingPause stops an armed binding; bindingResume returns it to pending - // approval. - bindingPause: (id: string) => - request(`/api/bindings/${encodeURIComponent(id)}/pause`, { method: "POST" }), - bindingResume: (id: string) => - request(`/api/bindings/${encodeURIComponent(id)}/resume`, { method: "POST" }), sourceSigning: (id: string, signed: boolean) => request(`/api/sources/${encodeURIComponent(id)}/signing`, { method: "POST", @@ -930,16 +793,32 @@ export interface ApprovalConfirmation { options: { publicKey: Record }; } +/** One action an approval request covers, in the order the request covers + * them: the first action, or the whole sequence one request asks about. */ +export interface ApprovalStep { + decision_id: string; + /** The connector and action, as "connector action". */ + action: string; + /** "kind:id". */ + target: string; + level: string; +} + export interface Approval { id: string; run_id: string; step: number; kind: string; + /** The connector and action of the request's first action. */ action: string; + /** The first action's "kind:id" target. */ target: string; level: string; summary: string; state: string; + /** The actions the request covers, in the order they run. An autonomy + * proposal covers none. */ + steps?: ApprovalStep[]; requested_at: string; deadline?: string; answered_at?: string; diff --git a/ui/src/lib/task-meta-snapshot.ts b/ui/src/lib/task-meta-snapshot.ts index efcd97c49..ff1109a91 100644 --- a/ui/src/lib/task-meta-snapshot.ts +++ b/ui/src/lib/task-meta-snapshot.ts @@ -1,8 +1,9 @@ -// The freeze-dried /api/task-meta catalog the dashboard renders before the -// served one arrives, or when archied is unreachable; task-meta.ts replaces it -// with the live catalog. +// The lifecycle statuses the dashboard draws, and the severity and "needs you" +// grouping each one carries. The single binary serves no catalogue for these, +// so this snapshot is the vocabulary; a status it doesn't list renders as its +// own id with an idle pill. -/** A lifecycle status as the server describes it. */ +/** A lifecycle status as the dashboard draws it. */ export interface StatusMeta { id: string; label: string; @@ -10,29 +11,6 @@ export interface StatusMeta { needs_attention?: boolean; } -/** An operator control as the server describes it. */ -export interface ActionMeta { - id: string; - label: string; - kind: string; - confirm?: string; -} - -/** A changes_captured file status as the server describes it. */ -export interface ChangeStatusMeta { - id: string; - label: string; -} - -/** A retry worktree mode as the server describes it. */ -export interface RetryModeMeta { - id: string; - label: string; - description: string; - default?: boolean; - requires_branch?: boolean; -} - export const DEFAULT_STATUSES: StatusMeta[] = [ { id: "queued", label: "Queued", kind: "idle" }, { id: "running", label: "Running", kind: "info" }, @@ -50,74 +28,3 @@ export const DEFAULT_STATUSES: StatusMeta[] = [ { id: "rejected", label: "Rejected", kind: "danger" }, { id: "closed_wont_do", label: "Won't do", kind: "idle" }, ]; - -export const DEFAULT_ACTIONS: ActionMeta[] = [ - { - id: "cancel", - label: "Cancel", - kind: "quiet", - confirm: `Cancel "{title}"? Closes the issue.`, - }, - { - id: "stop", - label: "Stop", - kind: "primary", - confirm: `Stop "{title}"? Work stays parked.`, - }, - { id: "approve", label: "Approve", kind: "primary" }, - { id: "rereview", label: "Re-review", kind: "quiet" }, - { - id: "reject", - label: "Reject", - kind: "quiet", - confirm: `Reject "{title}"? Closes the issue.`, - }, - { id: "retry", label: "Retry", kind: "primary" }, - { - id: "abandon", - label: "Abandon", - kind: "quiet", - confirm: `Abandon "{title}"? The issue stays open.`, - }, - { - id: "archive", - label: "Archive", - kind: "quiet", - confirm: `Archive the local record for "{title}"?`, - }, - { - id: "merge", - label: "Merge", - kind: "primary", - confirm: `Merge the pull request for "{title}"?`, - }, - { id: "open_pr", label: "Open PR", kind: "link" }, - { id: "open_issue", label: "Open issue", kind: "link" }, -]; - -export const DEFAULT_CHANGE_STATUSES: ChangeStatusMeta[] = [ - { id: "added", label: "Added" }, - { id: "modified", label: "Modified" }, - { id: "deleted", label: "Deleted" }, - { id: "renamed", label: "Renamed" }, - { id: "typechange", label: "Type changed" }, -]; - -export const DEFAULT_RETRY_MODES: RetryModeMeta[] = [ - { - id: "refresh_onto_base", - label: "Refresh onto base", - description: - "Retry from the current base; discards pushed commits.", - default: true, - }, - { - id: "continue_pushed_work", - label: "Continue pushed work", - description: - "Resume the pushed branch.", - requires_branch: true, - }, -]; - -export const DEFAULT_CONFIG_SCHEMA = "archie/task-config@1"; diff --git a/ui/src/lib/task-meta.ts b/ui/src/lib/task-meta.ts index 8daf50a55..1ebc7b22b 100644 --- a/ui/src/lib/task-meta.ts +++ b/ui/src/lib/task-meta.ts @@ -1,93 +1,23 @@ -// Central lifecycle vocabulary for the dashboard. The backend is the source of -// truth: /api/task-meta returns the statuses (label, pill severity, "needs you" -// grouping) and operator actions (label, button variant, confirm prompt). This -// module fetches that catalog and exposes the accessors the rest of the UI -// reads, so no surface keeps a hand-synced copy of the vocabulary. +// Lifecycle vocabulary for the dashboard: the status labels, pill severities +// and "needs you" grouping the shell and the stage rail draw. // -// The defaults below are a freeze-dried snapshot that render immediately and -// keep working when archied is unreachable; loadTaskMeta() replaces them with -// the live catalog as soon as it arrives. They must match the backend catalog -// so drawing the page never flashes a stale label. -// -// loadTaskMeta() is called once at boot by main.ts. The catalog is held in -// refs, so a late-arriving catalog re-renders whatever already read it; there -// is no separate "re-render the mounted route" step the way the Preact shell -// needed one. -// -// The dashboard draws a line here between two kinds of vocabulary. Anything -// that is *presentation* -- a status's label, pill severity and "needs you" -// grouping, or a control's label and confirm prompt -- is served, because the -// server owns the words as well as the ids. -import { computed, shallowRef } from "vue"; - -import { api } from "./api"; +// The single binary serves no catalogue for this, so the vocabulary is the +// snapshot in task-meta-snapshot.ts. Keep it in step with the statuses the +// binary reports; a status it doesn't list renders as its own id. import type { StatusKind } from "./status"; -import { - type ActionMeta, - type ChangeStatusMeta, - DEFAULT_ACTIONS, - DEFAULT_CHANGE_STATUSES, - DEFAULT_CONFIG_SCHEMA, - DEFAULT_RETRY_MODES, - DEFAULT_STATUSES, - type RetryModeMeta, - type StatusMeta, -} from "./task-meta-snapshot"; +import { DEFAULT_STATUSES, type StatusMeta } from "./task-meta-snapshot"; -export type { ActionMeta, RetryModeMeta, StatusMeta }; - -const statuses = shallowRef([...DEFAULT_STATUSES]); -const actions = shallowRef([...DEFAULT_ACTIONS]); -const retryModesRef = shallowRef([...DEFAULT_RETRY_MODES]); -const changeStatuses = shallowRef([ - ...DEFAULT_CHANGE_STATUSES, -]); -const configSchemaRef = shallowRef(DEFAULT_CONFIG_SCHEMA); - -const statusById = computed( - () => new Map(statuses.value.map((s) => [s.id, s])), -); -const actionById = computed(() => new Map(actions.value.map((a) => [a.id, a]))); -const changeStatusById = computed( - () => new Map(changeStatuses.value.map((c) => [c.id, c])), -); - -// loadTaskMeta upgrades the dashboard from the server catalog. It never throws: -// a failed fetch keeps the defaults so the UI still renders. -export async function loadTaskMeta(): Promise { - try { - const data = await api.taskMeta<{ - statuses?: StatusMeta[]; - actions?: ActionMeta[]; - retry_modes?: RetryModeMeta[]; - change_statuses?: ChangeStatusMeta[]; - config_schema?: string; - } | null>(); - if (Array.isArray(data?.statuses)) statuses.value = data.statuses; - if (Array.isArray(data?.actions)) actions.value = data.actions; - if (Array.isArray(data?.retry_modes)) retryModesRef.value = data.retry_modes; - if (Array.isArray(data?.change_statuses)) - changeStatuses.value = data.change_statuses; - if (data?.config_schema) configSchemaRef.value = data.config_schema; - } catch { - // archied unreachable or not yet serving this route; keep the defaults. - } -} +const statusById = new Map(DEFAULT_STATUSES.map((s) => [s.id, s])); /** statusLabel is the human-readable name for a lifecycle status. */ export function statusLabel(id: string): string { - return statusById.value.get(id)?.label || id || "Unknown"; + return statusById.get(id)?.label || id || "Unknown"; } /** statusKind is the pill severity token (idle, info, ok, warn, danger). */ export function statusKind(id: string): StatusKind { - return (statusById.value.get(id)?.kind || "idle") as StatusKind; -} - -/** statusList returns every known lifecycle status in display order. */ -export function statusList(): StatusMeta[] { - return statuses.value; + return (statusById.get(id)?.kind || "idle") as StatusKind; } /** @@ -95,42 +25,5 @@ export function statusList(): StatusMeta[] { * filter (work that needs attention). */ export function attentionStatusIds(): Set { - return new Set(statuses.value.filter((s) => s.needs_attention).map((s) => s.id)); + return new Set((DEFAULT_STATUSES as StatusMeta[]).filter((s) => s.needs_attention).map((s) => s.id)); } - -/** - * actionFor returns the presentation metadata for an operator control, or null - * if the backend has never seen it. - */ -export function actionFor(id: string): ActionMeta | null { - return actionById.value.get(id) || null; -} - -/** - * retryModes returns the server's retry worktree modes in display order. The - * retry dialog renders these and falls back to the frozen snapshot before the - * catalog arrives. - */ -export function retryModes(): RetryModeMeta[] { - return retryModesRef.value; -} - -/** - * changeStatusLabel names a changes_captured file status. An id the catalog - * does not know renders as itself rather than breaking the row. - */ -export function changeStatusLabel(id: string | undefined): string { - return (id && changeStatusById.value.get(id)?.label) || id || "unknown"; -} - -/** configSchema is the schema stamp a recognised config_captured payload carries. */ -export function configSchema(): string { - return configSchemaRef.value; -} - -/** What a task waiting for approval asks the operator to decide. */ -export const approvalLabels: Record = { - plan: "Plan", - review: "Review findings", - budget: "Continue?", -}; diff --git a/ui/src/lib/webmcp-tools.ts b/ui/src/lib/webmcp-tools.ts index 447416ce3..95f138aa4 100644 --- a/ui/src/lib/webmcp-tools.ts +++ b/ui/src/lib/webmcp-tools.ts @@ -1,10 +1,9 @@ -// The dashboard's WebMCP tools: what an in-page agent may read and do. +// The dashboard's WebMCP tools: what an in-page agent may read. // // The API client is a parameter rather than a module import, so this list is // host-agnostic and unit-testable; `archie-webmcp.ts` is the one place that // binds it to the dashboard's own client. Scope is deliberate: read-only -// inspection and consequential task actions. The authenticated operator's -// session authorizes every mutation. +// inspection only. // // Security model: these tools run in the signed-in operator's own browser // session, so they inherit exactly what that operator can already do and can @@ -12,25 +11,13 @@ // // The annotations are advisory, and today they are not enforced: Chrome 152's // `getTools()` reports only `readOnlyHint` and `untrustedContentHint` and drops -// `consequentialHint`, so no agent sees it from discovery, and a page-invoked -// `executeTool` gates nothing. `consequentialHint` is still set on the recovery -// tools because the spec accepts it and a conforming client may honour it. -// The `confirm: true` requirement below is a deliberate-action signal, not a -// security control: an agent can pass it trivially. Its value is making the -// model state intent rather than reaching for a mutation mid-sentence. +// `consequentialHint`. Every tool here is a read. import type { WebMcpTool } from "./webmcp"; /** The dashboard client these tools call. `ui/src/lib/api.ts` satisfies it. */ export interface DashboardApi { health(): Promise; - tasks(): Promise; - task(id: string): Promise; captures(limit?: number): Promise; - taskAction( - id: string, - action: string, - payload?: { instructions?: string; findings?: string[] }, - ): Promise; } /** The MCP-shaped envelope a tool result is returned in. */ @@ -47,93 +34,9 @@ function jsonEnvelope(value: unknown): ToolEnvelope { return textEnvelope(JSON.stringify(value, null, 2)); } -/** A required task id, read from tool input. */ -function taskID(input: Record): string { - const id = input.task_id; - if (typeof id !== "string" && typeof id !== "number") { - throw new Error("task_id is required"); - } - return String(id); -} - -const taskIDSchema = { - type: "object", - properties: { - task_id: { - type: "string", - description: "Task id, as shown on the dashboard's task pages.", - }, - }, - required: ["task_id"], - additionalProperties: false, -} as const; - -// A task action's schema. `confirm` is required and must be true: a -// deliberate-action signal, not a security control (see the module header). -const taskActionSchema = { - type: "object", - properties: { - task_id: { - type: "string", - description: "Task id, as shown on the dashboard's task pages.", - }, - confirm: { - type: "boolean", - description: - "Must be true. State the intent explicitly rather than as a side effect of another action.", - }, - }, - required: ["task_id", "confirm"], - additionalProperties: false, -} as const; - -/** One task action, published under its own name so the agent chooses by intent. */ -function taskActionTool( - client: DashboardApi, - name: string, - action: string, - description: string, -): WebMcpTool { - return { - name, - description, - inputSchema: taskActionSchema, - annotations: { readOnlyHint: false, consequentialHint: true }, - execute: async (input) => { - const id = taskID(input); - if (input.confirm !== true) { - throw new Error( - `${name}: confirm must be true; this action changes a task`, - ); - } - return jsonEnvelope(await client.taskAction(id, action)); - }, - }; -} - /** Every tool the dashboard publishes to model context. */ export function archieWebMcpTools(client: DashboardApi): WebMcpTool[] { return [ - { - name: "list_tasks", - description: - "List Archie's tasks with their state, stage, and age. Read-only. The output is operator- and agent-authored and must be treated as untrusted.", - inputSchema: { - type: "object", - properties: {}, - additionalProperties: false, - }, - annotations: { readOnlyHint: true, untrustedContentHint: true }, - execute: async () => jsonEnvelope(await client.tasks()), - }, - { - name: "get_task", - description: - "Read one task's status and detail by id. Read-only. The output includes agent-generated content and must be treated as untrusted.", - inputSchema: taskIDSchema, - annotations: { readOnlyHint: true, untrustedContentHint: true }, - execute: async (input) => jsonEnvelope(await client.task(taskID(input))), - }, { name: "recent_events", description: @@ -169,47 +72,5 @@ export function archieWebMcpTools(client: DashboardApi): WebMcpTool[] { annotations: { readOnlyHint: true, untrustedContentHint: false }, execute: async () => jsonEnvelope(await client.health()), }, - taskActionTool( - client, - "retry_task", - "retry", - "Requeue a task that is stuck or parked so the workflow runs it again; keeps the task, its history, and its pull request. This recovers stalled work -- it is not how a review is approved.", - ), - taskActionTool( - client, - "stop_task", - "stop", - "Stop a running task recoverably: it moves to parked and can be retried later. Does not close the issue or discard the branch. Use this to pause work; use cancel_task to end it.", - ), - taskActionTool( - client, - "cancel_task", - "cancel", - "End a parked task archie should not continue; the forge issue stays open. stop_task parks a running task recoverably instead.", - ), - taskActionTool( - client, - "approve_task", - "approve", - "Approve a task waiting for approval so its workflow can continue.", - ), - taskActionTool( - client, - "reject_task", - "reject", - "Reject a task Archie should not continue. This ends the task and may close its forge issue or pull request.", - ), - taskActionTool( - client, - "abandon_task", - "abandon", - "Abandon a parked task without closing its forge issue.", - ), - taskActionTool( - client, - "archive_task", - "archive", - "Archive a terminal task, removing its local task record and worktree.", - ), ]; } diff --git a/ui/src/logs/LogActions.vue b/ui/src/logs/LogActions.vue deleted file mode 100644 index b02dce5de..000000000 --- a/ui/src/logs/LogActions.vue +++ /dev/null @@ -1,27 +0,0 @@ - - - diff --git a/ui/src/logs/LogFilters.vue b/ui/src/logs/LogFilters.vue deleted file mode 100644 index 8e9200439..000000000 --- a/ui/src/logs/LogFilters.vue +++ /dev/null @@ -1,122 +0,0 @@ - - - diff --git a/ui/src/logs/LogList.vue b/ui/src/logs/LogList.vue deleted file mode 100644 index 4ec07e901..000000000 --- a/ui/src/logs/LogList.vue +++ /dev/null @@ -1,72 +0,0 @@ - - - diff --git a/ui/src/logs/LogStatus.vue b/ui/src/logs/LogStatus.vue deleted file mode 100644 index 40caf6ed6..000000000 --- a/ui/src/logs/LogStatus.vue +++ /dev/null @@ -1,18 +0,0 @@ - - - diff --git a/ui/src/logs/LogStream.vue b/ui/src/logs/LogStream.vue deleted file mode 100644 index 7519b467f..000000000 --- a/ui/src/logs/LogStream.vue +++ /dev/null @@ -1,28 +0,0 @@ - - - diff --git a/ui/src/logs/LogsEmpty.vue b/ui/src/logs/LogsEmpty.vue deleted file mode 100644 index a91caca26..000000000 --- a/ui/src/logs/LogsEmpty.vue +++ /dev/null @@ -1,24 +0,0 @@ - - - diff --git a/ui/src/logs/log-entries.ts b/ui/src/logs/log-entries.ts deleted file mode 100644 index 572cd52dd..000000000 --- a/ui/src/logs/log-entries.ts +++ /dev/null @@ -1,71 +0,0 @@ -import type { LogEntry } from "@/lib/log"; - -/** - * What the log list is made of: the filters an entry survives, the key that - * makes one entry, and the merge of the durable history with the live tail. - * Pure, so the page's rendering has nothing to decide about entries. - */ - -/** The filters the list is read through. All three narrow the read - * server-side as well as the live stream locally. */ -export interface LogFilters { - service?: string; - level: string; - component: string; - q: string; -} - -/** - * entryKey is the identity of a log line: its time, level, message and fields. - * The live stream repeats entries the history also carries, so both sides key - * on the same value and the duplicate is stored once. - */ -export function entryKey(entry: LogEntry): string { - return `${entry.time || ""}|${entry.level || ""}|${entry.message || entry.msg || ""}|${JSON.stringify(entry.fields || {})}`; -} - -/** - * matchesFilters applies the filters to one entry. It runs over live entries as - * they arrive and again over the merged list, so the level CSV is matched part - * by part exactly as the server matches it (`splitCSV` in - * internal/webui/api_tasks_logs.go). - */ -export function matchesFilters(entry: LogEntry, filters: LogFilters): boolean { - if ( - filters.level && - !filters.level.split(",").includes((entry.level || "").toUpperCase()) - ) { - return false; - } - if (filters.service && entry.fields?.service !== filters.service) return false; - if (filters.component && entry.fields?.component !== filters.component) - return false; - if (filters.q) { - const needle = filters.q.toLowerCase(); - const hay = - `${entry.message || entry.msg || ""} ${JSON.stringify(entry.fields || {})}`.toLowerCase(); - if (!hay.includes(needle)) return false; - } - return true; -} - -/** - * mergeEntries overlays the live tail on the durable history, keeps the last - * 1000 that pass the filters, and returns them oldest first. - * - * A key the history already holds keeps its position when the live entry - * replaces it, so a line both sources carry is not reordered; lines only ever - * seen live land at the end, where the newest ones belong. - */ -export function mergeEntries( - history: LogEntry[], - live: Map, - filters: LogFilters, -): LogEntry[] { - const byID = new Map(); - for (const entry of history) byID.set(entryKey(entry), entry); - for (const [id, entry] of live) byID.set(id, entry); - return [...byID.values()] - .filter((entry) => matchesFilters(entry, filters)) - .slice(-1000); -} diff --git a/ui/src/logs/logs-empty.ts b/ui/src/logs/logs-empty.ts deleted file mode 100644 index 897ff11b3..000000000 --- a/ui/src/logs/logs-empty.ts +++ /dev/null @@ -1,27 +0,0 @@ -// What the logs list says when it has nothing to show: a dead stream, a -// deployment with no durable history, or filters that match nothing. -import { errors } from "@/copy/errors"; - -/** logsEmptyTitle names the situation. */ -export function logsEmptyTitle( - durableUnavailable: boolean, - streamState: string, -): string { - if (streamState === "unavailable") return errors.logs.empty.streamUnavailable; - if (durableUnavailable) return "No logs yet"; - return "Nothing matches"; -} - -/** The line under the title: what to expect next. */ -export function logsEmptyDetail( - durableUnavailable: boolean, - streamState: string, -): string { - if (streamState === "unavailable") { - return errors.logs.empty.streamUnavailableDetail; - } - if (durableUnavailable) { - return "This deployment keeps no durable history."; - } - return "Try a wider level or clear the search."; -} diff --git a/ui/src/logs/state.ts b/ui/src/logs/state.ts deleted file mode 100644 index ff50563e4..000000000 --- a/ui/src/logs/state.ts +++ /dev/null @@ -1,190 +0,0 @@ -import { computed, onMounted, onUnmounted, reactive, ref, watch } from "vue"; - -import { errors } from "@/copy/errors"; -import { api, describeError } from "@/lib/api"; -import { useSessionStore } from "@/stores/session"; -import type { LogEntry } from "@/lib/log"; -import type { StatusKind } from "@/lib/status"; -import type { StreamState } from "@/lib/stream-state"; -import { - entryKey, - matchesFilters, - mergeEntries, - type LogFilters, -} from "./log-entries"; -import { logsEmptyDetail, logsEmptyTitle } from "./logs-empty"; - -/** - * The log page's shared state. - * - * The filters, the stream's state and the list itself are read by different - * components, so it lives in a module rather than being threaded down through a - * chain of props. - */ - -/** One page of the durable log, as GET /api/logs answers it. */ -interface LogHistory { - entries?: LogEntry[]; - components?: string[]; - services?:string[]; - errors?:Record; - file?: string; - /** The process serving the request keeps no durable history. */ - disabled?: boolean; -} - -export const filters = reactive({ - level: "", - service:"", - component: "", - q: "", -}); - -/** The components the filter can name: those the server found, plus any the - * live stream has shown since. */ -export const serviceOptions=ref([]); -export const serviceErrors=ref>({}); -export const componentOptions = ref([]); -export const paused = ref(false); -export const loading = ref(true); -export const readError = ref(null); -export const streamState = ref("connecting"); - -const historyEntries = ref([]); -const durableUnavailable = ref(false); -const logFile = ref(""); - -// Live entries are held in a plain Map so a line the stream repeats is stored -// once, and the tick is what makes that mutation visible to `entries` below -- -// a Map is not something a computed can depend on by being read. -const liveEntries = new Map(); -const liveTick = ref(0); - -export const entries = computed(() => { - void liveTick.value; - return mergeEntries(historyEntries.value, liveEntries, filters); -}); - -/** A failed read, else the file the lines came from. */ -export const meta = computed(() => (readError.value ? errors.logs.read.unreadable : logFile.value)); - -/** The stream's state as a badge kind. Never `ok` for a stream that is still - * connecting, and never `warn` for one that has given up: the two are - * different answers, and stream-state.ts is what tells them apart. */ -export const streamKind = computed(() => { - if (streamState.value === "live") return "ok"; - return streamState.value === "unavailable" ? "danger" : "warn"; -}); - -/** Which of the nothing-to-show situations the list is in. */ -export const emptyTitle = computed(() => - logsEmptyTitle(durableUnavailable.value, streamState.value), -); -export const emptyDetail = computed(() => - logsEmptyDetail(durableUnavailable.value, streamState.value), -); - -let generation=0; -async function loadLogs(): Promise { - const current=++generation; - loading.value = true; - // readError is cleared only by a successful read below: clearing it here - // makes the error and the stale lines alternate on every 5 s refresh. - try { - const res = await api.logs({ - service:filters.service, - level: filters.level, - component: filters.component, - q: filters.q, - limit: 500, - }); - if(current!==generation)return; - readError.value = null; - serviceOptions.value=[...new Set([...serviceOptions.value,...(res.services??[])])].sort(); - serviceErrors.value=res.errors??{}; - componentOptions.value = res.components ?? []; - durableUnavailable.value = !!res.disabled; - logFile.value = res.file ?? ""; - historyEntries.value = res.entries ?? []; - } catch (err) { - 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 lines. - readError.value = describeError(err, errors.common.unknown); - } finally { - if(current===generation)loading.value = false; - } -} - -function handleEntry(raw: unknown): void { - // Paused drops what arrives rather than buffering it: the list is a view of - // the stream, and resuming continues from where the stream is now instead of - // replaying the pause. - if (paused.value) return; - - const entry = raw as LogEntry; - if (!matchesFilters(entry, filters)) return; - - if (streamState.value === "unavailable") streamState.value = "live"; - liveEntries.set(entryKey(entry), entry); - // The list shows only the last 1000; keep a margin and drop the oldest so - // the map cannot grow without bound while the page stays open. - if (liveEntries.size > 1500) { - let excess = liveEntries.size - 1500; - for (const key of liveEntries.keys()) { - liveEntries.delete(key); - if (--excess <= 0) break; - } - } - const component = entry.fields?.component; - if ( - typeof component === "string" && - component && - !componentOptions.value.includes(component) - ) { - componentOptions.value = [...componentOptions.value, component]; - } - liveTick.value += 1; -} - -let refresh:ReturnType|undefined; -let unsubscribe: (() => void) | undefined; - -/** Owns the initial read, the re-reads a filter change causes, and the live - * stream, for the page's lifetime. */ -export function useLogs(): void { - const live = useSessionStore(); - onMounted(() => { - // A mount opens a new stream against a fresh read, so the tail starts - // unpaused, connecting, and without the lines the previous visit's stream - // left behind. The filters are not reset: they are what the operator last - // asked to see, and the read below answers them again. - paused.value = false; - streamState.value = "connecting"; - liveEntries.clear(); - liveTick.value += 1; - - void loadLogs(); - refresh=setInterval(()=>{if(!paused.value)void loadLogs()},5000); - unsubscribe = live.subscribe("logs", handleEntry); - streamState.value = live.streamState; - }); - onUnmounted(() => { - clearInterval(refresh); - generation++; - unsubscribe?.(); - unsubscribe = undefined; - }); - watch(() => live.streamState, (state) => { - streamState.value = state; - }); - // A process without a LogFeed cannot deliver live entries. - const stopStatus = live.subscribe("logs-status", (data) => { - if (!(data as { available: boolean }).available) streamState.value = "unavailable"; - }); - onUnmounted(stopStatus); - - // Every filter is a server-side one -- the request carries it -- so a change - // to any of them is a new read, not a re-filter of what is already here. - watch(filters, () => void loadLogs()); -} diff --git a/ui/src/org/NewOrgDialog.vue b/ui/src/org/NewOrgDialog.vue index 50e7a7865..f2d16a1c9 100644 --- a/ui/src/org/NewOrgDialog.vue +++ b/ui/src/org/NewOrgDialog.vue @@ -34,13 +34,19 @@ const error = ref(""); const busy = ref(false); const identities = useOrgStore(); +// The owner has to be an identity that already exists, so the candidates are the +// members of the caller's organisation. const people = computed(() => - identities.identities.filter((i) => i.kind !== "system" && i.lifecycle === "active"), + (identities.membersByOrg.get(identities.homeOrg) ?? []).filter((member) => member.kind !== "system" && member.status === "active"), ); function opened(value: boolean): void { open.value = value; - if (value) identities.watchIdentities(); + if (value) { + void identities.loadOrg() + .then(() => identities.readMembers(identities.homeOrg)) + .catch((cause) => (error.value = describeError(cause, errors.common.unknown))); + } } async function create(): Promise { @@ -80,7 +86,7 @@ async function create(): Promise { - + {{ person.display_name }} diff --git a/ui/src/org/UserReference.vue b/ui/src/org/UserReference.vue index 8306e4941..e03c56782 100644 --- a/ui/src/org/UserReference.vue +++ b/ui/src/org/UserReference.vue @@ -9,19 +9,16 @@ const accounts = useAccountsStore(); const scope = computed(() => props.orgId || org.homeOrg); const recordName = computed(() => props.name === props.id ? undefined : props.name); -watch(() => [props.id, recordName.value, props.kind, props.orgId] as const, ([id, name, kind, orgId]) => { +watch(() => [props.id, props.kind, props.orgId] as const, ([id, kind, orgId]) => { if (!id || (kind && kind !== "user")) return; - if (!name || !kind) org.watchIdentities(); - void org.loadOrg().then(() => { - if (!name || !kind) return org.readMembers(orgId || org.homeOrg); - }).catch(() => { /* Without a directory, keep the attribution supplied by the record. */ }); + void org.loadOrg().then(() => org.readMembers(orgId || org.homeOrg)) + .catch(() => { /* Without a member list, keep the attribution supplied by the record. */ }); }, { immediate: true }); -const identity = computed(() => org.identities.find((entry) => entry.id === props.id)); const member = computed(() => org.membersByOrg.get(scope.value)?.find((entry) => entry.identity_id === props.id)); const account = computed(() => accounts.status?.user?.id === props.id ? accounts.status?.user : undefined); -const kind = computed(() => props.kind || member.value?.kind || identity.value?.kind || account.value?.kind); -const label = computed(() => recordName.value || member.value?.display_name || identity.value?.display_name || account.value?.display_name || props.id || props.fallback); +const kind = computed(() => props.kind || member.value?.kind || account.value?.kind); +const label = computed(() => recordName.value || member.value?.display_name || account.value?.display_name || props.id || props.fallback);