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
1 change: 0 additions & 1 deletion bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/console-ui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ exports the raw tokens and `@shepherdjerred/console-ui/testing` the scan.
| `State` | The loading, empty or error line where content would be (`kind`, `children`, `action`); announced as `status` or `alert`. |
| `Dialog`, `DialogClose` | Base UI modal: `title`, `description`, body, `actions`, `size` (`sm`/`md`/`lg`), controlled `open` or a `trigger`. Native `<dialog class="ui-dialog">` with the `ui-dialog-*` parts looks the same. |
| `StatusGlyph` | 14px severity glyph plus its word; `label` may be rich content, `icon` swaps the glyph (running, queued), `hideLabel` keeps the word for screen readers only. |
| `Chip` | 22px bordered chip: a tag (`children`) or a `label`/`value` metric, optional `severity` and `href`. No margin; group chips in `.ui-chips`. |
| `Chip` | 22px bordered chip: a tag (`children`) or a `label`/`value` metric, optional `severity`, `href` and `external` (new tab plus the external icon). No margin; group chips in `.ui-chips`. |
| `Button` | Base UI button, 28px with a pressable edge; `variant` is `default`, `primary` or `danger`. For links use `ButtonLink`. |
| `ButtonLink` | A real `<a href>` with the `ui-btn` look and the same `variant`s; `render={<Link to="…" />}` for router links. No `role="button"`. |
| `IconButton` | Icon-only button; `label` is required and becomes its accessible name. |
Expand Down Expand Up @@ -254,7 +254,7 @@ state and 36px search look inside a `PageBody` so Go link renders unchanged.
| ------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `DescriptionList` | A `<dl>` of `{ label, value, mono?, wide?, severity? }` items. `layout="grid"` auto-fits ~220px columns; `"rail"` is one column for a side rail. |
| `Disclosure` | Native `<details>` with a twisting chevron, `count`, `defaultOpen`. |
| `CodeBlock` | Mono text in a focusable, labelled, scrolling region (`label` required); `lineNumbers`, `activeLine`, `wrap`. |
| `CodeBlock` | Mono text in a focusable, labelled, scrolling region (`label` required); `lineNumbers`, `firstLine` (an excerpt of a longer file), `activeLine`, `wrap`. |
| `CopyButton` | Copies `text`; icon-only or `variant="text"`; announces "Copied" or "Copy failed" in a polite live region and resets after 1.8s. |
| `Pager`, `ListToggle`, `useCapped` | Keyset "Newest / Older" links (`renderLink`), and the "Show all N / Show fewer" toggle with the hook that caps a list (`cappedCount`). |
| `BackLink` | The arrow link for `HeaderBar`'s `lead`. |
Expand Down
9 changes: 8 additions & 1 deletion packages/console-ui/src/components/chip.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { ReactNode } from "react";
import { ICONS } from "@shepherdjerred/console-ui/icons.ts";
import type { Severity } from "@shepherdjerred/console-ui/tokens.ts";

type ChipContent =
Expand All @@ -20,15 +21,19 @@ export type ChipProps = ChipContent & {
readonly severity?: Severity;
/** Makes the chip a link. */
readonly href?: string;
/** With `href`: opens in a new tab and draws the external-link icon. */
readonly external?: boolean;
readonly title?: string;
};

/**
* A 22px bordered chip: a tag (`children`) or a label/value pair. Chips
* carry no margin; put them in a `.ui-chips` row or any gap container.
*/
const External = ICONS.external;

export function Chip(props: ChipProps): React.JSX.Element {
const { severity, href, title } = props;
const { severity, href, title, external = false } = props;
const content =
props.children === undefined ? (
<>
Expand All @@ -55,8 +60,10 @@ export function Chip(props: ChipProps): React.JSX.Element {
data-sev={severity}
title={title}
href={href}
{...(external ? { target: "_blank", rel: "noreferrer" } : {})}
>
{content}
{external ? <External aria-hidden="true" /> : null}
</a>
);
}
8 changes: 8 additions & 0 deletions packages/console-ui/src/components/detail-forms.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,14 @@ describe("CodeBlock", () => {
expect(html).toContain('aria-current="location"');
});

test("starts its line numbers at firstLine for an excerpt", () => {
expect(
renderToStaticMarkup(
<CodeBlock code="a" label="x" lineNumbers firstLine={42} />,
),
).toContain("counter-reset:ui-line 41");
});

test("wraps on request", () => {
expect(
renderToStaticMarkup(<CodeBlock code="x" label="x" wrap />),
Expand Down
13 changes: 11 additions & 2 deletions packages/console-ui/src/components/detail/code-block.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ export type CodeBlockProps = {
/** Accessible name of the scrollable region, e.g. "Alert rule YAML". */
readonly label: string;
readonly lineNumbers?: boolean;
/** 1-based line to highlight, e.g. the failing line. */
/** The number of the first line, for an excerpt of a longer file (1). */
readonly firstLine?: number;
/** 1-based line of `code` to highlight, e.g. the failing line. */
readonly activeLine?: number;
/** Wrap long lines instead of scrolling sideways. */
readonly wrap?: boolean;
Expand All @@ -17,6 +19,7 @@ export function CodeBlock({
code,
label,
lineNumbers = false,
firstLine = 1,
activeLine,
wrap = false,
}: CodeBlockProps): React.JSX.Element {
Expand All @@ -30,7 +33,13 @@ export function CodeBlock({
data-wrap={wrap ? "" : undefined}
data-numbers={lineNumbers ? "" : undefined}
>
<pre>
<pre
style={
firstLine === 1
? undefined
: { counterReset: `ui-line ${String(firstLine - 1)}` }
}
>
<code>
{lines.map((line, index) => (
<span
Expand Down
14 changes: 14 additions & 0 deletions packages/console-ui/src/components/pieces.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,20 @@ describe("StatusGlyph and Chip", () => {
'<a class="ui-chip" data-kind="metric" href="/open">Open<b class="ui-chip-value">3</b></a>',
);
});

test("an external link chip opens a new tab and draws the external icon", () => {
const html = renderToStaticMarkup(
<Chip
label="Tracker"
value="AI-1"
href="https://t.example/AI-1"
external
/>,
);
expect(html).toContain('target="_blank"');
expect(html).toContain('rel="noreferrer"');
expect(html).toContain("lucide-external-link");
});
});

describe("Button", () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/errors/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
<meta
name="theme-color"
media="(prefers-color-scheme: light)"
content="#f7f8fa"
content="#ecede6"
/>
<meta
name="theme-color"
media="(prefers-color-scheme: dark)"
content="#0e1116"
content="#111210"
/>
<title>Errors</title>
<link
Expand Down
1 change: 0 additions & 1 deletion packages/errors/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
"test:ci": "bun ../../scripts/ci/run-ci-test.ts"
},
"dependencies": {
"@base-ui/react": "catalog:",
"@opentelemetry/api": "^1.9.1",
"@opentelemetry/context-async-hooks": "^2.12.0",
"@opentelemetry/exporter-trace-otlp-http": "^0.223.0",
Expand Down
87 changes: 26 additions & 61 deletions packages/errors/src/client/app.tsx
Original file line number Diff line number Diff line change
@@ -1,34 +1,25 @@
import {
HeaderBar,
ShellFrame,
type ThemeStore,
} from "@shepherdjerred/console-ui";
import { HeaderBar, State, type ThemeStore } from "@shepherdjerred/console-ui";
import { Loaded } from "@shepherdjerred/loaded";
import { useQuery } from "@tanstack/react-query";
import { useRef } from "react";
import { Link, Route, Routes } from "react-router";
import { fetchOverview, fetchProjects, queryKeys } from "./api.ts";
import { IssueDetailPage } from "./issue-detail-page.tsx";
import { IssuesPage } from "./issues-page.tsx";
import { OverviewPage } from "./overview-page.tsx";
import { CommandPalette } from "./palette.tsx";
import { ErrorsPalette } from "./palette.tsx";
import { ProjectsPage } from "./projects-page.tsx";
import { ReleasesPage } from "./releases-page.tsx";
import { ErrorsSidebar, Topbar } from "./shell-nav.tsx";
import { ErrorsShell } from "./shell.tsx";
import { themeStore as defaultThemeStore } from "./theme.ts";

function NotFoundPage(): React.JSX.Element {
return (
<main>
<main id="main">
<title>Not found · Errors</title>
<HeaderBar title="Page not found" />
<p className="er-state">
This page does not exist.{" "}
<Link className="er-subtle-link" to="/">
Return to Overview
</Link>
.
</p>
<State kind="empty">
This page does not exist. <Link to="/">Return to Overview</Link>.
</State>
</main>
);
}
Expand All @@ -38,8 +29,6 @@ export function App({
}: {
readonly store?: ThemeStore | undefined;
}): React.JSX.Element {
const contentRef = useRef<HTMLDivElement>(null);

const overviewQuery = useQuery({
queryKey: queryKeys.overview,
queryFn: ({ signal }) => fetchOverview(signal),
Expand All @@ -55,54 +44,30 @@ export function App({
Loaded.fromQuery(projectsQuery),
overview?.projects ?? [],
);
const totalUnresolved = overview?.totalUnresolved;
const totalRegressed = overview?.totalRegressed;

return (
<>
<a
className="skip-link"
href="#content"
onClick={(event) => {
event.preventDefault();
contentRef.current?.focus();
}}
>
Skip to content
</a>
<CommandPalette projects={projects} store={store} />
<Topbar
<ErrorsPalette projects={projects} store={store} />
<ErrorsShell
theme={store}
projects={projects}
totalUnresolved={totalUnresolved}
totalRegressed={totalRegressed}
store={store}
/>
<ShellFrame
sidebar={
<ErrorsSidebar
projects={projects}
totalUnresolved={totalUnresolved}
totalRegressed={totalRegressed}
store={store}
/>
}
totalUnresolved={overview?.totalUnresolved}
totalRegressed={overview?.totalRegressed}
>
<div className="er-content" id="content" ref={contentRef} tabIndex={-1}>
<Routes>
<Route path="/" element={<OverviewPage />} />
<Route path="/issues" element={<IssuesPage />} />
<Route path="/issues/:id" element={<IssueDetailPage />} />
<Route
path="/issues/:id/events/:eventId"
element={<IssueDetailPage />}
/>
<Route path="/projects" element={<ProjectsPage />} />
<Route path="/projects/:slug" element={<IssuesPage />} />
<Route path="/releases" element={<ReleasesPage />} />
<Route path="*" element={<NotFoundPage />} />
</Routes>
</div>
</ShellFrame>
<Routes>
<Route path="/" element={<OverviewPage />} />
<Route path="/issues" element={<IssuesPage />} />
<Route path="/issues/:id" element={<IssueDetailPage />} />
<Route
path="/issues/:id/events/:eventId"
element={<IssueDetailPage />}
/>
<Route path="/projects" element={<ProjectsPage />} />
<Route path="/projects/:slug" element={<IssuesPage />} />
<Route path="/releases" element={<ReleasesPage />} />
<Route path="*" element={<NotFoundPage />} />
</Routes>
</ErrorsShell>
</>
);
}
Loading