Skip to content
Merged
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
2 changes: 1 addition & 1 deletion ui/src/components/runDetail.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe("cellShade", () => {
expect(cellShade(0, false).background).toContain("--bad) 0%");
});
it("uses white text only on a strong diagonal", () => {
expect(cellShade(0.8, true).color).toBe("var(--mantine-color-white)");
expect(cellShade(0.8, true).color).toBe("var(--inverse-ink)");
expect(cellShade(0.8, false).color).toBe("var(--text-primary)");
expect(cellShade(0.3, true).color).toBe("var(--text-primary)");
});
Expand Down
23 changes: 21 additions & 2 deletions ui/src/kit/ErrorAlert.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,29 @@
/** The one way to show a failed request: the message plus the API's per-field details. */
import type { ReactNode } from "react";
import { Alert, List } from "@mantine/core";
import { Alert, Box, List } from "@mantine/core";
import { describeError } from "../toast";

export function ErrorAlert({ error, title, children }: { error: unknown; title?: string; children?: ReactNode }) {
export function ErrorAlert({
error,
title,
children,
page,
}: {
error: unknown;
title?: string;
children?: ReactNode;
/** The whole page failed: the alert sits inside the page's padding instead of edge to edge under the bar. */
page?: boolean;
}) {
if (!error) return null;
if (page)
return (
<Box px="xl" pt="xl" pb={48} maw={1280} mx="auto" w="100%">
<ErrorAlert error={error} title={title}>
{children}
</ErrorAlert>
</Box>
);
const e = error as { message?: string; details?: string[] };
return (
<Alert color="bad" variant="light" title={title} role="alert">
Expand Down
10 changes: 9 additions & 1 deletion ui/src/kit/JobStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,15 @@ export function JobStatus({
const pct = progress == null ? null : Math.round(Math.max(0, Math.min(1, progress)) * 100);
return (
<Group gap="xs" wrap="nowrap" align="center">
<Badge color={look.color} variant={look.variant} size="sm" radius="sm" tt="none" fw={500}>
<Badge
color={look.color}
variant={look.variant}
size="sm"
radius="sm"
tt="none"
fw={500}
style={{ flexShrink: 0, minWidth: "max-content" }}
>
{look.label}
</Badge>
{live && (
Expand Down
37 changes: 20 additions & 17 deletions ui/src/pages/batch/BatchPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
oneVsRestValues,
} from "../../batches";
import { BatchDialog } from "../experiment/BatchDialog";
import { Page } from "../experiment/Page";
import { useDatasetContext } from "../../components/DatasetLayout";
import { ErrorAlert } from "../../kit";
import { batchDeployment } from "../../deployments";
Expand Down Expand Up @@ -177,25 +178,27 @@ function BatchView() {
if (batch.error && !b) {
const missing = (batch.error as { status?: number }).status === 404;
return (
<Paper withBorder radius="md" p="md">
{missing ? (
<EmptyState
title={`Batch #${bid} doesn't exist, or isn't shared with you`}
action={
<Button component={Link} to={back} variant="default">
<Page>
<Paper withBorder radius="md" p="md" maw={560} mx="auto" w="100%">
{missing ? (
<EmptyState
title={`Batch #${bid} doesn't exist, or isn't shared with you`}
action={
<Button component={Link} to={back} variant="default">
Back to the runs
</Button>
}
/>
) : (
<Stack>
<ErrorAlert error={batch.error} title="Couldn't load the batch" />
<Button component={Link} to={back} variant="default" style={{ alignSelf: "flex-start" }}>
Back to the runs
</Button>
}
/>
) : (
<Stack>
<ErrorAlert error={batch.error} title="Couldn't load the batch" />
<Button component={Link} to={back} variant="default" style={{ alignSelf: "flex-start" }}>
Back to the runs
</Button>
</Stack>
)}
</Paper>
</Stack>
)}
</Paper>
</Page>
);
}
if (!b || !registration) return <Loader size="sm" m="lg" aria-busy="true" />;
Expand Down
5 changes: 4 additions & 1 deletion ui/src/pages/batch/common.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ const LOOK: Record<string, { label: string; color: string; variant: "light" | "o
cancelled: { label: "Cancelled", color: "gray", variant: "outline" },
};

/** A status word is never cut to "Runni…": the badge keeps its width and the table scrolls instead. */
const NO_SQUEEZE = { flexShrink: 0, minWidth: "max-content" } as const;

/** A run's status, written out once: queued, running, done, failed, cancelled. */
export function RunStatus({ status, children }: { status: string; children?: ReactNode }) {
const look = LOOK[status] ?? {
Expand All @@ -23,7 +26,7 @@ export function RunStatus({ status, children }: { status: string; children?: Rea
variant: "light" as const,
};
return (
<Badge color={look.color} variant={look.variant} size="sm" radius="sm" tt="none" fw={500}>
<Badge color={look.color} variant={look.variant} size="sm" radius="sm" tt="none" fw={500} style={NO_SQUEEZE}>
{children ?? look.label}
</Badge>
);
Expand Down
17 changes: 13 additions & 4 deletions ui/src/pages/connections/ConnectionPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -354,18 +354,27 @@ export function ConnectionPage() {
enabled: cid !== null,
});
const c = q.data ?? null;
const readOnlyBar = useMemo(() => ({ title: c?.name ?? "Connection", subtitle: c ? "Connection" : undefined }), [c]);
usePageBar(readOnlyBar, c !== null && !c.can.manage);
const kind = params.get("kind") as ConnectionKind | null;
// The editor sets its own bar; every other state (read-only, no kind chosen, not an owner) shows this one.
const noEditor =
cid === null ? !kind || !KINDS.includes(kind) || (!instanceMode && (all || role !== "owner")) : false;
const readOnlyBar = useMemo(
() => ({
title: c?.name ?? (cid === null ? "New connection" : "Connection"),
subtitle: c ? "Connection" : undefined,
}),
[c, cid],
);
usePageBar(readOnlyBar, (c !== null && !c.can.manage) || noEditor);
if (cid === null) {
const kind = params.get("kind") as ConnectionKind | null;
if (!kind || !KINDS.includes(kind))
return <EmptyState title="Choose a kind">Start from Connections, New connection.</EmptyState>;
if (instanceMode) return <Editor key={kind} existing={null} kind={kind} instanceMode />;
if (all || role !== "owner")
return <EmptyState title="Only an owner can add a connection">Open a project you own.</EmptyState>;
return <Editor key={kind} existing={null} kind={kind} instanceMode={false} />;
}
if (q.error) return <ErrorAlert error={q.error} title="Couldn't load the connection" />;
if (q.error) return <ErrorAlert page error={q.error} title="Couldn't load the connection" />;
if (!c) return <EmptyState title="Loading…">{""}</EmptyState>;
if (c.can.manage)
return <Editor key={`${c.id}-${c.updated_at}`} existing={c} kind={c.kind} instanceMode={c.instance} />;
Expand Down
2 changes: 1 addition & 1 deletion ui/src/pages/connections/ConnectionsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export function ConnectionsPage() {
cell: (c) => fmtInt(c.datasets),
},
];
if (list.error) return <ErrorAlert error={list.error} title="Couldn't load the connections" />;
if (list.error) return <ErrorAlert page error={list.error} title="Couldn't load the connections" />;
const rows = list.data ?? [];
return (
<Box px="xl" pt="xl" pb={48}>
Expand Down
2 changes: 1 addition & 1 deletion ui/src/pages/data/CompositionPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export function CompositionPage({ id: given }: { id?: number } = {}) {
[c?.name, c?.version, c?.status, c?.dataset_id, c?.created_at, owner],
);
usePageBar(bar);
if (q.error) return <ErrorAlert error={q.error} />;
if (q.error) return <ErrorAlert page error={q.error} />;
if (!c) return null;
const used = c.used_by;
return (
Expand Down
2 changes: 1 addition & 1 deletion ui/src/pages/data/DataPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ export function DataPage() {
secondary: editor ? [{ label: "Compose…", to: projectPath(target.project ?? slug, "/data/compose") }] : [],
children:
editor || target.choosing ? (
<Group gap="xs">
<Group gap="xs" wrap="nowrap">
<CreateTargetSelect target={target} compact />
{editor && (
<>
Expand Down
2 changes: 1 addition & 1 deletion ui/src/pages/endpoints/EndpointPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ export function EndpointPage() {
[e, member, change, at],
);
usePageBar(spec);
if (q.error) return <ErrorAlert error={q.error} title="Couldn't load the endpoint" />;
if (q.error) return <ErrorAlert page error={q.error} title="Couldn't load the endpoint" />;
if (!e) return null;
const origin = typeof window === "undefined" ? "" : window.location.origin;
const look = ENDPOINT_LOOK[e.status];
Expand Down
2 changes: 1 addition & 1 deletion ui/src/pages/evaluations/EvaluationPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export function EvaluationPage() {
[e, version.data, at],
);
usePageBar(spec);
if (q.error) return <ErrorAlert error={q.error} title="Couldn't load the evaluation" />;
if (q.error) return <ErrorAlert page error={q.error} title="Couldn't load the evaluation" />;
if (!e) return null;
const binary = (e.columns?.labels?.length ?? 0) > 0 && version.data?.models.some((m) => m.kind === "binary") === true;
const target = e.columns?.label_field ?? (version.data ? targetOf(version.data) : "the target");
Expand Down
2 changes: 1 addition & 1 deletion ui/src/pages/experiment/RunsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ export function RunsTable({
)}
<Table.Td>
{(r.report?.hardware?.device_used ?? r.report?.device ?? r.config?.device)?.startsWith("cuda") ? (
<Badge size="sm" variant="light" color="accent" tt="none" fw={500} radius="sm">
<Badge size="sm" variant="light" color="accent" tt="none" fw={500} radius="sm" miw="max-content">
GPU
</Badge>
) : (
Expand Down
2 changes: 1 addition & 1 deletion ui/src/pages/models/ModelPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ export function ModelPage() {
[m, member, owner, removeModel, at],
);
usePageBar(spec);
if (q.error) return <ErrorAlert error={q.error} title="Couldn't load the model" />;
if (q.error) return <ErrorAlert page error={q.error} title="Couldn't load the model" />;
if (!m) return null;
const versions = m.versions;
return (
Expand Down
2 changes: 1 addition & 1 deletion ui/src/pages/models/ModelsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export function ModelsPage() {
width: 140,
},
];
if (list.error) return <ErrorAlert error={list.error} title="Couldn't load the registry" />;
if (list.error) return <ErrorAlert page error={list.error} title="Couldn't load the registry" />;
return (
<Box px="xl" pt="xl" pb={48}>
<DataTable
Expand Down
2 changes: 1 addition & 1 deletion ui/src/pages/models/VersionPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ export function VersionPage() {
[v, member, modelId, rebuildVersion, removeVersion, at],
);
usePageBar(spec);
if (model.error) return <ErrorAlert error={model.error} title="Couldn't load the version" />;
if (model.error) return <ErrorAlert page error={model.error} title="Couldn't load the version" />;
if (!model.data) return null;
if (!v) return <ErrorAlert error={new Error(`${model.data.name} has no v${n}.`)} />;
const o = v.origin;
Expand Down
7 changes: 5 additions & 2 deletions ui/src/pages/runs/detail/ConfusionTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ import type { TargetEvaluation } from "../../../types";
* the error colour, so mistakes stand out from near-empty cells. */
export function cellShade(share: number, diag: boolean): { background: string; color: string } {
const pct = Math.round(Math.min(1, Math.max(0, share)) * 100);
const mix = diag ? pct : Math.round(pct * 0.8);
return {
background: `color-mix(in srgb, var(${diag ? "--series-1" : "--bad"}) ${diag ? pct : Math.round(pct * 0.8)}%, var(--surface-1))`,
color: diag && share > 0.55 ? "var(--mantine-color-white)" : "var(--text-primary)",
background: `color-mix(in srgb, var(${diag ? "--series-1" : "--bad"}) ${mix}%, var(--surface-1))`,
// Past about three quarters the cell is the full colour: dark in Day, bright in Night, so the ink flips with the
// scheme (white in Day, black in Night); below it the ordinary text reads in both.
color: mix > 75 ? "var(--inverse-ink)" : "var(--text-primary)",
};
}

Expand Down
10 changes: 10 additions & 0 deletions ui/src/theme/mantine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,16 @@ function scheme(side: "light" | "dark"): Record<string, string> {
"--mantine-color-warn-light-color": c.warn[side],
"--mantine-color-bad-light": c["bad-weak"][side],
"--mantine-color-bad-light-color": c.bad[side],
// Neutral chips (gray light) sit on the hover ground, so they read on white cards, the page and the sidebar in
// both schemes; Mantine's own dark value (gray 9 darkened) was the card colour itself. Outlines take the 3:1
// control border, and coloured outlines the token, not a near-white tint of the dark ramp.
"--mantine-color-gray-light": c["surface-hover"][side],
"--mantine-color-gray-light-hover": c.border[side],
"--mantine-color-gray-outline": c["border-strong"][side],
"--mantine-color-accent-outline": c.accent[side],
"--mantine-color-good-outline": c.good[side],
"--mantine-color-warn-outline": c.warn[side],
"--mantine-color-bad-outline": c.bad[side],
// A filled danger button needs white on it: the strong (Day) orange in both schemes.
"--mantine-color-bad-filled": c.bad.light,
"--mantine-color-bad-filled-hover": "#8a2f12",
Expand Down
Loading