feat: add astryx design reference prototype

- scaffold a React/Vite reference app under ui/astryx-reference with shell, composer, runs, and area pages
- wire @astryxdesign packages, a neutral-derived theme, and reference dev/build scripts
- document the astryx workflow in ui/AGENTS.md
This commit is contained in:
sam committed 2026-11-19 17:36:22 +11:00
1 parent 091d117459
commit a0d14090ef
16 files changed
+3382 -1

No files matched your search

+32
View File
@@ -145,3 +145,35 @@ pnpm audit # after dependency changes
- Delegate to pi workers when asked, and verify their output. Check for overlap
before merging, rerun their checks on the combined result, and fix what they
find.
<!-- ASTRYX:START -->
Astryx v0.7.16 · 174 components
CLI: run every command as `pnpm exec astryx <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.
Before you deliver a build, run `astryx doctor --built <dir>`; don't deliver it if it fails.
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 Tailwind utilities backed by tokens. No raw hex/px.
- THEMES: palettes and custom colors go through the theme, never :root overrides. To make or change a theme (colors, fonts, corners, spacing, a look from a picture), prefer the experimental theme editor over hand-written theme files: `astryx experimental theme editor new <name> --like neutral`, then `editor set <name> <thing> <value>` or `editor how "<what you want>"`; wire it with `astryx theme add <name>`; after each change look at it with `astryx experimental theme editor show <name> --png` and open the PNGs it writes (changes nothing in the app); a theme change is not done until you have looked at the pictures. In code, extend an imported theme to customize it; `theme eject <slug>` only forks source. See `astryx docs theme`.
- SELF-CHECK: re-read the file; replace any style={{…}}, raw <div>/<span>, imported .css/@apply, or hardcoded/arbitrary value (bg-[#fff], p-[13px]) with the component or a token-backed utility.
`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 -->
+82
View File
@@ -0,0 +1,82 @@
import { Badge } from "@astryxdesign/core/Badge";
import { Button } from "@astryxdesign/core/Button";
import { Heading } from "@astryxdesign/core/Heading";
import { Layout, LayoutContent, LayoutHeader } from "@astryxdesign/core/Layout";
import { Section } from "@astryxdesign/core/Section";
import { HStack, VStack } from "@astryxdesign/core/Stack";
import { Text } from "@astryxdesign/core/Text";
import type { Area } from "./ShellFrame";
type AreaPageProps = {
area: Exclude<Area, "Composer" | "Runs">;
onOpenRun: () => void;
};
const copy = {
Events: {
heading: "What Archie heard",
subheading: "Incoming evidence and the work it started.",
title: "Checkout timeout rate exceeded 5%",
eyebrow: "Monitoring · 09:38 UTC",
body: "Checkout timeouts rose after the latest release. Archie authenticated the event, bound it to the production checkout target, and started an investigation run.",
action: "Open investigation",
seam: "Hears → Understands → Decides",
},
Governance: {
heading: "Governance",
subheading: "Policies, autonomy levels and action limits.",
title: "Production rollback requires approval",
eyebrow: "Production · Checkout · Rollback",
body: "The current autonomy level permits read-only investigation. The rollback is reversible, but it changes production. Hard rules and the Timing guard therefore require an operator decision.",
action: "Review decision",
seam: "Governs · Assesses · Manages risk · Invokes policy",
},
Reports: {
heading: "What Archie delivered",
subheading: "Outcomes, evidence and the remaining work.",
title: "Checkout investigation delivered",
eyebrow: "Operations · Waiting on approval",
body: "The investigation and evidence are in Operations. No production change has been made. The underlying release defect remains to be confirmed.",
action: "Open decision trail",
seam: "Does → Delivers",
},
} as const;
export function AreaPage({ area, onOpenRun }: AreaPageProps) {
const content = copy[area];
return (
<Layout
height="fill"
padding={4}
contentWidth={960}
header={
<LayoutHeader padding={4} hasDivider>
<VStack gap={1}>
<Heading level={1}>{content.heading}</Heading>
<Text color="secondary">{content.subheading}</Text>
</VStack>
</LayoutHeader>
}
content={
<LayoutContent padding={4}>
<Section>
<VStack gap={3}>
<HStack gap={1} wrap="wrap" vAlign="center">
<Badge variant="info" label={content.seam} />
<Text size="sm" color="secondary">
{content.eyebrow}
</Text>
</HStack>
<Heading level={2}>{content.title}</Heading>
<Text as="p">{content.body}</Text>
<HStack>
<Button label={content.action} variant="primary" onClick={onOpenRun} />
</HStack>
</VStack>
</Section>
</LayoutContent>
}
/>
);
}
+258
View File
@@ -0,0 +1,258 @@
import { useLocalStorage, useWindowSize } from "@uidotdev/usehooks";
import { Avatar } from "@astryxdesign/core/Avatar";
import { BottomSheet } from "@astryxdesign/core/BottomSheet";
import { Button } from "@astryxdesign/core/Button";
import {
ChatComposer,
ChatLayout,
ChatMessage,
ChatMessageBubble,
ChatMessageList,
} from "@astryxdesign/core/Chat";
import { Heading } from "@astryxdesign/core/Heading";
import { useMediaQuery } from "@astryxdesign/core/hooks";
import { Icon } from "@astryxdesign/core/Icon";
import { IconButton } from "@astryxdesign/core/IconButton";
import { Popover } from "@astryxdesign/core/Popover";
import { HStack, StackItem, VStack } from "@astryxdesign/core/Stack";
import { Text } from "@astryxdesign/core/Text";
import { Toolbar } from "@astryxdesign/core/Toolbar";
import mark from "../../assets/brand/archie-mark.svg?url";
export type DockedMessage = {
id: string;
sender: "user" | "assistant";
text: string;
};
type DockedComposerProps = {
context: string;
messages: DockedMessage[];
draft: string;
onDraftChange: (value: string) => void;
onSubmit: (value: string) => void;
onOpenConversation: () => void;
};
const suggestedPrompts = [
"Why does this need approval?",
"What is the risk?",
"What happens if I decline?",
] as const;
export function DockedComposer({
context,
messages,
draft,
onDraftChange,
onSubmit,
onOpenConversation,
}: DockedComposerProps) {
const isNarrow = useMediaQuery("(max-width: 48rem)");
const [isConversationOpen, setIsConversationOpen] = useLocalStorage(
"archie.astryx-reference.chat-open",
messages.length > 0,
);
const { height: viewportHeight } = useWindowSize();
const conversationHeight = Math.max(
280,
Math.min(560, (viewportHeight ?? 656) - 96),
);
function submit(value: string) {
setIsConversationOpen(true);
onSubmit(value);
}
const composer = (
<ChatComposer
density="compact"
elevation="none"
value={draft}
onChange={onDraftChange}
onSubmit={submit}
placeholder="Message Archie"
/>
);
const conversation = (
<VStack
gap={0}
width="100%"
height={isNarrow ? "100%" : conversationHeight}
>
<Toolbar
label="Archie conversation"
size="sm"
variant="transparent"
dividers={["bottom"]}
startContent={
<HStack gap={1} vAlign="center">
<Avatar
src={mark}
name="Archie"
size="sm"
shape="square"
tooltip={false}
/>
<VStack gap={0}>
<Heading level={2}>Archie</Heading>
<Text type="supporting" maxLines={1}>
{context}
</Text>
</VStack>
</HStack>
}
endContent={
<HStack gap={0.5} vAlign="center">
<Button
label="Expand"
variant="ghost"
size="sm"
onClick={onOpenConversation}
/>
<IconButton
label="Hide conversation"
tooltip="Hide conversation"
icon={<Icon icon="chevronDown" />}
variant="ghost"
size="sm"
onClick={() => setIsConversationOpen(false)}
/>
</HStack>
}
/>
<StackItem size="fill">
<ChatLayout
density="compact"
composer={
<VStack gap={1}>
<HStack gap={1} width="100%" isScrollable>
{suggestedPrompts.map((prompt) => (
<StackItem key={prompt} size="static">
<Button
label={prompt}
size="sm"
variant="secondary"
onClick={() => submit(prompt)}
/>
</StackItem>
))}
</HStack>
{composer}
</VStack>
}
>
<ChatMessageList density="compact" align="top">
{messages.map((message) => (
<ChatMessage
key={message.id}
sender={message.sender}
avatar={
message.sender === "assistant" ? (
<Avatar
src={mark}
name="Archie"
size="sm"
shape="square"
tooltip={false}
/>
) : undefined
}
>
<ChatMessageBubble
variant={message.sender === "assistant" ? "ghost" : "filled"}
>
<Text as="p">{message.text}</Text>
</ChatMessageBubble>
</ChatMessage>
))}
</ChatMessageList>
</ChatLayout>
</StackItem>
</VStack>
);
const toggleLabel = isConversationOpen
? "Hide conversation"
: "Show conversation";
const toggle = (
<IconButton
label={toggleLabel}
tooltip={toggleLabel}
icon={
<Icon icon={isConversationOpen ? "chevronDown" : "arrowUp"} />
}
variant="ghost"
size="sm"
/>
);
return (
<VStack width="100%" hAlign="end">
<HStack
gap={2}
padding={2}
width={isNarrow ? "100%" : 440}
vAlign="center"
hAlign="end"
>
{!isConversationOpen && (
<>
<Avatar
src={mark}
name="Archie"
size="sm"
shape="square"
tooltip={false}
/>
<StackItem size="fill">{composer}</StackItem>
</>
)}
{isNarrow ? (
<>
<IconButton
label={toggleLabel}
tooltip={toggleLabel}
icon={
<Icon
icon={isConversationOpen ? "chevronDown" : "arrowUp"}
/>
}
variant="ghost"
size="sm"
onClick={() => setIsConversationOpen((open) => !open)}
/>
<BottomSheet
isOpen={isConversationOpen}
onOpenChange={setIsConversationOpen}
label="Archie conversation"
height="55dvh"
padding={0}
>
{isConversationOpen ? conversation : null}
</BottomSheet>
</>
) : (
<Popover
isOpen={isConversationOpen}
onOpenChange={setIsConversationOpen}
placement="above"
alignment="end"
width={440}
padding={0}
label="Archie conversation"
isModal={false}
presentation="popover"
hasAutoFocus={false}
hasCloseButton={false}
content={isConversationOpen ? conversation : null}
>
{toggle}
</Popover>
)}
</HStack>
</VStack>
);
}
+235
View File
@@ -0,0 +1,235 @@
import { useEffect, useMemo, useState, type ReactNode } from "react";
import { AppShell } from "@astryxdesign/core/AppShell";
import { Badge } from "@astryxdesign/core/Badge";
import { Button } from "@astryxdesign/core/Button";
import { CommandPalette } from "@astryxdesign/core/CommandPalette";
import { DropdownMenu } from "@astryxdesign/core/DropdownMenu";
import { HStack, Stack } from "@astryxdesign/core/Stack";
import { Icon } from "@astryxdesign/core/Icon";
import { Layout, LayoutContent, LayoutFooter } from "@astryxdesign/core/Layout";
import { useMediaQuery } from "@astryxdesign/core/hooks";
import { SideNav, SideNavItem, SideNavSection } from "@astryxdesign/core/SideNav";
import { Text } from "@astryxdesign/core/Text";
import { TextInput } from "@astryxdesign/core/TextInput";
import { TopNav } from "@astryxdesign/core/TopNav";
import { createStaticSource } from "@astryxdesign/core/Typeahead";
import {
BellAlertIcon,
ChatBubbleLeftRightIcon,
ChartBarSquareIcon,
CheckBadgeIcon,
MagnifyingGlassIcon,
QueueListIcon,
ShieldCheckIcon,
} from "@heroicons/react/24/outline";
import wordmark from "../../assets/brand/archie-wordmark.svg?url";
import darkWordmark from "../../assets/brand/archie-wordmark-dark.svg?url";
export type Area = "Composer" | "Runs" | "Events" | "Governance" | "Reports";
type ShellFrameProps = {
activeArea: Area;
pendingCount: number;
onNavigate: (area: Area) => void;
dock?: ReactNode;
children: ReactNode;
};
const navigation = [
{
title: "Work",
items: [
{ label: "Composer", icon: ChatBubbleLeftRightIcon },
{ label: "Runs", icon: QueueListIcon },
{ label: "Events", icon: BellAlertIcon },
],
},
{
title: "Control",
items: [
{ label: "Governance", icon: ShieldCheckIcon },
{ label: "Reports", icon: ChartBarSquareIcon },
],
},
] satisfies Array<{
title: string;
items: Array<{ label: Area; icon: typeof ChatBubbleLeftRightIcon }>;
}>;
type Command = {
id: "composer" | "runs" | "events" | "governance" | "reports";
label: string;
};
const commands: Command[] = [
{ id: "composer", label: "Composer" },
{ id: "runs", label: "Runs" },
{ id: "events", label: "Events" },
{ id: "governance", label: "Governance" },
{ id: "reports", label: "Reports" },
];
export function ShellFrame({
activeArea,
pendingCount,
onNavigate,
dock,
children,
}: ShellFrameProps) {
const [isPaletteOpen, setIsPaletteOpen] = useState(false);
const [isMobileNavOpen, setIsMobileNavOpen] = useState(false);
const source = useMemo(() => createStaticSource(commands), []);
const hasInlineNavigation = useMediaQuery("(min-width: 768px)");
const prefersDark = useMediaQuery("(prefers-color-scheme: dark)");
useEffect(() => {
function openPalette(event: KeyboardEvent) {
if ((event.metaKey || event.ctrlKey) && event.key.toLowerCase() === "k") {
event.preventDefault();
setIsPaletteOpen(true);
}
}
window.addEventListener("keydown", openPalette);
return () => window.removeEventListener("keydown", openPalette);
}, []);
useEffect(() => {
setIsMobileNavOpen(false);
}, [activeArea]);
function renderNavigation() {
return (
<SideNav
collapsible
resizable={{ defaultWidth: 224, minWidth: 200, maxWidth: 320 }}
>
{navigation.map((section) => (
<SideNavSection key={section.title} title={section.title}>
{section.items.map((item) => (
<SideNavItem
key={item.label}
label={item.label}
icon={item.icon}
isSelected={activeArea === item.label}
onClick={() => navigate(item.label)}
endContent={
item.label === "Runs" && pendingCount > 0 ? (
<Badge variant="warning" label={pendingCount} />
) : undefined
}
/>
))}
</SideNavSection>
))}
</SideNav>
);
}
function navigate(area: Area) {
setIsMobileNavOpen(false);
onNavigate(area);
window.setTimeout(() => setIsMobileNavOpen(false), 0);
}
function chooseCommand(value: Command) {
setIsPaletteOpen(false);
navigate(
value.id === "composer"
? "Composer"
: value.id === "runs"
? "Runs"
: value.id === "events"
? "Events"
: value.id === "governance"
? "Governance"
: "Reports",
);
}
return (
<>
<AppShell
contentPadding={0}
topNav={
<TopNav
label="Archie workspace"
heading={
<img
src={prefersDark ? darkWordmark : wordmark}
alt="Archie"
width={88}
height={24}
/>
}
startContent={
<DropdownMenu
button={{ label: "CatlowTech", variant: "ghost", size: "sm" }}
items={[
{ label: "CatlowTech", endContent: <Badge variant="neutral" label="Instance" /> },
{ type: "divider" },
{ label: "Instance settings", onClick: () => navigate("Governance") },
]}
/>
}
endContent={
<HStack gap={1} vAlign="center">
{hasInlineNavigation && (
<Stack onClick={() => setIsPaletteOpen(true)}>
<TextInput
label="Jump to"
isLabelHidden
size="sm"
width={240}
startIcon={MagnifyingGlassIcon}
placeholder="Jump to…"
value=""
onChange={() => setIsPaletteOpen(true)}
/>
</Stack>
)}
<Button
label="Approvals"
size="sm"
variant="ghost"
icon={<Icon icon={CheckBadgeIcon} size="sm" />}
endContent={pendingCount > 0 ? <Badge variant="warning" label={pendingCount} /> : undefined}
onClick={() => navigate("Runs")}
/>
</HStack>
}
/>
}
sideNav={renderNavigation()}
mobileNav={{
breakpoint: "md",
isOpen: isMobileNavOpen,
onOpenChange: setIsMobileNavOpen,
}}
>
<Layout
height="fill"
padding={0}
content={<LayoutContent padding={0}>{children}</LayoutContent>}
footer={
dock ? (
<LayoutFooter hasDivider label="Composer">
{dock}
</LayoutFooter>
) : undefined
}
/>
</AppShell>
<CommandPalette
label="Jump to"
isOpen={isPaletteOpen}
onOpenChange={setIsPaletteOpen}
searchSource={source}
onValueChange={(value) => {
const command = commands.find((candidate) => candidate.id === value);
if (command) chooseCommand(command);
}}
/>
</>
);
}
+12
View File
@@ -0,0 +1,12 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Archie · Astryx design reference</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="./main.tsx"></script>
</body>
</html>
+152
View File
@@ -0,0 +1,152 @@
import { useState } from "react";
import { createRoot } from "react-dom/client";
import { Theme } from "@astryxdesign/core/theme";
import "@astryxdesign/core/reset.css";
import "@astryxdesign/core/astryx.css";
import { AreaPage } from "./AreaPage";
import { DockedComposer } from "./DockedComposer";
import { ShellFrame, type Area } from "./ShellFrame";
import LandingPage from "./pages/LandingPage";
import ConversationPage, {
type ConversationMessage,
} from "./pages/ConversationPage";
import RunsPage, { type RunDecision } from "./pages/RunsPage";
import { theme } from "./theme";
const answers = [
{
test: /decision|approval|blocked|waiting/i,
text: "One run needs a decision. The checkout investigation recommends a rollback after timeouts rose from 0.4% to 8.1%. Production policy requires your approval before anything changes.",
},
{
test: /risk|impact|go wrong/i,
text: "The rollback carries moderate risk because checkout may briefly lose capacity while the release changes. It is reversible: the current release can be reapplied, and no database change is proposed.",
},
{
test: /declin(e|es|ed|ing)|deny|reject/i,
text: "Declining stops the run before any production change. Archie records the exact decision and evidence; checkout remains unchanged and the timeout investigation remains unresolved.",
},
{
test: /checkout|tim(e|ing)? out/i,
text: "Only checkout is affected. Timeouts rose four minutes after the 09:34 release. That release is the leading suspect, not a confirmed cause. The proposed rollback is reversible and does not change the database.",
},
{
test: /today|did archie|what happened/i,
text: "Archie authenticated the checkout alert, investigated the timeout spike, assessed the proposed rollback, and delivered the evidence for review. Nothing changed in production.",
},
] as const;
function answerFor(prompt: string) {
return (
answers.find(({ test }) => test.test(prompt))?.text ??
"I can explain this page, open a run, or help you review the evidence and policy behind it. This reference does not start live work."
);
}
function App() {
const [activeArea, setActiveArea] = useState<Area>("Composer");
const [draft, setDraft] = useState("");
const [messages, setMessages] = useState<ConversationMessage[]>([]);
const [decision, setDecision] = useState<RunDecision>("pending");
function submit(prompt: string) {
const value = prompt.trim();
if (!value) return;
const id = crypto.randomUUID();
setMessages((current) => [
...current,
{ id: `${id}-user`, sender: "user", text: value },
{ id: `${id}-archie`, sender: "assistant", text: answerFor(value) },
]);
setDraft("");
}
function recordDecision(next: RunDecision) {
setDecision(next);
const outcome =
next === "approved"
? "The operator approved the checkout rollback. This reference would now execute the exact approved action and verify the timeout rate."
: "The operator declined the checkout rollback. No production change was made, and the run stopped at the decision.";
setMessages((current) => [
...current,
{
id: crypto.randomUUID(),
sender: "assistant",
text: outcome,
},
]);
}
const dockedComposer = (
<DockedComposer
context={
activeArea === "Runs"
? "Runs · checkout rollback"
: `${activeArea} · same conversation`
}
messages={messages}
draft={draft}
onDraftChange={setDraft}
onSubmit={submit}
onOpenConversation={() => setActiveArea("Composer")}
/>
);
return (
<ShellFrame
activeArea={activeArea}
pendingCount={decision === "pending" ? 1 : 0}
onNavigate={setActiveArea}
dock={
activeArea !== "Composer" && activeArea !== "Runs"
? dockedComposer
: undefined
}
>
{activeArea === "Composer" &&
(messages.length === 0 ? (
<LandingPage
draft={draft}
onDraftChange={setDraft}
onSubmit={submit}
onNavigate={(area) => {
const destination = {
composer: "Composer",
runs: "Runs",
events: "Events",
governance: "Governance",
reports: "Reports",
} as const;
setActiveArea(destination[area]);
}}
/>
) : (
<ConversationPage
messages={messages}
draft={draft}
onDraftChange={setDraft}
onSubmit={submit}
onOpenRun={() => setActiveArea("Runs")}
decision={decision}
/>
))}
{activeArea === "Runs" && (
<RunsPage
composer={dockedComposer}
decision={decision}
onDecision={recordDecision}
/>
)}
{activeArea !== "Composer" && activeArea !== "Runs" && (
<AreaPage area={activeArea} onOpenRun={() => setActiveArea("Runs")} />
)}
</ShellFrame>
);
}
createRoot(document.getElementById("root")!).render(
<Theme theme={theme}>
<App />
</Theme>,
);
@@ -0,0 +1,499 @@
// Copyright (c) Meta Platforms, Inc. and affiliates.
'use client';
import {useState} from 'react';
import {Avatar} from '@astryxdesign/core/Avatar';
import {Badge} from '@astryxdesign/core/Badge';
import {Button} from '@astryxdesign/core/Button';
import {Card} from '@astryxdesign/core/Card';
import {
ChatComposer,
ChatLayout,
ChatMessage,
ChatMessageBubble,
ChatMessageList,
} from '@astryxdesign/core/Chat';
import {ClickableCard} from '@astryxdesign/core/ClickableCard';
import {Dialog, DialogHeader} from '@astryxdesign/core/Dialog';
import {Icon} from '@astryxdesign/core/Icon';
import {
HStack,
Layout,
LayoutContent,
LayoutPanel,
StackItem,
VStack,
} from '@astryxdesign/core/Layout';
import {MetadataList, MetadataListItem} from '@astryxdesign/core/MetadataList';
import {useMediaQuery} from '@astryxdesign/core/hooks';
import {ResizeHandle, useResizable} from '@astryxdesign/core/Resizable';
import {Section} from '@astryxdesign/core/Section';
import {Step, Stepper} from '@astryxdesign/core/Stepper';
import {Heading, Text} from '@astryxdesign/core/Text';
import {Toolbar} from '@astryxdesign/core/Toolbar';
import {
ChevronRightIcon,
DocumentTextIcon,
XMarkIcon,
} from '@heroicons/react/24/outline';
import mark from '../../../assets/brand/archie-mark.svg?url';
const ARTIFACT_TITLE = 'Checkout rollback review';
const EVIDENCE_TRAIL = [
{
label: 'Hears',
description: 'The checkout alert fired after timeouts exceeded 5%.',
},
{
label: 'Understands',
description: 'The 09:34 release is the leading timing suspect.',
},
{
label: 'Decides',
description: 'A bounded rollback is proposed; policy requires approval.',
},
{
label: 'Defines',
description:
'The existing checkout rollback workflow supplies the exact bounded operation.',
},
{
label: 'Does',
description: 'No production change has been made.',
},
{
label: 'Delivers',
description: 'The outcome follows the operator decision in Runs.',
},
] as const;
export type ConversationMessage = {
id: string;
sender: 'user' | 'assistant';
text: string;
};
type ConversationDecision = 'pending' | 'approved' | 'declined';
function proposesCheckoutRollback(text: string) {
const normalized = text.toLowerCase();
return (
normalized.includes('checkout') &&
(normalized.includes('rollback') ||
normalized.includes('roll back') ||
(normalized.includes('roll') && normalized.includes('back')))
);
}
function RollbackArtifactBody({
decision,
}: {
decision: ConversationDecision;
}) {
const statusLabel =
decision === 'pending'
? 'Approval Required'
: decision === 'approved'
? 'Completed'
: 'Declined';
const statusVariant =
decision === 'pending'
? 'warning'
: decision === 'approved'
? 'success'
: 'neutral';
const evidenceTrail = EVIDENCE_TRAIL.map((stage) => {
if (stage.label === 'Does') {
return {
...stage,
description:
decision === 'approved'
? 'The exact approved rollback ran in production.'
: decision === 'declined'
? 'The operator declined the rollback; no production change was made.'
: stage.description,
};
}
if (stage.label === 'Delivers') {
return {
...stage,
description:
decision === 'approved'
? 'Operations received the restored timeout rate and verification.'
: decision === 'declined'
? 'Operations received the decision; the incident remains unresolved.'
: stage.description,
};
}
return stage;
});
return (
<Section variant="transparent" padding={4}>
<VStack gap={2}>
<VStack gap={2}>
<HStack gap={2} wrap="wrap" vAlign="center">
<Badge variant={statusVariant} label={statusLabel} />
<Text type="supporting" color="secondary">
Checkout · Production
</Text>
</HStack>
<Heading level={1}>Roll back checkout</Heading>
<Text as="p" type="body" color="secondary">
{decision === 'pending'
? 'The proposal is limited to checkout and is ready for an operator decision. Reviewing it here does not change production.'
: decision === 'approved'
? 'The operator approved the exact proposal in Runs. The result is recorded with the action trail.'
: 'The operator declined the exact proposal in Runs. No production change was made.'}
</Text>
</VStack>
<VStack gap={2}>
<Heading level={2}>Evidence trail</Heading>
<Stepper
activeStep={decision === 'pending' ? 4 : 5}
density="compact"
indicatorPosition="on-track"
label="Checkout run evidence trail"
orientation="vertical">
{evidenceTrail.map((stage, index) => (
<Step
key={stage.label}
step={index}
label={stage.label}
description={stage.description}
status={
decision === 'pending' && index === 4 ? 'warning' : undefined
}
/>
))}
</Stepper>
</VStack>
<MetadataList
columns="single"
label={{position: 'top'}}
title={<Heading level={2}>Decision brief</Heading>}>
<MetadataListItem label="Evidence">
<Text as="p" type="body">
Checkout timeouts rose from 0.4% to 8.1% four minutes after the
09:34 release. No other service showed a comparable increase.
The timing is strong evidence, not a confirmed root cause.
</Text>
</MetadataListItem>
<MetadataListItem label="Risk">
<Text as="p" type="body">
Moderate: checkout may briefly lose capacity while instances
move to the earlier release.
</Text>
</MetadataListItem>
<MetadataListItem label="Reversibility">
<Text as="p" type="body">
The release can be reapplied if the rollback does not restore
checkout. No database change is proposed.
</Text>
</MetadataListItem>
<MetadataListItem label="Policy decision">
<Text as="p" type="body">
Read-only investigation is allowed. This production rollback
requires operator approval in Runs; database changes remain
outside the workflow.
</Text>
</MetadataListItem>
</MetadataList>
</VStack>
</Section>
);
}
function RollbackArtifactCard({
decision,
onOpen,
}: {
decision: ConversationDecision;
onOpen: () => void;
}) {
const statusLabel =
decision === 'pending'
? 'Approval Required'
: decision === 'approved'
? 'Completed'
: 'Declined';
return (
<ClickableCard
label={`Review ${ARTIFACT_TITLE.toLowerCase()}`}
onClick={onOpen}
variant="muted"
padding={3}
width="100%">
<HStack gap={3} vAlign="center">
<Icon icon={DocumentTextIcon} size="md" color="secondary" />
<StackItem size="fill">
<VStack gap={1}>
<HStack gap={2} wrap="wrap" vAlign="center">
<Text type="label" weight="semibold">
{ARTIFACT_TITLE}
</Text>
<Badge
variant={
decision === 'pending'
? 'warning'
: decision === 'approved'
? 'success'
: 'neutral'
}
label={statusLabel}
/>
</HStack>
<Text type="supporting" color="secondary">
Evidence, risk, reversibility, and policy
</Text>
</VStack>
</StackItem>
<Icon icon={ChevronRightIcon} size="sm" color="secondary" />
</HStack>
</ClickableCard>
);
}
function ArtifactToolbar({
onClose,
onOpenRun,
}: {
onClose: () => void;
onOpenRun: () => void;
}) {
return (
<Toolbar
label="Checkout rollback actions"
dividers={['bottom']}
startContent={
<HStack gap={3} vAlign="center">
<Icon icon={DocumentTextIcon} size="sm" color="secondary" />
<VStack gap={0}>
<Text type="label" weight="semibold">
{ARTIFACT_TITLE}
</Text>
<Text type="supporting" color="secondary">
Checkout · Production
</Text>
</VStack>
</HStack>
}
endContent={
<HStack gap={1} vAlign="center">
<Button
label="Open run"
variant="primary"
size="sm"
onClick={onOpenRun}
/>
<Button
label="Close checkout rollback review"
variant="ghost"
size="sm"
icon={<Icon icon={XMarkIcon} size="sm" />}
isIconOnly
onClick={onClose}
/>
</HStack>
}
/>
);
}
export default function ConversationPage({
messages,
draft,
onDraftChange,
onSubmit,
onOpenRun,
decision,
}: {
messages: ConversationMessage[];
draft: string;
onDraftChange(value: string): void;
onSubmit(value: string): void;
onOpenRun(): void;
decision: ConversationDecision;
}) {
const isNarrow = useMediaQuery('(max-width: 48rem)');
const [closedArtifactId, setClosedArtifactId] = useState<string | null>(null);
const [dialogArtifactId, setDialogArtifactId] = useState<string | null>(null);
const artifactResize = useResizable({
defaultSize: 640,
minSize: 480,
maxSize: 960,
});
const latestAssistantIndex = messages.reduce(
(latestIndex, message, index) =>
message.sender === 'assistant' ? index : latestIndex,
-1,
);
const latestAssistantMessage =
latestAssistantIndex >= 0 ? messages[latestAssistantIndex] : null;
const hasRollbackProposal =
latestAssistantMessage != null &&
proposesCheckoutRollback(latestAssistantMessage.text);
const isDesktopArtifactOpen =
hasRollbackProposal &&
latestAssistantMessage != null &&
closedArtifactId !== latestAssistantMessage.id;
const isArtifactDialogOpen =
hasRollbackProposal &&
latestAssistantMessage != null &&
dialogArtifactId === latestAssistantMessage.id;
function openArtifact() {
if (latestAssistantMessage == null || !hasRollbackProposal) {
return;
}
if (isNarrow) {
setDialogArtifactId(latestAssistantMessage.id);
} else {
setClosedArtifactId(null);
}
}
return (
<>
<Layout
height="fill"
padding={0}
content={
<LayoutContent padding={0}>
<HStack height="100%">
<StackItem size="fill">
<VStack gap={0} width="100%" height="100%">
<ChatLayout
density="spacious"
composer={
<ChatComposer
value={draft}
onChange={onDraftChange}
onSubmit={onSubmit}
placeholder="Ask Archie about active work, evidence, or policy…"
/>
}>
<ChatMessageList>
{messages.map((message, index) => {
const isAssistant = message.sender === 'assistant';
const isRollbackMessage =
hasRollbackProposal &&
index === latestAssistantIndex;
return (
<ChatMessage
key={message.id}
sender={message.sender}
avatar={
isAssistant ? (
<Avatar
src={mark}
name="Archie"
size="md"
shape="square"
/>
) : undefined
}>
<ChatMessageBubble
variant={isAssistant ? 'ghost' : 'filled'}>
<Text as="p">{message.text}</Text>
</ChatMessageBubble>
{isRollbackMessage && (
<ChatMessageBubble variant="ghost" width="100%">
<RollbackArtifactCard
decision={decision}
onOpen={openArtifact}
/>
</ChatMessageBubble>
)}
</ChatMessage>
);
})}
</ChatMessageList>
</ChatLayout>
</VStack>
</StackItem>
{isDesktopArtifactOpen && !isNarrow && latestAssistantMessage && (
<>
<ResizeHandle
direction="horizontal"
resizable={artifactResize.props}
isReversed
pillPlacement="start"
hasDivider
label="Resize checkout rollback review"
/>
<LayoutPanel
resizable={artifactResize}
padding={0}
isScrollable={false}
label="Checkout rollback review">
<Card
variant="transparent"
padding={0}
width="100%"
height="100%">
<VStack gap={0} height="100%">
<ArtifactToolbar
onClose={() =>
setClosedArtifactId(latestAssistantMessage.id)
}
onOpenRun={onOpenRun}
/>
<StackItem size="fill" isScrollable>
<RollbackArtifactBody decision={decision} />
</StackItem>
</VStack>
</Card>
</LayoutPanel>
</>
)}
</HStack>
</LayoutContent>
}
/>
{hasRollbackProposal && latestAssistantMessage && (
<Dialog
isOpen={isArtifactDialogOpen}
onOpenChange={isOpen =>
setDialogArtifactId(isOpen ? latestAssistantMessage.id : null)
}
purpose="info"
variant="fullscreen">
<Layout
height="fill"
header={
<DialogHeader
title={ARTIFACT_TITLE}
subtitle="Checkout · Production"
onOpenChange={() => setDialogArtifactId(null)}
endContent={
<Button
label="Open run"
variant="primary"
size="sm"
onClick={onOpenRun}
/>
}
/>
}
content={
<LayoutContent padding={0}>
<RollbackArtifactBody decision={decision} />
</LayoutContent>
}
/>
</Dialog>
)}
</>
);
}
+89
View File
@@ -0,0 +1,89 @@
// Copyright (c) Meta Platforms, Inc. and affiliates.
'use client';
import {Button} from '@astryxdesign/core/Button';
import {ChatComposer} from '@astryxdesign/core/Chat';
import {
Layout,
LayoutContent,
VStack,
HStack,
} from '@astryxdesign/core/Layout';
import {VisuallyHidden} from '@astryxdesign/core/VisuallyHidden';
export type LandingArea =
| 'composer'
| 'runs'
| 'events'
| 'governance'
| 'reports';
const SUGGESTIONS: ReadonlyArray<{
prompt: string;
destination?: LandingArea;
}> = [
{
prompt: 'What needs a decision?',
destination: 'runs',
},
{
prompt: 'Why is checkout timing out?',
},
{
prompt: 'What did Archie do today?',
},
];
export default function LandingPage({
draft,
onDraftChange,
onSubmit,
onNavigate,
}: {
draft: string;
onDraftChange(value: string): void;
onSubmit(value: string): void;
onNavigate(area: LandingArea): void;
}) {
return (
<Layout
height="fill"
contentWidth={720}
padding={6}
content={
<LayoutContent label="Composer">
<VStack gap={8} vAlign="center" minHeight="100%">
<VisuallyHidden as="h1">Composer</VisuallyHidden>
<ChatComposer
value={draft}
onChange={onDraftChange}
onSubmit={onSubmit}
placeholder="Message Archie…"
/>
<VStack gap={2} paddingInline={3} hAlign="center">
<HStack gap={2} wrap="wrap" vAlign="center" hAlign="center">
{SUGGESTIONS.map(suggestion => (
<Button
key={suggestion.prompt}
label={suggestion.prompt}
variant="secondary"
size="sm"
onClick={() => {
onSubmit(suggestion.prompt);
if (suggestion.destination) {
onNavigate(suggestion.destination);
}
}}
/>
))}
</HStack>
</VStack>
</VStack>
</LayoutContent>
}
/>
);
}
+873
View File
@@ -0,0 +1,873 @@
// Copyright (c) Meta Platforms, Inc. and affiliates.
'use client';
import {Fragment, useMemo, useState} from 'react';
import type * as React from 'react';
import {BottomSheet} from '@astryxdesign/core/BottomSheet';
import {Button} from '@astryxdesign/core/Button';
import {Divider} from '@astryxdesign/core/Divider';
import {EmptyState} from '@astryxdesign/core/EmptyState';
import {Icon} from '@astryxdesign/core/Icon';
import {
HStack,
Layout,
LayoutContent,
LayoutFooter,
LayoutHeader,
LayoutPanel,
StackItem,
VStack,
} from '@astryxdesign/core/Layout';
import {List, ListItem} from '@astryxdesign/core/List';
import {
MetadataList,
MetadataListItem,
} from '@astryxdesign/core/MetadataList';
import {
PowerSearch,
usePowerSearchConfig,
} from '@astryxdesign/core/PowerSearch';
import type {PowerSearchFilter} from '@astryxdesign/core/PowerSearch';
import {ResizeHandle, useResizable} from '@astryxdesign/core/Resizable';
import {
SegmentedControl,
SegmentedControlItem,
} from '@astryxdesign/core/SegmentedControl';
import {StatusDot} from '@astryxdesign/core/StatusDot';
import {Heading, Text} from '@astryxdesign/core/Text';
import {Timestamp} from '@astryxdesign/core/Timestamp';
import {Token} from '@astryxdesign/core/Token';
import {useMediaQuery} from '@astryxdesign/core/hooks';
import {BellAlertIcon} from '@heroicons/react/24/outline';
export type RunDecision = 'pending' | 'approved' | 'declined';
type RunStatus = 'approval' | 'completed' | 'failed' | 'declined';
type StageName =
| 'Hears'
| 'Understands'
| 'Decides'
| 'Defines'
| 'Does'
| 'Delivers';
type StageState = 'complete' | 'waiting' | 'blocked';
interface RunStage {
name: StageName;
detail: string;
state: StageState;
}
interface Run extends Record<string, unknown> {
id: string;
title: string;
workflow: string;
service: string;
environment: string;
status: RunStatus;
trigger: string;
startedAt: string;
summary: string;
evidence: string;
proposedAction: string;
reversibility: string;
policy: string;
stages: RunStage[];
}
const PRIMARY_RUN_ID = 'RUN-2041';
const STAGE_ORDER: StageName[] = [
'Hears',
'Understands',
'Decides',
'Defines',
'Does',
'Delivers',
];
const STATUS_ORDER: RunStatus[] = [
'approval',
'completed',
'failed',
'declined',
];
const STATUS_LABEL: Record<RunStatus, string> = {
approval: 'Approval Required',
completed: 'Completed',
failed: 'Failed',
declined: 'Declined',
};
const STATUS_TOKEN_COLOR: Record<
RunStatus,
'yellow' | 'green' | 'red' | 'gray'
> = {
approval: 'yellow',
completed: 'green',
failed: 'red',
declined: 'gray',
};
const STATUS_DOT_VARIANT: Record<
RunStatus,
'warning' | 'success' | 'error' | 'neutral'
> = {
approval: 'warning',
completed: 'success',
failed: 'error',
declined: 'neutral',
};
const STAGE_STATE_LABEL: Record<StageState, string> = {
complete: 'Complete',
waiting: 'Waiting',
blocked: 'Blocked',
};
const STAGE_STATE_TOKEN_COLOR: Record<
StageState,
'green' | 'yellow' | 'gray'
> = {
complete: 'green',
waiting: 'yellow',
blocked: 'gray',
};
const STAGE_STATE_DOT_VARIANT: Record<
StageState,
'success' | 'warning' | 'neutral'
> = {
complete: 'success',
waiting: 'warning',
blocked: 'neutral',
};
function checkoutStages(decision: RunDecision): RunStage[] {
const decisionState: StageState =
decision === 'declined' ? 'blocked' : decision === 'approved' ? 'complete' : 'waiting';
return [
{
name: 'Hears',
detail:
'Checkout monitoring reports a timeout-rate alert after the 09:34 release.',
state: 'complete',
},
{
name: 'Understands',
detail:
'Archie links the 8.1% timeout rise to the release; no other service shows a comparable rise.',
state: 'complete',
},
{
name: 'Decides',
detail:
'Archie recommends a checkout-only rollback to the last healthy release.',
state: 'complete',
},
{
name: 'Defines',
detail:
'The existing checkout rollback workflow defines the exact bounded operation: verify 4.9.0, roll back to 4.8.2, then verify recovery.',
state: 'complete',
},
{
name: 'Does',
detail:
decision === 'approved'
? 'The approved rollback reached production and the checkout version changed to 4.8.2.'
: decision === 'declined'
? 'The operator declined the rollback. Archie made no production change.'
: 'Archie waits for the exact operator decision. No production change has been made.',
state: decisionState,
},
{
name: 'Delivers',
detail:
decision === 'approved'
? 'Operations received the result: timeout rate returned to 0.4% by 09:46 UTC.'
: decision === 'declined'
? 'Operations received the decision record; the incident remains unresolved.'
: 'Delivery waits until the approval decision and any permitted action are resolved.',
state: decision === 'pending' ? 'waiting' : 'complete',
},
];
}
function resolvedStages(...details: string[]): RunStage[] {
return STAGE_ORDER.map((name, index) => ({
name,
detail: details[index],
state: 'complete',
}));
}
function failedStages(...details: string[]): RunStage[] {
return STAGE_ORDER.map((name, index) => ({
name,
detail: details[index],
state: index === 4 ? 'blocked' : 'complete',
}));
}
const BASE_RUNS: Run[] = [
{
id: PRIMARY_RUN_ID,
title: 'Roll back checkout to the last healthy release',
workflow: 'checkout-rollback',
service: 'checkout',
environment: 'production',
status: 'approval',
trigger: 'Checkout timeout alert',
startedAt: '2026-11-19T09:38:00Z',
summary: 'Evidence points to release 4.9.0; rollback awaits an exact decision',
evidence:
'Checkout timeouts rose from 0.4% to 8.1% four minutes after release 4.9.0. No other service showed a comparable rise.',
proposedAction:
'Roll back checkout only from 4.9.0 to 4.8.2, then verify the deployed version and timeout rate.',
reversibility:
'Moderate risk: checkout may briefly lose capacity during rollout. Release 4.9.0 can be reapplied. The database is unchanged.',
policy:
'Read-only investigation is allowed. A production rollback needs operator approval. Database changes are blocked.',
stages: checkoutStages('pending'),
},
{
id: 'RUN-2040',
title: 'Rebuild the payments search projection',
workflow: 'projection-rebuild',
service: 'payments',
environment: 'production',
status: 'completed',
trigger: 'Projection lag alert',
startedAt: '2026-11-19T08:52:00Z',
summary: 'Rebuilt 18,420 stale documents and verified query freshness',
evidence:
'Projection lag crossed 12 minutes after the indexing worker was rescheduled. Source events remained intact.',
proposedAction:
'Pause the stale reader, rebuild the projection from verified source events, and run a freshness check.',
reversibility:
'Low risk. The prior read projection remained available until the replacement passed validation.',
policy:
'Rebuilding a derived projection is permitted. Changing source payment records requires separate approval.',
stages: resolvedStages(
'The projection lag alert reported 18,420 stale payment documents.',
'Archie verified source-event continuity and isolated the stale read model.',
'Archie selected a full projection rebuild with no source-record mutation.',
'The operation paused the reader, rebuilt it, and checked the newest document offset.',
'The replacement projection rebuilt successfully without changing payment records.',
'Payments received a freshness report with 0 documents outside the lag budget.',
),
},
{
id: 'RUN-2039',
title: 'Retry webhook deliveries from the failed queue',
workflow: 'webhook-recovery',
service: 'webhooks',
environment: 'production',
status: 'failed',
trigger: 'Queue saturation alert',
startedAt: '2026-11-19T08:11:00Z',
summary: 'Stopped before replay because the target allowlist did not match policy',
evidence:
'The failed queue held 2,104 deliveries, including two destinations outside the approved recovery allowlist.',
proposedAction:
'Replay deliveries only to approved destinations and retain the rest for operator review.',
reversibility:
'No delivery replay occurred. The retained queue can be reviewed without duplicating external side effects.',
policy:
'External delivery is limited to approved destinations. The policy match must pass before replay starts.',
stages: failedStages(
'The webhook queue alert reported 2,104 failed deliveries.',
'Archie compared each destination with the active recovery allowlist.',
'Archie separated approved destinations from two destinations needing review.',
'The replay operation was constrained to the approved subset.',
'Policy blocked the mixed-destination replay before any message left the queue.',
'Operations received the failed-policy decision and the retained queue count.',
),
},
{
id: 'RUN-2038',
title: 'Restore the stale warehouse cache',
workflow: 'cache-restore',
service: 'warehouse',
environment: 'staging',
status: 'completed',
trigger: 'Freshness report',
startedAt: '2026-11-18T23:24:00Z',
summary: 'Restored cache generation 41 and verified sample query parity',
evidence:
'The active cache was two generations behind while the source data and last good cache remained available.',
proposedAction:
'Promote cache generation 41 after parity checks, then invalidate the stale generation.',
reversibility:
'Generation 40 remains retained and can be promoted again if parity checks regress.',
policy:
'Staging cache promotion is permitted because it does not modify source data.',
stages: resolvedStages(
'The freshness report identified warehouse cache generation 40 as stale.',
'Archie compared source and cache generation metadata and found generation 41 intact.',
'Archie chose a staged promotion with before-and-after parity checks.',
'The operation promoted generation 41 and retained generation 40 as fallback.',
'Staging switched to generation 41 and sample queries passed.',
'Data Operations received the parity report and active generation.',
),
},
{
id: 'RUN-2037',
title: 'Rotate the notification scheduler worker',
workflow: 'worker-recovery',
service: 'notifications',
environment: 'production',
status: 'completed',
trigger: 'Worker heartbeat miss',
startedAt: '2026-11-18T21:07:00Z',
summary: 'Replaced one unhealthy worker and drained its duplicate task safely',
evidence:
'Worker notifications-7 missed three heartbeats while the scheduler retained its last lease record.',
proposedAction:
'Drain notifications-7, start a replacement, and verify one active lease per scheduled task.',
reversibility:
'The replacement remained behind the healthy pool until lease uniqueness passed; the old worker could be returned if needed.',
policy:
'Worker replacement is permitted. Sending an ad hoc notification requires a separate workflow and grant.',
stages: resolvedStages(
'The scheduler reported three missed heartbeats from notifications-7.',
'Archie confirmed one retained lease and no customer-visible delay.',
'Archie selected a worker rotation without changing notification content.',
'The operation drained leases, started a replacement, and checked duplicate claims.',
'The replacement joined the pool and every scheduled task had one active lease.',
'Notifications Operations received the worker replacement and lease audit.',
),
},
{
id: 'RUN-2036',
title: 'Reconcile the expired identity group sync',
workflow: 'identity-reconcile',
service: 'identity',
environment: 'production',
status: 'failed',
trigger: 'Credential expiry',
startedAt: '2026-11-18T18:43:00Z',
summary: 'Stopped at the first protected group; no membership was changed',
evidence:
'The sync reached an expired credential after loading 61 proposed membership differences, including four protected groups.',
proposedAction:
'Renew the credential and replay only the membership differences allowed by the protected-group policy.',
reversibility:
'No membership update was applied. A renewed credential and a new run can reproduce the proposed difference set.',
policy:
'Protected groups cannot be reconciled by this workflow. Credential renewal does not authorize protected membership changes.',
stages: failedStages(
'The scheduled identity sync reported an expired service credential.',
'Archie loaded the difference set and found four protected groups among 61 entries.',
'Archie separated ordinary group changes from the protected group set.',
'The operation required a renewed credential and an allowed destination scope.',
'Policy stopped execution before the first membership write.',
'Identity Operations received the scope and credential failure report.',
),
},
];
const STATUS_VALUES = STATUS_ORDER.map(value => ({
value,
label: STATUS_LABEL[value],
}));
const SERVICE_VALUES = [
{value: 'checkout', label: 'Checkout'},
{value: 'payments', label: 'Payments'},
{value: 'webhooks', label: 'Webhooks'},
{value: 'warehouse', label: 'Warehouse'},
{value: 'notifications', label: 'Notifications'},
{value: 'identity', label: 'Identity'},
];
const ENVIRONMENT_VALUES = [
{value: 'production', label: 'Production'},
{value: 'staging', label: 'Staging'},
];
const fieldDefs = [
{key: 'title', type: 'string', label: 'Title'},
{key: 'id', type: 'string', label: 'Run'},
{key: 'workflow', type: 'string', label: 'Workflow'},
{
key: 'service',
type: 'enum',
label: 'Service',
enumValues: SERVICE_VALUES,
},
{
key: 'environment',
type: 'enum',
label: 'Environment',
enumValues: ENVIRONMENT_VALUES,
},
{
key: 'status',
type: 'enum',
label: 'Status',
enumValues: STATUS_VALUES,
},
] as const;
function getRuns(decision: RunDecision): Run[] {
return BASE_RUNS.map(run => {
if (run.id !== PRIMARY_RUN_ID) {
return run;
}
return {
...run,
status:
decision === 'pending'
? 'approval'
: decision === 'approved'
? 'completed'
: 'declined',
summary:
decision === 'pending'
? run.summary
: decision === 'approved'
? 'Rollback completed; checkout timeouts returned to 0.4%'
: 'Operator declined the rollback; no production change was made',
stages: checkoutStages(decision),
};
});
}
function RunRows({
runs,
selectedId,
onSelect,
}: {
runs: Run[];
selectedId: string | null;
onSelect: (id: string) => void;
}) {
const groups = STATUS_ORDER.map(status => ({
status,
items: runs.filter(run => run.status === status),
})).filter(group => group.items.length > 0);
if (groups.length === 0) {
return (
<EmptyState
title="No matching runs"
description="Adjust the status filter or clear search filters."
icon={<Icon icon={BellAlertIcon} size="lg" />}
/>
);
}
return (
<VStack gap={0}>
{groups.map(group => (
<VStack gap={0} key={group.status}>
<HStack
gap={2}
paddingBlock={2}
paddingInline={3}
vAlign="center">
<Text type="label" color="secondary">
{STATUS_LABEL[group.status]}
</Text>
<Text type="supporting" color="secondary">
{group.items.length}
</Text>
</HStack>
<Divider />
<List density="compact" hasDividers>
{group.items.map(run => (
<ListItem
key={run.id}
label={run.title}
description={`${run.id} · ${run.workflow} · ${run.summary}`}
startContent={
<StatusDot
variant={STATUS_DOT_VARIANT[run.status]}
label={STATUS_LABEL[run.status]}
isPulsing={run.status === 'approval'}
/>
}
endContent={
<HStack gap={3} vAlign="center">
<Token
size="sm"
color={STATUS_TOKEN_COLOR[run.status]}
label={STATUS_LABEL[run.status]}
/>
<Timestamp
value={run.startedAt}
format="relative_short"
color="secondary"
/>
</HStack>
}
onClick={() => onSelect(run.id)}
isSelected={run.id === selectedId}
/>
))}
</List>
</VStack>
))}
</VStack>
);
}
function StageDetail({stage}: {stage: RunStage}) {
return (
<ListItem
label={stage.name}
description={stage.detail}
startContent={
<StatusDot
variant={STAGE_STATE_DOT_VARIANT[stage.state]}
label={`${stage.name}: ${STAGE_STATE_LABEL[stage.state]}`}
/>
}
endContent={
<Token
size="sm"
color={STAGE_STATE_TOKEN_COLOR[stage.state]}
label={STAGE_STATE_LABEL[stage.state]}
/>
}
/>
);
}
function RunInspector({
run,
decision,
onDecision,
onClose,
}: {
run: Run;
decision: RunDecision;
onDecision: (decision: RunDecision) => void;
onClose?: () => void;
}) {
const needsDecision = run.id === PRIMARY_RUN_ID && decision === 'pending';
return (
<VStack gap={4} padding={4}>
<VStack gap={2}>
<HStack gap={2} vAlign="center" wrap="wrap">
<StackItem size="fill">
<HStack gap={2} vAlign="center" wrap="wrap">
<StatusDot
variant={STATUS_DOT_VARIANT[run.status]}
label={STATUS_LABEL[run.status]}
isPulsing={run.status === 'approval'}
/>
<Text type="supporting" color="secondary">
{run.id}
</Text>
<Token
size="sm"
color={STATUS_TOKEN_COLOR[run.status]}
label={STATUS_LABEL[run.status]}
/>
</HStack>
</StackItem>
{onClose && (
<Button
label="Close details"
variant="ghost"
size="sm"
onClick={onClose}
/>
)}
</HStack>
<Heading level={2}>{run.title}</Heading>
</VStack>
{needsDecision && (
<HStack gap={2} wrap="wrap">
<Button
label="Approve rollback"
variant="primary"
size="sm"
onClick={() => onDecision('approved')}
/>
<Button
label="Decline rollback"
variant="secondary"
size="sm"
onClick={() => onDecision('declined')}
/>
</HStack>
)}
<MetadataList
columns="single"
label={{position: 'start', width: 96}}>
<MetadataListItem label="Service">
<Text type="body">{run.service}</Text>
</MetadataListItem>
<MetadataListItem label="Environment">
<Text type="body">{run.environment}</Text>
</MetadataListItem>
<MetadataListItem label="Started">
<Timestamp
value={run.startedAt}
format="date_time"
timezoneID="UTC"
/>
</MetadataListItem>
<MetadataListItem label="Trigger">
<Text type="body">{run.trigger}</Text>
</MetadataListItem>
</MetadataList>
<Divider />
<VStack gap={2}>
<Heading level={3}>Run path</Heading>
<HStack gap={1} vAlign="center" wrap="wrap">
{run.stages.map((stage, index) => (
<Fragment key={stage.name}>
<Token
size="sm"
color={
stage.state === 'complete'
? 'green'
: stage.state === 'waiting'
? 'yellow'
: 'gray'
}
label={stage.name}
/>
{index < run.stages.length - 1 && (
<Icon icon="chevronRight" size="xsm" color="secondary" />
)}
</Fragment>
))}
</HStack>
<HStack gap={1} wrap="wrap">
<Token size="sm" color="purple" label="Governs" />
<Token size="sm" color="cyan" label="Assesses" />
<Token size="sm" color="orange" label="Manages risk" />
<Token size="sm" color="yellow" label="Invokes policy" />
</HStack>
<List density="compact">
{run.stages.map(stage => (
<StageDetail key={stage.name} stage={stage} />
))}
</List>
</VStack>
<Divider />
<VStack gap={2}>
<Heading level={3}>Decision record</Heading>
<MetadataList columns="single" label={{position: 'top'}}>
<MetadataListItem label="Evidence">
<Text as="p" type="body">
{run.evidence}
</Text>
</MetadataListItem>
<MetadataListItem label="Proposed action">
<Text as="p" type="body">
{run.proposedAction}
</Text>
</MetadataListItem>
<MetadataListItem label="Reversibility">
<Text as="p" type="body">
{run.reversibility}
</Text>
</MetadataListItem>
<MetadataListItem label="Policy">
<Text as="p" type="body">
{run.policy}
</Text>
</MetadataListItem>
</MetadataList>
</VStack>
</VStack>
);
}
export default function RunsPage({
composer,
decision,
onDecision,
}: {
composer: React.ReactNode;
decision: RunDecision;
onDecision: (decision: RunDecision) => void;
}) {
const [statusFilter, setStatusFilter] = useState('all');
const [filters, setFilters] = useState<PowerSearchFilter[]>([]);
const [selectedId, setSelectedId] = useState<string | null>(PRIMARY_RUN_ID);
const [isMobileInspectorOpen, setIsMobileInspectorOpen] = useState(false);
const {config, applyFilters} = usePowerSearchConfig(fieldDefs, 'Runs');
const isNarrow = useMediaQuery('(max-width: 1024px)');
const inspectorPanel = useResizable({
defaultSize: 380,
minSize: 320,
maxSize: 480,
});
const runs = useMemo(() => getRuns(decision), [decision]);
const visible = useMemo(() => {
const searched = applyFilters(filters, runs);
return statusFilter === 'all'
? searched
: searched.filter(run => run.status === statusFilter);
}, [applyFilters, filters, runs, statusFilter]);
const selected = visible.find(run => run.id === selectedId) ?? null;
const approvalCount = runs.filter(run => run.status === 'approval').length;
const selectRun = (id: string) => {
setSelectedId(id);
if (isNarrow) {
setIsMobileInspectorOpen(true);
}
};
return (
<Fragment>
<Layout
height="fill"
header={
<LayoutHeader hasDivider>
<HStack gap={3} vAlign="center" wrap="wrap">
<StackItem size="fill">
<HStack gap={2} vAlign="center" wrap="wrap">
<Heading level={1}>Runs</Heading>
<Text type="supporting" color="secondary">
{approvalCount} awaiting approval
</Text>
</HStack>
</StackItem>
<SegmentedControl
label="Filter runs by status"
value={statusFilter}
onChange={setStatusFilter}
size="sm">
<SegmentedControlItem label="All" value="all" />
<SegmentedControlItem label="Approval" value="approval" />
<SegmentedControlItem label="Completed" value="completed" />
<SegmentedControlItem label="Failed" value="failed" />
<SegmentedControlItem label="Declined" value="declined" />
</SegmentedControl>
</HStack>
</LayoutHeader>
}
content={
<LayoutContent padding={0}>
<Layout
height="fill"
content={
<LayoutContent padding={0}>
<VStack
gap={0}
height="100%"
minHeight={0}
hAlign="stretch">
<HStack padding={3}>
<StackItem size="fill">
<PowerSearch
config={config}
filters={filters}
onChange={newFilters =>
setFilters([...newFilters])
}
label="Search runs"
placeholder="Search runs..."
resultCount={visible.length}
/>
</StackItem>
</HStack>
<Divider />
<StackItem size="fill" isScrollable>
<RunRows
runs={visible}
selectedId={selected?.id ?? null}
onSelect={selectRun}
/>
</StackItem>
</VStack>
</LayoutContent>
}
end={
isNarrow ? undefined : (
<Fragment>
<ResizeHandle
direction="horizontal"
isReversed
hasDivider
isAlwaysVisible={false}
resizable={inspectorPanel.props}
label="Resize run inspector"
/>
<LayoutPanel
width={inspectorPanel.size}
resizable={inspectorPanel}
padding={0}
isScrollable
label="Run details">
{selected ? (
<RunInspector
run={selected}
decision={decision}
onDecision={onDecision}
/>
) : (
<EmptyState
title="No run selected"
description="Select a run to see its stages and decision record."
icon={<Icon icon={BellAlertIcon} size="lg" />}
isCompact
/>
)}
</LayoutPanel>
</Fragment>
)
}
/>
</LayoutContent>
}
footer={
<LayoutFooter hasDivider padding={0} label="Composer">
{composer}
</LayoutFooter>
}
/>
{isNarrow && (
<BottomSheet
isOpen={isMobileInspectorOpen && selected !== null}
onOpenChange={setIsMobileInspectorOpen}
label={selected?.title ?? 'Run details'}
height="tall"
padding={0}>
{selected ? (
<RunInspector
run={selected}
decision={decision}
onDecision={onDecision}
onClose={() => setIsMobileInspectorOpen(false)}
/>
) : (
<EmptyState
title="No run selected"
description="Select a run to see its stages and decision record."
icon={<Icon icon={BellAlertIcon} size="lg" />}
isCompact
/>
)}
</BottomSheet>
)}
</Fragment>
);
}
+39
View File
@@ -0,0 +1,39 @@
import { defineTheme } from "@astryxdesign/core/theme";
import "@fontsource-variable/ibm-plex-sans";
import { defaultThemeSlug, themes } from "../src/astryx-themes";
export const theme = defineTheme({
name: "archie-reference",
extends: themes[defaultThemeSlug],
tokens: {
"--font-family-body": '"IBM Plex Sans Variable", system-ui, sans-serif',
"--font-family-heading": "var(--font-family-body)",
"--color-background-body": ["#f5f4f1", "#16171a"],
"--color-background-surface": ["#ffffff", "#1c1d21"],
"--color-background-card": "var(--color-background-surface)",
"--color-background-popover": ["#ffffff", "#202226"],
"--color-background-muted": ["#ecebe7", "#26282c"],
"--color-border": ["#dcdad4", "#313338"],
"--color-border-emphasized": ["#c7c4bd", "#3c3f45"],
"--color-text-primary": ["#1f1f1d", "#e8e6e1"],
"--color-text-secondary": ["#5c5a55", "#a6a39b"],
"--color-accent": "#2e795a",
"--color-text-accent": ["#0c6f4d", "#51a580"],
"--text-heading-1-size": "0.9375rem",
"--text-heading-2-size": "0.9375rem",
"--radius-element": "0.25rem",
"--radius-inner": "0.25rem",
"--radius-container": "0.375rem",
"--radius-page": "0.5rem",
"--color-text-warning": ["#8a5a12", "#d9a45b"],
},
components: {
badge: {
base: { borderRadius: "var(--radius-element)" },
"variant:warning": {
backgroundColor: "color-mix(in srgb, var(--color-text-warning) 10%, transparent)",
color: "var(--color-text-warning)",
},
},
},
});
+14
View File
@@ -0,0 +1,14 @@
{
"compilerOptions": {
"target": "ES2022",
"lib": ["ES2022", "DOM", "DOM.Iterable"],
"module": "ESNext",
"moduleResolution": "Bundler",
"jsx": "react-jsx",
"types": ["vite/client"],
"strict": true,
"skipLibCheck": true,
"noEmit": true
},
"include": ["**/*.ts", "**/*.tsx"]
}
+12
View File
@@ -0,0 +1,12 @@
import { defineConfig } from "vite";
export default defineConfig({
cacheDir: "../node_modules/.cache/astryx-vite",
build: {
outDir: "../node_modules/.cache/astryx-reference",
emptyOutDir: true,
},
server: {
fs: { allow: [".."] },
},
});
+12
View File
@@ -7,15 +7,22 @@
"dev": "vite",
"build": "vue-tsc -b && vite build",
"preview": "vite preview",
"reference": "vite astryx-reference --config astryx-reference/vite.config.ts --host 127.0.0.1",
"reference:build": "tsc -p astryx-reference && vite build astryx-reference --config astryx-reference/vite.config.ts",
"test": "node --test --experimental-strip-types test/*.test.ts",
"typecheck": "vue-tsc --build --force"
},
"dependencies": {
"@astryxdesign/core": "^0.7.16",
"@astryxdesign/theme-neutral": "^0.7.16",
"@fontsource-variable/ibm-plex-sans": "^5.3.0",
"@fontsource/ibm-plex-mono": "^5.3.0",
"@heroicons/react": "^2.2.0",
"@lucide/vue": "^1.61.0",
"@stylexjs/stylex": "^0.19.2",
"@tailwindcss/vite": "^4.3.3",
"@tanstack/vue-form": "^1.33.5",
"@uidotdev/usehooks": "^2.4.1",
"@vue-flow/background": "^1.3.2",
"@vue-flow/core": "^1.48.2",
"@vueuse/core": "^15.0.0",
@@ -23,6 +30,8 @@
"clsx": "^2.1.1",
"cn": "^0.5.1",
"pinia": "^4.0.3",
"react": "^19.3.1",
"react-dom": "^19.3.1",
"reka-ui": "^2.10.5",
"shiki": "^4.5.0",
"tailwind-merge": "^3.7.0",
@@ -34,7 +43,10 @@
"yaml": "^2.9.1"
},
"devDependencies": {
"@astryxdesign/cli": "^0.7.16",
"@types/node": "^26.6.4",
"@types/react": "^19.3.0",
"@types/react-dom": "^19.3.0",
"@vitejs/plugin-vue": "^6.0.8",
"@vue/tsconfig": "^0.9.1",
"spotnote": "0.5.0",
+1056 -1
View File
File diff suppressed because it is too large. Load diff
+2
View File
@@ -1,2 +1,4 @@
allowBuilds:
'@astryxdesign/cli': true
'@astryxdesign/core': true
vue-demi: true
+15
View File
@@ -0,0 +1,15 @@
/**
* @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";