chore: remove dashboard-v2, archived out of tree

This commit is contained in:
sam committed 2026-10-27 01:54:05 +11:00
1 parent e4b8c77c72
commit 3da413119f
22 files changed
-7150

No files matched your search

-4
View File
@@ -26,10 +26,6 @@ config.production.toml
/ui/.vite/
/ui/*.tsbuildinfo
# ui/dist IS committed: the Go build must not need a Node toolchain.
/dashboard-v2/node_modules/
/dashboard-v2/.vite/
/dashboard-v2/*.tsbuildinfo
/dashboard-v2/dist/
# air live-reload
/.air/
-34
View File
@@ -1,34 +0,0 @@
# AGENTS.md
Project-specific guidance for AI coding agents.
<!-- ASTRYX:START -->
Astryx v0.7.4 · 173 components
CLI: run every command as `pnpm dlx @astryxdesign/cli@0.7.4 <cmd>` (shown below as `astryx ...`).
SETUP (once, in app entry e.g. main.tsx) — without these, components render unstyled:
import "@astryxdesign/core/reset.css";
import "@astryxdesign/core/astryx.css";
WORKFLOW — start every page from a template, never from scratch:
1. `astryx build "<idea>"` — names the template to scaffold from and the parts it lacks.
2. `astryx template <name> <path>` — scaffold it; keep its frame, gap and padding; replace the content.
3. `astryx template <Block>` for parts it lacks; `astryx component <Name>` to read props before using one.
Changing an existing page? Keep it: skip step 2 and add blocks/components inside its sections.
RULES:
- No <div> — components handle all layout and spacing.
- Read `astryx docs layout` before changing a template's frame.
- Dense data = rows (Table, List/Item), not Card-wrapped lists. Badge = counts only.
- Style with component props first, then tokens (var(--color-*|--spacing-*|--radius-*)). No raw hex/px. No StyleX/Tailwind compiler here — don't use xstyle/utility classes directly. Some templates use StyleX and need a compiler plugin; see `astryx docs styling-overview`.
- Palettes and custom colors go through the theme, never :root overrides. Run `astryx theme add <slug>` to import; `theme eject <slug>` only forks source. See `astryx docs theme`.
- SELF-CHECK: re-read the file; replace any raw <div>/<span>, imported .css/@apply, or hardcoded #hex/px with the component or a token.
`astryx help` lists every command. Key ones beyond the workflow:
search "<query>" find any component / hook / doc / template
discover <words> integrations you could add
docs <topic> getting-started, principles, tokens, theme … (`astryx docs` lists all)
docs cli commands and API reference
docs authoring build an integration package, and every field it holds
upgrade --from <old version> --apply run after a dependency bump
<!-- ASTRYX:END -->
-3
View File
@@ -1,3 +0,0 @@
<!-- ASTRYX:START -->
@./AGENTS.md
<!-- ASTRYX:END -->
-28
View File
@@ -1,28 +0,0 @@
# dashboard-v2
React plus Astryx replacement for the Vue dashboard (`ui/`), growing by
strangler: new pages land here, served beside the Vue app until v2 covers
everything. The server owns every contract; this app presents them.
First slice: System status (service health plus component versions), a
read-only mirror of the Vue status page.
## Run
```bash
cd dashboard-v2
pnpm install
astryx theme add neutral # regenerates src/astryx-themes.ts
pnpm run dev # http://localhost:5174
```
Open http://localhost:5174 in a browser after starting it. `/api` proxies
to a locally running archie-ui on 127.0.0.1:8484, same as the Vue dev
server. Port 5174 keeps v2 beside the Vue app on 5173.
`pnpm run build` typechecks and builds to `dist/`, which is not committed:
serving v2 (embed vs separate deploy) is still an open decision.
Dependency versions were chosen offline to match Astryx CLI 0.7.4
(`@astryxdesign/*` 0.7.4, React 19, Vite 8); if `pnpm install` reports peer
conflicts, follow its resolution and commit the lockfile.
-16
View File
@@ -1,16 +0,0 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link
rel="icon"
href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='2 3 20 18'%3E%3Cpath d='M2.00 21.00 L6.00 21.00 L14.00 3.00 L10.00 3.00Z' fill='%23111'/%3E%3Cpath d='M14.90 5.03 L22.00 21.00 L18.00 21.00 L12.90 9.53Z' fill='%23111'/%3E%3Cpath d='M10.47 15.00 L13.53 15.00 L14.64 17.50 L9.36 17.50Z' fill='%2351a580'/%3E%3C/svg%3E"
/>
<title>Status | Archie</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
-32
View File
@@ -1,32 +0,0 @@
{
"name": "archie-dashboard-v2",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc --noEmit && vite build",
"preview": "vite preview",
"typecheck": "tsc --noEmit"
},
"dependencies": {
"@astryxdesign/core": "0.7.4",
"@astryxdesign/theme-neutral": "0.7.4",
"@heroicons/react": "^2.2.0",
"@stylexjs/stylex": "^0.19.0",
"lucide-react": "^1.18.0",
"@tanstack/react-query": "^5.0.0",
"react": "^19.1.0",
"react-dom": "^19.1.0"
},
"devDependencies": {
"@astryxdesign/cli": "0.7.4",
"@types/react": "^19.1.0",
"@types/react-dom": "^19.1.0",
"@stylexjs/rollup-plugin": "^0.19.0",
"@vitejs/plugin-react": "^5.0.0",
"typescript": "~6.0.3",
"vite": "^8.3.0"
},
"packageManager": "pnpm@12.10.1"
}
-1909
View File
File diff suppressed because it is too large. Load diff
-3
View File
@@ -1,3 +0,0 @@
allowBuilds:
'@astryxdesign/cli': true
'@astryxdesign/core': true
-84
View File
@@ -1,84 +0,0 @@
import { Suspense, lazy, useState } from "react";
import { AppShell } from "@astryxdesign/core/AppShell";
import { HStack } from "@astryxdesign/core/Layout";
import { SideNav, SideNavHeading, SideNavItem } from "@astryxdesign/core/SideNav";
import { Center } from "@astryxdesign/core/Center";
import { Text } from "@astryxdesign/core/Text";
import {
ClipboardDocumentListIcon,
ServerStackIcon,
} from "@heroicons/react/24/outline";
import { ArchieMark } from "./components/ArchieLogo.tsx";
import LoginPage from "./pages/LoginPage.tsx";
import { useSession } from "./session.tsx";
const StatusPage = lazy(() => import("./pages/StatusPage.tsx"));
const TasksPage = lazy(() => import("./pages/TasksPage.tsx"));
function PageFallback(): React.JSX.Element {
return (
<Center axis="both" padding={6}>
<Text type="body">Loading…</Text>
</Center>
);
}
type Page = "tasks" | "status";
export default function App() {
const { state } = useSession();
const [page, setPage] = useState<Page>("tasks");
if (state === "unknown") {
return (
<Center axis="both" padding={6}>
<Text type="body">Loading…</Text>
</Center>
);
}
// Fresh installs set up through the Vue dashboard until v2 grows a
// setup page.
if (state === "setup") {
return (
<Center axis="both" padding={6}>
<Text type="body">Complete initial setup before signing in.</Text>
</Center>
);
}
if (state === "guest") return <LoginPage />;
return (
<AppShell
contentPadding={0}
sideNav={
<SideNav
header={
<HStack gap={2} vAlign="center">
<ArchieMark size={20} />
<SideNavHeading heading="Archie" />
</HStack>
}
>
<SideNavItem
label="Tasks"
icon={ClipboardDocumentListIcon}
isSelected={page === "tasks"}
onClick={() => setPage("tasks")}
/>
<SideNavItem
label="Status"
icon={ServerStackIcon}
isSelected={page === "status"}
onClick={() => setPage("status")}
/>
</SideNav>
}
>
<Suspense fallback={<PageFallback />}>
{page === "tasks" ? <TasksPage /> : <StatusPage />}
</Suspense>
</AppShell>
);
}
-15
View File
@@ -1,15 +0,0 @@
/**
* @generated by `astryx theme` — do not edit manually.
* @astryx-theme-record {"themes":{"neutral":"@astryxdesign/theme-neutral"},"defaultThemeSlug":"neutral"}
*/
import {neutralTheme as _astryxTheme0} from "@astryxdesign/theme-neutral/built";
import "@astryxdesign/theme-neutral/theme.css";
import "@astryxdesign/theme-neutral/fonts.css";
export const themes = {
"neutral": _astryxTheme0,
} as const;
export type ThemeSlug = keyof typeof themes;
export const defaultThemeSlug: keyof typeof themes = "neutral";
-209
View File
@@ -1,209 +0,0 @@
import {
useCallback,
useEffect,
useLayoutEffect,
useRef,
useState,
type CSSProperties,
} from "react";
/** Brand sage, mirroring v1's shared `--sage` accent. */
export const ARCHIE_SAGE = "#51a580";
const LEGS_LEFT = "M2.00 21.00 L6.00 21.00 L14.00 3.00 L10.00 3.00Z";
const LEGS_RIGHT = "M14.90 5.03 L22.00 21.00 L18.00 21.00 L12.90 9.53Z";
const BAR = "M10.47 15.00 L13.53 15.00 L14.64 17.50 L9.36 17.50Z";
/** Suffixes the open mark cycles through, with their accessible names. */
const NAMES = ["rchie", "rchitect", "rchimedes", "rchipelago"];
const LABELS = ["Archie", "Architect", "Archimedes", "archipelago"];
const EASE = "cubic-bezier(0.2, 0.7, 0.2, 1)";
const BOOT_OPEN_MS = 700;
const HOLD_MS = 2400;
const CYCLE_MS = 1800;
const SWAP_MS = 200;
function MarkArt({booted}: {booted: boolean}): React.JSX.Element {
return (
<svg
viewBox="2 3 20 18"
aria-hidden="true"
style={{
height: "0.698em",
width: "calc(0.698em * 20 / 18)",
display: "block",
flex: "none",
alignSelf: "baseline",
overflow: "visible",
}}
>
<path d={LEGS_LEFT} fill="currentColor" />
<path d={LEGS_RIGHT} fill="currentColor" />
<path
d={BAR}
fill={ARCHIE_SAGE}
style={{
transition: "transform 520ms cubic-bezier(0.2, 0.7, 0.2, 1)",
transform: booted ? undefined : "translateY(6px)",
opacity: booted ? undefined : 0,
}}
/>
</svg>
);
}
/** The static A mark, for shells and topbars. */
export function ArchieMark({size = 16}: {size?: number}): React.JSX.Element {
return (
<span
role="img"
aria-label="Archie"
style={{fontSize: size, lineHeight: 1, display: "inline-flex"}}
>
<MarkArt booted />
</span>
);
}
/**
* The full logo: the A opens out to the name on mount, holds, folds back,
* and reopens on hover or focus, cycling the name while open. Reduced motion
* gets no transitions and the name on hover only.
*/
export default function ArchieLogo({
size = 32,
}: {
size?: number;
}): React.JSX.Element {
const [booted, setBooted] = useState(false);
const [open, setOpen] = useState(false);
const [nameIndex, setNameIndex] = useState(0);
const [swapping, setSwapping] = useState(false);
const [hovering, setHovering] = useState(false);
const [reduced] = useState(
() =>
typeof window !== "undefined" &&
window.matchMedia("(prefers-reduced-motion: reduce)").matches,
);
const suffixRef = useRef<HTMLSpanElement>(null);
const textRef = useRef<HTMLSpanElement>(null);
const foldTimer = useRef<number>(0);
const fit = useCallback(() => {
const suffix = suffixRef.current;
const text = textRef.current;
if (suffix && text) {
suffix.style.maxWidth = `${Math.ceil(text.getBoundingClientRect().width)}px`;
}
}, []);
const close = useCallback(() => {
setOpen(false);
window.setTimeout(() => setNameIndex(0), reduced ? 0 : 460);
}, [reduced]);
// Boot once on mount: bar rises, name opens, holds, folds back.
useEffect(() => {
if (reduced) {
setBooted(true);
return;
}
const rise = window.setTimeout(() => setBooted(true), 150);
const show = window.setTimeout(() => setOpen(true), BOOT_OPEN_MS);
foldTimer.current = window.setTimeout(() => {
setHovering(current => {
if (!current) {
setOpen(false);
}
return current;
});
}, BOOT_OPEN_MS + 460 + HOLD_MS);
return () => {
window.clearTimeout(rise);
window.clearTimeout(show);
window.clearTimeout(foldTimer.current);
};
}, [reduced]);
// Fit the suffix to the name whenever it opens or the name changes.
useLayoutEffect(() => {
if (open) {
fit();
} else if (suffixRef.current) {
suffixRef.current.style.maxWidth = "0px";
}
}, [open, nameIndex, fit]);
// Cycle the name while open.
useEffect(() => {
if (!open || reduced) {
return;
}
const timer = window.setInterval(() => {
setSwapping(true);
window.setTimeout(() => {
setNameIndex(i => (i + 1) % NAMES.length);
setSwapping(false);
}, SWAP_MS);
}, CYCLE_MS);
return () => window.clearInterval(timer);
}, [open, reduced]);
const show = () => {
window.clearTimeout(foldTimer.current);
setHovering(true);
setOpen(true);
};
const hide = () => {
setHovering(false);
close();
};
const logoStyle: CSSProperties = {
display: "inline-flex",
alignItems: "baseline",
fontWeight: 600,
letterSpacing: "-0.01em",
lineHeight: 1,
whiteSpace: "nowrap",
fontSize: size,
borderRadius: 8,
outline: "none",
};
const suffixStyle: CSSProperties = {
display: "inline-block",
overflow: "hidden",
paddingBottom: "0.25em",
marginBottom: "-0.25em",
maxWidth: 0,
transition: reduced ? "none" : `max-width 460ms ${EASE}`,
};
const textStyle: CSSProperties = {
display: "inline-block",
width: "max-content",
paddingLeft: "0.02em",
transition: reduced ? "none" : "opacity 200ms ease, transform 200ms ease",
opacity: swapping ? 0 : undefined,
transform: swapping ? "translateY(0.18em)" : undefined,
};
return (
<span
tabIndex={0}
aria-label={LABELS[nameIndex]}
style={logoStyle}
onMouseEnter={show}
onFocus={show}
onMouseLeave={hide}
onBlur={hide}
>
<MarkArt booted={booted} />
<span ref={suffixRef} style={suffixStyle} aria-hidden="true">
<span ref={textRef} style={textStyle}>
{NAMES[nameIndex]}
</span>
</span>
</span>
);
}
-2
View File
@@ -1,2 +0,0 @@
@import "@astryxdesign/core/reset.css";
@import "@astryxdesign/core/astryx.css";
-163
View File
@@ -1,163 +0,0 @@
// Minimal port of the Vue dashboard's api client: same request semantics
// (timeout, CSRF on mutation, server-first error text), only the endpoints
// v2 pages use. The server owns every shape below.
const DEFAULT_TIMEOUT_MS = 15000;
export class ApiError extends Error {
status: number;
constructor(message: string, status: number) {
super(message);
this.name = "ApiError";
this.status = status;
}
}
// errorMessage prefers what the server actually said: archie-ui answers with
// a plain-text reason, the only part an operator can act on.
async function errorMessage(res: Response): Promise<string> {
try {
const body = (await res.text()).trim();
if (body) return body.split("\n")[0].slice(0, 200);
} catch {
// Body already consumed or unreadable; fall through to the status.
}
return `${res.status} ${res.statusText}`;
}
interface RequestOptions {
method?: string;
body?: unknown;
timeoutMs?: number;
}
async function request<T>(
path: string,
opts: RequestOptions = {},
): Promise<T> {
const { method = "GET", body, timeoutMs = DEFAULT_TIMEOUT_MS } = opts;
const headers: Record<string, string> = { Accept: "application/json" };
const init: RequestInit = {
method,
headers,
signal: AbortSignal.timeout(timeoutMs),
};
if (method !== "GET") {
headers["Content-Type"] = "application/json";
headers["X-Archie-CSRF"] = "1";
}
if (body !== undefined) init.body = JSON.stringify(body);
const res = await fetch(path, init);
if (!res.ok) throw new ApiError(await errorMessage(res), res.status);
return (await res.json()) as T;
}
export interface ServiceCheck {
name: string;
status: "ok" | "degraded";
detail?: string;
}
export interface Service {
service: string;
instance_id: string;
state: "up" | "degraded" | "down" | "unknown";
version: string;
install_type: string;
started_at: string;
reported_at: string;
detail?: string;
applied: {
kind: string;
applied_version: number;
error?: string;
state: "current" | "failed" | "unknown";
}[];
checks?: ServiceCheck[];
}
export interface ComponentVersion {
id: string;
label: string;
install_type?: string;
reference?: string;
running_version?: string;
installed_claim?: string;
latest_available?: string;
status: "ok" | "update_available" | "drift" | "unknown";
}
export interface AuthStatus {
setup_required?: boolean;
user?: unknown;
oidc?: boolean;
instance?: string;
}
export interface StatusMeta {
id: string;
label: string;
kind: "ok" | "warn" | "danger" | "info" | "idle";
needs_attention?: boolean;
}
export interface TaskMeta {
statuses?: StatusMeta[];
}
export interface Task {
id: number | string;
title?: string;
owner?: string;
repo?: string;
status?: string;
workflow?: string;
attempt?: number;
branch?: string;
plan?: string;
park_reason?: string;
created_at?: string;
updated_at?: string;
issue_url?: string;
pr_url?: string;
actions?: string[];
}
export interface TaskPageParams {
status?: string;
workflow?: string;
limit?: number;
cursor?: string | null;
}
export const api = {
authStatus: () => request<AuthStatus>("/api/auth/status"),
taskMeta: () => request<TaskMeta>("/api/task-meta"),
// taskPage reads one page of tasks; next is the cursor for the page
// after it, or null when this page was the last.
taskPage: async (params: TaskPageParams) => {
const q = new URLSearchParams();
if (params.status) q.set("status", params.status);
if (params.workflow) q.set("workflow", params.workflow);
q.set("limit", String(params.limit ?? 100));
if (params.cursor) q.set("cursor", params.cursor);
const res = await fetch(`/api/tasks?${q}`, {
headers: { Accept: "application/json" },
signal: AbortSignal.timeout(DEFAULT_TIMEOUT_MS),
});
if (!res.ok) throw new ApiError(await errorMessage(res), res.status);
return {
tasks: (await res.json()) as Task[],
next: res.headers.get("X-Next-Cursor"),
};
},
services: () => request<Service[]>("/api/services"),
version: () => request<{ components: ComponentVersion[] }>("/api/version"),
signIn: (email: string, password: string) =>
request<unknown>("/api/auth/login", {
method: "POST",
body: { email, password },
}),
};
-16
View File
@@ -1,16 +0,0 @@
import { QueryClient } from "@tanstack/react-query";
// Server state lives here. Pages read through useQuery and never cache
// responses in useState.
export const queryClient = new QueryClient({
defaultOptions: {
queries: {
// Status data goes stale fast, but a focus storm on every alt-tab is
// worse: pages that need live data poll or refetch explicitly.
staleTime: 10_000,
refetchOnWindowFocus: false,
// Fail fast to the page's error state; the operator retries there.
retry: 1,
},
},
});
-26
View File
@@ -1,26 +0,0 @@
import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import { Theme } from "@astryxdesign/core/theme";
import { QueryClientProvider } from "@tanstack/react-query";
import { defaultThemeSlug, themes } from "./astryx-themes.ts";
import App from "./App.tsx";
import "./globals.css";
import { queryClient } from "./lib/query.ts";
import { SessionProvider } from "./session.tsx";
const root = document.getElementById("root");
if (!root) throw new Error("missing #root element");
createRoot(root).render(
<StrictMode>
<QueryClientProvider client={queryClient}>
<Theme theme={themes[defaultThemeSlug]}>
<SessionProvider>
<App />
</SessionProvider>
</Theme>
</QueryClientProvider>
</StrictMode>,
);
-114
View File
@@ -1,114 +0,0 @@
import { useState, type CSSProperties } from "react";
import { Banner } from "@astryxdesign/core/Banner";
import { Button } from "@astryxdesign/core/Button";
import { Card } from "@astryxdesign/core/Card";
import { Center } from "@astryxdesign/core/Center";
import { VStack } from "@astryxdesign/core/Layout";
import { Heading, Text } from "@astryxdesign/core/Text";
import { TextInput } from "@astryxdesign/core/TextInput";
import ArchieLogo from "../components/ArchieLogo.tsx";
import { useSession } from "../session.tsx";
// Standalone auth page paints its own body background (no host shell).
const pageStyle: CSSProperties = {
minHeight: "100%",
backgroundColor: "var(--color-background-body)",
};
// Cap the column at 400px but let it shrink to fit narrow screens (Stack
// has no maxWidth prop, so it's set here).
const contentStyle: CSSProperties = {
width: "100%",
maxWidth: 400,
};
export default function LoginPage() {
const { signIn, instance, oidc } = useSession();
const [email, setEmail] = useState("");
const [password, setPassword] = useState("");
const [isLoading, setIsLoading] = useState(false);
const [error, setError] = useState("");
const handleSignIn = async () => {
setError("");
if (!email || !password) {
setError("Enter both email and password.");
return;
}
setIsLoading(true);
try {
await signIn(email, password);
} catch (err) {
setError(err instanceof Error ? err.message : "Sign-in failed");
} finally {
setIsLoading(false);
}
};
return (
<Center axis="both" padding={6} style={pageStyle}>
<VStack gap={4} hAlign="center" style={contentStyle}>
<ArchieLogo size={40} />
{/* Card */}
<Card padding={8} width="100%">
<VStack gap={4} hAlign="stretch">
<VStack gap={1} hAlign="center">
<Heading level={2}>Sign in</Heading>
</VStack>
{error && <Banner status="error" title={error} container="card" />}
<TextInput
label="Email"
value={email}
onChange={setEmail}
onEnter={() => void handleSignIn()}
placeholder="you@example.com"
type="email"
size="lg"
autoComplete="email"
isDisabled={isLoading}
/>
<TextInput
label="Password"
value={password}
onChange={setPassword}
onEnter={() => void handleSignIn()}
placeholder="Enter your password"
type="password"
size="lg"
autoComplete="current-password"
isDisabled={isLoading}
/>
<Button
label="Sign in"
variant="primary"
size="lg"
isLoading={isLoading}
onClick={() => void handleSignIn()}
/>
{oidc && (
<Button
label="Continue with SSO"
variant="secondary"
size="lg"
onClick={() => {
window.location.href = "/oauth2/login";
}}
/>
)}
{instance && (
<Text type="supporting" color="secondary" justify="center">
{instance}
</Text>
)}
</VStack>
</Card>
</VStack>
</Center>
);
}
-304
View File
@@ -1,304 +0,0 @@
import { useEffect } from "react";
import { Button } from "@astryxdesign/core/Button";
import { Card } from "@astryxdesign/core/Card";
import { Divider } from "@astryxdesign/core/Divider";
import { Grid } from "@astryxdesign/core/Grid";
import { Icon } from "@astryxdesign/core/Icon";
import {
HStack,
Layout,
LayoutContent,
VStack,
} from "@astryxdesign/core/Layout";
import { StatusDot } from "@astryxdesign/core/StatusDot";
import {
Table,
pixel,
proportional,
type TableColumn,
} from "@astryxdesign/core/Table";
import { Heading, Text } from "@astryxdesign/core/Text";
import { useQuery } from "@tanstack/react-query";
import { ArrowPathIcon } from "@heroicons/react/24/outline";
import {
ApiError,
api,
type ComponentVersion,
type Service,
} from "../lib/api.ts";
import { useSession } from "../session.tsx";
// Service health plus per-component versions, in the dashboard template's
// frame. Server state comes from useQuery; the session owns the 401 bounce.
function uptime(startedAt: string, state: Service["state"]): string {
if (!startedAt || state === "down") return "not reported";
const seconds = Math.max(
0,
Math.round((Date.now() - Date.parse(startedAt)) / 1000),
);
const days = Math.floor(seconds / 86400);
const hours = Math.floor((seconds % 86400) / 3600);
const minutes = Math.floor((seconds % 3600) / 60);
if (days) return `${days}d ${hours}h`;
if (hours) return `${hours}h ${minutes}m`;
return `${minutes}m`;
}
const serviceVariant = {
up: "success",
degraded: "warning",
down: "error",
unknown: "neutral",
} as const;
const versionVariant = {
ok: "success",
update_available: "warning",
drift: "error",
unknown: "neutral",
} as const;
const versionLabel = {
ok: "Current",
update_available: "Update available",
drift: "Version drift",
unknown: "Unknown",
} as const;
function MetricCard({
label,
value,
caption,
}: {
label: string;
value: string;
caption: string;
}) {
return (
<Card>
<VStack gap={2}>
<Heading level={4}>{label}</Heading>
<Heading level={2}>{value}</Heading>
<Text type="supporting" color="secondary">
{caption}
</Text>
</VStack>
</Card>
);
}
interface ServiceRow extends Record<string, unknown> {
id: string;
service: string;
state: Service["state"];
version: string;
uptime: string;
detail?: string;
}
const serviceColumns: TableColumn<ServiceRow>[] = [
{ key: "service", header: "Service", width: proportional(1) },
{
key: "state",
header: "State",
width: pixel(160),
renderCell: (item: ServiceRow) => (
<HStack gap={2} vAlign="center">
<StatusDot
variant={serviceVariant[item.state]}
label={item.state}
tooltip={item.detail}
/>
<Text type="body">{item.state}</Text>
</HStack>
),
},
{ key: "version", header: "Version", width: pixel(120) },
{ key: "uptime", header: "Uptime", width: pixel(120) },
];
interface VersionRow extends Record<string, unknown> {
id: string;
component: string;
running: string;
latest: string;
status: ComponentVersion["status"];
}
const versionColumns: TableColumn<VersionRow>[] = [
{ key: "component", header: "Component", width: proportional(1) },
{ key: "running", header: "Running", width: pixel(140) },
{ key: "latest", header: "Latest", width: pixel(140) },
{
key: "status",
header: "State",
width: pixel(180),
renderCell: (item: VersionRow) => (
<HStack gap={2} vAlign="center">
<StatusDot
variant={versionVariant[item.status]}
label={versionLabel[item.status]}
/>
<Text type="body">{versionLabel[item.status]}</Text>
</HStack>
),
},
];
function isAuthError(err: unknown): boolean {
return err instanceof ApiError && err.status === 401;
}
export default function StatusPage() {
const { expire } = useSession();
const servicesQuery = useQuery({
queryKey: ["services"],
queryFn: api.services,
});
const versionQuery = useQuery({
queryKey: ["version"],
queryFn: api.version,
});
// A mid-session 401 bounces to the login page; anything else renders where
// it failed.
const authed = [servicesQuery.error, versionQuery.error].some(isAuthError);
useEffect(() => {
if (authed) expire();
}, [authed, expire]);
const loading = servicesQuery.isPending || versionQuery.isPending;
const error = [servicesQuery.error, versionQuery.error].find(
(err) => err && !isAuthError(err),
);
const services = servicesQuery.data ?? [];
const components = versionQuery.data?.components ?? [];
const reload = () => {
void servicesQuery.refetch();
void versionQuery.refetch();
};
const up = services.filter((s) => s.state === "up").length;
const attention = services.filter(
(s) => s.state === "degraded" || s.state === "down",
).length;
const current = components.filter((c) => c.status === "ok").length;
const serviceRows: ServiceRow[] = services.map((s) => ({
id: `${s.service}/${s.instance_id}`,
service: s.service,
state: s.state,
version: s.version || "not reported",
uptime: uptime(s.started_at, s.state),
detail: s.detail,
}));
const versionRows: VersionRow[] = components.map((c) => ({
id: c.id,
component: c.label,
running: c.running_version || c.installed_claim || "not reported",
latest: c.latest_available || "not reported",
status: c.status,
}));
return (
<Layout
height="fill"
content={
<LayoutContent padding={6}>
<VStack gap={6}>
<VStack gap={6}>
<HStack hAlign="between" vAlign="center">
<Heading level={3}>System status</Heading>
<Button
label="Reload"
variant="secondary"
size="md"
icon={<Icon icon={ArrowPathIcon} size="sm" />}
onClick={reload}
/>
</HStack>
{loading ? (
<Card>
<Text type="body">Loading status…</Text>
</Card>
) : error ? (
<Card>
<VStack gap={4}>
<Text type="body">
{error instanceof Error ? error.message : String(error)}
</Text>
<Button
label="Retry"
variant="secondary"
size="md"
onClick={reload}
/>
</VStack>
</Card>
) : (
<Grid columns={{ minWidth: 240, repeat: "fit" }} gap={4}>
<MetricCard
label="Services up"
value={`${up} of ${services.length}`}
caption="Services reporting up"
/>
<MetricCard
label="Needs attention"
value={String(attention)}
caption="Degraded or down"
/>
<MetricCard
label="Components current"
value={`${current} of ${components.length}`}
caption="Running the latest version"
/>
</Grid>
)}
</VStack>
{!loading && !error && (
<>
<Divider />
<HStack hAlign="between" vAlign="center">
<Heading level={3}>Services</Heading>
</HStack>
<Card>
<Table<ServiceRow>
data={serviceRows}
columns={serviceColumns}
idKey="id"
density="compact"
dividers="rows"
hasHover
/>
</Card>
<Divider />
<HStack hAlign="between" vAlign="center">
<Heading level={3}>Versions</Heading>
</HStack>
<Card>
<Table<VersionRow>
data={versionRows}
columns={versionColumns}
idKey="id"
density="compact"
dividers="rows"
hasHover
/>
</Card>
</>
)}
</VStack>
</LayoutContent>
}
/>
);
}
File diff suppressed because it is too large. Load diff
-70
View File
@@ -1,70 +0,0 @@
import {
createContext,
useCallback,
useContext,
useEffect,
useState,
type ReactNode,
} from "react";
import { api } from "./lib/api.ts";
export type SessionState = "unknown" | "authed" | "guest" | "setup";
const SessionContext = createContext<{
state: SessionState;
signIn: (email: string, password: string) => Promise<void>;
expire: () => void;
instance: string | null;
oidc: boolean;
} | null>(null);
// The only client state in the app: who is signed in. Everything else is
// server state behind useQuery.
export function SessionProvider({ children }: { children: ReactNode }) {
const [state, setState] = useState<SessionState>("unknown");
const [instance, setInstance] = useState<string | null>(null);
const [oidc, setOidc] = useState(false);
useEffect(() => {
let live = true;
api
.authStatus()
.then((status) => {
// The status is 200 for anonymous visitors too, with a null user.
if (!live) return;
setInstance(status.instance ?? null);
setOidc(status.oidc ?? false);
setState(
status.setup_required ? "setup" : status.user ? "authed" : "guest",
);
})
.catch(() => {
// Any failure to prove a session means no session: the login page
// then shows the server's own message when sign-in is attempted.
if (live) setState("guest");
});
return () => {
live = false;
};
}, []);
const signIn = useCallback(async (email: string, password: string) => {
await api.signIn(email, password);
setState("authed");
}, []);
const expire = useCallback(() => setState("guest"), []);
return (
<SessionContext.Provider value={{ state, signIn, expire, instance, oidc }}>
{children}
</SessionContext.Provider>
);
}
export function useSession() {
const ctx = useContext(SessionContext);
if (!ctx) throw new Error("useSession needs SessionProvider");
return ctx;
}
-1
View File
@@ -1 +0,0 @@
/// <reference types="vite/client" />
-17
View File
@@ -1,17 +0,0 @@
{
"compilerOptions": {
"target": "ES2022",
"module": "ESNext",
"moduleResolution": "bundler",
"jsx": "react-jsx",
"strict": true,
"skipLibCheck": true,
"noEmit": true,
"isolatedModules": true,
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"useDefineForClassFields": true,
"lib": ["ES2022", "DOM", "DOM.Iterable"]
},
"include": ["src", "vite.config.ts"]
}
-51
View File
@@ -1,51 +0,0 @@
import stylex from "@stylexjs/rollup-plugin";
import react from "@vitejs/plugin-react";
import type { Plugin } from "vite";
import { defineConfig } from "vite";
// The plugin string-matches file contents for StyleX imports, which also
// matches stylesheets, and then feeds them to Babel. Guard it to code.
function stylexJsOnly(): Plugin {
const inner = stylex({
fileName: "stylex.css",
unstable_moduleResolution: { type: "commonJS" },
}) as unknown as {
transform: (code: string, id: string) => unknown;
[key: string]: unknown;
};
const transform = inner.transform;
return {
...inner,
transform(this: unknown, code: string, id: string) {
if (id.split("?", 1)[0].endsWith(".css")) {
return null;
}
return Reflect.apply(transform, this, [code, id]);
},
} as unknown as Plugin;
}
export default defineConfig({
plugins: [
// Compiles the StyleX the table-filter template carries. CommonJS
// module resolution so the theme file resolves across packages.
stylexJsOnly(),
react(),
],
server: {
// The Vue dashboard owns 5173; v2 runs beside it during the migration.
// strictPort fails loudly instead of silently moving to another port.
port: 5174,
strictPort: true,
// Proxies the API to a locally running archie-ui so the frontend can be
// developed without rebuilding Go. changeOrigin stays false: archie-ui
// refuses a mutation whose Origin does not match its Host, and the
// browser's Origin is this dev server.
proxy: {
"/api": { target: "http://127.0.0.1:8484", changeOrigin: false },
"/health": { target: "http://127.0.0.1:8484", changeOrigin: false },
"/webhooks": { target: "http://127.0.0.1:8484", changeOrigin: false },
"/oauth2": { target: "http://127.0.0.1:8484", changeOrigin: false },
},
},
});