Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions packages/alert-dashboard/e2e/ops.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,14 @@ test("a section page leads with summaries, then trends, then the signals", async
const trends = page.getByRole("heading", { level: 2, name: "Trends" });
expect(await top(trends)).toBeGreaterThan(await top(summaries.last()));
expect(await top(signals)).toBeGreaterThan(await top(trends));
const panels = page.locator(".signal-columns .panel");
const panels = page.locator(".ui-columns .ui-section");
await expect(panels).toHaveCount(4);
const backups = page.getByRole("region", { name: /^Maintenance/u });
await expect(backups.getByRole("heading", { level: 3 })).toHaveText(
/^Maintenance\s*\d+$/u,
"Maintenance",
);
await expect(backups.locator(".ui-section-head .ui-count")).toHaveText(
/^\d+$/u,
);
await expect(backups.locator(".signal").first()).toBeVisible();
expect(await top(panels.first())).toBeGreaterThan(await top(signals));
Expand Down
31 changes: 13 additions & 18 deletions packages/alert-dashboard/src/client/ops/ai-page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { ButtonLink, StatusGlyph } from "@shepherdjerred/console-ui";
import {
ButtonLink,
Section as SectionBlock,
StatusGlyph,
} from "@shepherdjerred/console-ui";
import { findMetric, findSection } from "@shepherdjerred/ops-model/assemble.ts";
import { METRIC_IDS } from "@shepherdjerred/ops-model/metric-ids.ts";
import { OPS_POLICY } from "@shepherdjerred/ops-model/policy.ts";
Expand Down Expand Up @@ -38,11 +42,10 @@ function SpendPanel({
const severity: Severity =
spent === null ? "unknown" : overBudget ? "warning" : "ok";
return (
<section className="panel spend-panel" aria-labelledby="spend-heading">
<header className="panel-heading">
<h2 id="spend-heading">API spend this month</h2>
<StatusGlyph severity={severity} />
</header>
<SectionBlock
title="API spend this month"
actions={<StatusGlyph severity={severity} />}
>
<p className="hero-figure">
{formatValue(spent, "usd")}
<span> of {formatValue(budget, "usd")} budget</span>
Expand Down Expand Up @@ -72,12 +75,12 @@ function SpendPanel({
/>
)}
</div>
<p className="panel-summary">
<p className="spend-summary">
Projected month end {formatValue(projected, "usd")}
{overBudget ? ", over budget" : ", within budget"}. Cluster LLM spend
for the UTC month, priced from the catalog; subscriptions are fixed.
</p>
</section>
</SectionBlock>
);
}

Expand Down Expand Up @@ -150,22 +153,14 @@ function AiBody({
/>
</div>
{other.length === 0 ? null : (
<section
className="panel list-panel"
aria-labelledby="ai-signals-heading"
>
<header className="panel-heading">
<h2 id="ai-signals-heading">
Other signals <span className="ui-count">{other.length}</span>
</h2>
</header>
<SectionBlock title="Other signals" count={other.length}>
<SignalList
signals={other}
empty=""
label="Other signals"
newIds={new Set(snapshot.newSignalIds)}
/>
</section>
</SectionBlock>
)}
</>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function render(signals: readonly Signal[]): string {
<QuotaTable
model={quotaTable(signals, GENERATED_AT)}
now={NOW}
labelledBy="quota-heading"
label="Subscription quota"
/>,
);
}
Expand Down Expand Up @@ -80,7 +80,7 @@ describe("QuotaTable", () => {
it("is one table with a row group and a group header per provider", () => {
const html = render(WINDOWS);
expect(html).toContain(
'<table class="quota-table ui-table" role="table" aria-labelledby="quota-heading">',
'<table class="quota-table ui-table" role="table" aria-label="Subscription quota">',
);
expect(html.match(/<tbody/gu)).toHaveLength(3);
expect(
Expand Down Expand Up @@ -245,7 +245,7 @@ describe("QuotaPanel", () => {
<QuotaPanel signals={WINDOWS} generatedAt={GENERATED_AT} />,
);
expect(html).toContain(
'<h2 id="quota-heading">Subscription quota <span class="ui-count">4</span></h2>',
'Subscription quota</h2><span class="ui-count">4</span>',
);
expect(html.match(/role="meter"/gu)).toHaveLength(4);
});
Expand Down
23 changes: 7 additions & 16 deletions packages/alert-dashboard/src/client/ops/ai-quota-table.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Temporal } from "@js-temporal/polyfill";
import { StatusGlyph } from "@shepherdjerred/console-ui";
import { Section, StatusGlyph } from "@shepherdjerred/console-ui";
import type { Signal } from "@shepherdjerred/ops-model/snapshot.ts";

import {
Expand Down Expand Up @@ -163,19 +163,15 @@ function InvalidRows({
export function QuotaTable({
model,
now,
labelledBy,
label,
}: {
readonly model: QuotaTableModel;
readonly now: Temporal.Instant;
readonly labelledBy: string;
readonly label: string;
}): React.JSX.Element {
return (
<div className="table-scroll">
<table
className="quota-table ui-table"
role="table"
aria-labelledby={labelledBy}
>
<table className="quota-table ui-table" role="table" aria-label={label}>
<thead role="rowgroup">
<tr role="row">
<th scope="col" role="columnheader">
Expand Down Expand Up @@ -213,21 +209,16 @@ export function QuotaPanel({
}): React.JSX.Element {
const model = quotaTable(signals, generatedAt);
return (
<section className="panel quota-panel" aria-labelledby="quota-heading">
<header className="panel-heading">
<h2 id="quota-heading">
Subscription quota <span className="ui-count">{signals.length}</span>
</h2>
</header>
<Section title="Subscription quota" count={signals.length}>
{signals.length === 0 ? (
<p className="list-empty">No quota windows reported.</p>
) : (
<QuotaTable
model={model}
now={Temporal.Now.instant()}
labelledBy="quota-heading"
label="Subscription quota"
/>
)}
</section>
</Section>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ describe("toolSpend", () => {
describe("ToolSpendPanel", () => {
it("is a table of tool and API-equivalent spend with a total row", () => {
const html = renderToStaticMarkup(<ToolSpendPanel signals={TOOLS} />);
expect(html).toContain('<h2 id="tool-spend-heading">Usage by tool</h2>');
expect(html).toContain("Usage by tool</h2>");
expect(html).toContain(
'<table class="tool-table ui-table" aria-labelledby="tool-spend-heading" aria-describedby="tool-spend-note">',
'<table class="tool-table ui-table" aria-label="Usage by tool" aria-describedby="tool-spend-note">',
);
expect(html).toContain(
'<th scope="col">Tool</th><th scope="col" class="ui-num">API-equivalent this month</th>',
Expand Down Expand Up @@ -100,9 +100,7 @@ describe("ToolSpendPanel", () => {

it("explains what API-equivalent means", () => {
const html = renderToStaticMarkup(<ToolSpendPanel signals={TOOLS} />);
expect(html).toContain(
'<p class="panel-summary tool-note" id="tool-spend-note">',
);
expect(html).toContain('<p class="tool-note" id="tool-spend-note">');
expect(html).toContain("would have cost at API prices");
expect(html).toContain("not money spent");
});
Expand Down
12 changes: 5 additions & 7 deletions packages/alert-dashboard/src/client/ops/ai-tool-spend.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Section } from "@shepherdjerred/console-ui";
import type { Signal } from "@shepherdjerred/ops-model/snapshot.ts";
import { z } from "zod";

Expand Down Expand Up @@ -60,7 +61,7 @@ function ToolSpendTable({
return (
<table
className="tool-table ui-table"
aria-labelledby="tool-spend-heading"
aria-label="Usage by tool"
aria-describedby="tool-spend-note"
>
<thead>
Expand Down Expand Up @@ -115,22 +116,19 @@ export function ToolSpendPanel({
readonly signals: readonly Signal[];
}): React.JSX.Element {
return (
<section className="panel tool-panel" aria-labelledby="tool-spend-heading">
<header className="panel-heading">
<h2 id="tool-spend-heading">Usage by tool</h2>
</header>
<Section title="Usage by tool">
{signals.length === 0 ? (
<p className="list-empty">No tool usage reported.</p>
) : (
<>
<p className="panel-summary tool-note" id="tool-spend-note">
<p className="tool-note" id="tool-spend-note">
API-equivalent is what each tool&apos;s usage on the Mac this month
would have cost at API prices. Most of it runs on subscriptions, so
it is not money spent.
</p>
<ToolSpendTable spend={toolSpend(signals)} />
</>
)}
</section>
</Section>
);
}
19 changes: 5 additions & 14 deletions packages/alert-dashboard/src/client/ops/ops-ui.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
ButtonLink,
FigureStrip,
HeaderBar,
Section as SectionBlock,
State,
StatusGlyph,
Tabs,
Expand Down Expand Up @@ -419,16 +420,11 @@ function TrendRow({ trend }: { readonly trend: Trend }): React.JSX.Element {
/** Trends compare whole weeks, so only the weekly report carries them. */
export function TrendPanel({
trends,
headingId = "trends-heading",
}: {
readonly trends: readonly Trend[];
readonly headingId?: string;
}): React.JSX.Element {
return (
<section className="panel" aria-labelledby={headingId}>
<header className="panel-heading">
<h2 id={headingId}>Compared with the previous week</h2>
</header>
<SectionBlock title="Compared with the previous week">
<div className="table-scroll">
<table className="trend-table ui-table">
<thead>
Expand All @@ -452,22 +448,17 @@ export function TrendPanel({
</tbody>
</table>
</div>
</section>
</SectionBlock>
);
}

export function IncidentPanel({
incidents,
headingId = "incident-heading",
}: {
readonly incidents: DigestReport["incidents"];
readonly headingId?: string;
}): React.JSX.Element {
return (
<section className="panel incident-panel" aria-labelledby={headingId}>
<header className="panel-heading">
<h2 id={headingId}>Incidents</h2>
</header>
<SectionBlock title="Incidents">
<FigureStrip
figures={[
{ label: "Opened", value: incidents.opened },
Expand All @@ -481,6 +472,6 @@ export function IncidentPanel({
},
]}
/>
</section>
</SectionBlock>
);
}
16 changes: 3 additions & 13 deletions packages/alert-dashboard/src/client/ops/pages/product-page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { State, StatusGlyph } from "@shepherdjerred/console-ui";
import { Section, State, StatusGlyph } from "@shepherdjerred/console-ui";
import { Loaded } from "@shepherdjerred/loaded";
import { findSection } from "@shepherdjerred/ops-model/assemble.ts";
import type { PostHogFacet } from "@shepherdjerred/ops-model/facets.ts";
Expand Down Expand Up @@ -181,24 +181,14 @@ export function ProductPageView({
/>
)}
{productSection === null || productSection.signals.length === 0 ? null : (
<section
className="panel list-panel"
aria-labelledby="product-signals-heading"
style={{ marginTop: "18px" }}
>
<header className="panel-heading">
<h2 id="product-signals-heading">
Product signals{" "}
<span className="ui-count">{productSection.signals.length}</span>
</h2>
</header>
<Section title="Product signals" count={productSection.signals.length}>
<SignalList
signals={productSection.signals}
empty="No product signals."
label="Product signals"
newIds={new Set(snapshot?.newSignalIds)}
/>
</section>
</Section>
)}
</>
);
Expand Down
32 changes: 11 additions & 21 deletions packages/alert-dashboard/src/client/ops/pages/the-storm-page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { ButtonLink, State, StatusGlyph } from "@shepherdjerred/console-ui";
import {
ButtonLink,
Section,
State,
StatusGlyph,
} from "@shepherdjerred/console-ui";
import { Loaded } from "@shepherdjerred/loaded";
import { LoadingBlock } from "@shepherdjerred/loaded/react.tsx";
import { allSignals, rankSignals } from "@shepherdjerred/ops-model/assemble.ts";
Expand Down Expand Up @@ -330,31 +335,16 @@ export function TheStormPageView({
syncKey="storm"
/>
</div>
<div className="service-layout">
<section
className="panel list-panel"
aria-labelledby="storm-signals-heading"
>
<header className="panel-heading">
<h2 id="storm-signals-heading">
Storm signals{" "}
<span className="ui-count">{stormSignals.length}</span>
</h2>
</header>
<div className="ui-columns">
<Section title="Storm signals" count={stormSignals.length}>
<SignalList
signals={stormSignals}
empty="No active signals across Minecraft, Storm Brain, or Storm Forum."
label="Storm signals"
newIds={new Set(snapshot?.newSignalIds)}
/>
</section>
<section
className="panel list-panel"
aria-labelledby="storm-changes-heading"
>
<header className="panel-heading">
<h2 id="storm-changes-heading">Recent changes</h2>
</header>
</Section>
<Section title="Recent changes">
<LoadingBlock
values={{ changes }}
fallback={<p role="status">Loading recent changes…</p>}
Expand All @@ -375,7 +365,7 @@ export function TheStormPageView({
</>
)}
</LoadingBlock>
</section>
</Section>
</div>
</>
);
Expand Down
Loading