Files
PaperClipAI/ui/src/components/StatusGlyph.test.tsx
T
bac15ebd09 feat: task status icons & colors (#8580)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work, and task status is one of the most-scanned signals across its
whole UI.
> - The Tasks UI shows status through small coloured ring icons and
chips spread across the list, kanban, task detail, the properties
flyout, inline `@`-mentions and the breadcrumb.
> - Those ring glyphs lean heavily on colour to distinguish states,
which is hard to read for colour-blind users, and the status hues were
hard-coded in component classes rather than a single source.
> - We want color-blind-safe, distinct *shapes* per status plus a single
`--status-*` colour-token system the chips and icons share.
> - This pull request adds a unified `StatusGlyph` (one shape per
status) and the `--status-*` colour-token system, and adopts them across
every task-status surface so the new glyphs + colours render by default.
> - The benefit is a more accessible, consistent status language with
one source of truth for status hues.

## Linked Issues or Issue Description

This is a **feature** (no public issue filed). Following the feature
issue template:

- **Problem / motivation:** Task status is communicated mostly by colour
(ring fills/borders), which is hard to distinguish for colour-blind
users, and the status hues are duplicated across component classes with
no single source of truth. Several community PRs have nibbled at parts
of this (see related PRs below).
- **Proposed solution:** A single `StatusGlyph` component with a
distinct *shape* per status (not just colour), backed by a `--status-*`
CSS-variable colour system (base hues + AA-tuned icon hues +
`.status-chip` / `.status-fill` color-mix helpers), adopted across all
task-status surfaces.
- **Alternatives considered:** Recolouring the existing rings in place
(rejected — still colour-only, no shape differentiation).
- **Roadmap alignment:** Additive UI only; no overlap with planned core
work.

Related community PRs (partial / different approaches to the same area —
not duplicates):

- Refs #3806 — Show issue ref and status icon in breadcrumbs and
properties
- Refs #1760 — Improve design of cancelled task status icon
- Refs #1856 — a11y title/aria-label on status and priority icons

## What Changed

- **Colour token system:** `--status-agent-*` / `--status-task-*` base
hues, AA-tuned `--status-task-icon-*` hues (light + dark), and
`.status-chip` / `.status-fill` color-mix helpers in `index.css`;
matching status→CSS-var maps in `status-colors.ts`.
- **`StatusGlyph`** — one `viewBox="0 0 24 24"` glyph per status with
distinct, color-blind-safe shapes (dashed ring, open ring, half-fill,
ring+dot, disc+check, ring+bar, ring+slash, and `in_queue` = the blocked
shape recoloured blue). Sizes `sm`/`md`/`lg`.
- **Adoption (renders by default)** across `StatusIcon`, `StatusBadge`
(agent + issue chips), `MarkdownBody` inline mentions, `IssueRow`,
`IssuesList`, `IssueProperties`, `BreadcrumbBar` + `BreadcrumbContext`,
and the task-detail header/breadcrumb.
- **Tests** for `StatusGlyph`, `StatusIcon`, `StatusBadge`, `IssueRow`,
`IssuesList`, `MarkdownBody` lock the rendered behaviour.

Scope notes: no experimental flag and no Theme Editor surfaces. The
generic `StatusBadge` (runs/goals/approvals) is unchanged.
Project-status recolour is deferred (no in-scope consumer).

## Verification

- `pnpm --filter @paperclipai/shared build` — green (tsc).
- `pnpm --filter @paperclipai/ui build` — green (tsc + vite).
- Targeted unit tests green: `StatusGlyph`, `StatusIcon`, `StatusBadge`,
`IssueRow`, `IssuesList`, `MarkdownBody`, plus consumer suites that
render these (`IssueProperties`, `IssueDetail`, `Search`,
`IssueChatThread`, `IssueFiltersPopover`, `InterruptHandoffViews`) — all
passing.
- Remaining: interactive light + dark visual confirmation across list /
kanban / detail / properties / inline mentions / breadcrumb. The glyph
shapes + AA-tuned hues were previously QA'd on the originating feature
branch.

## Risks

Low risk. Additive UI: a new component + CSS tokens, adopted at existing
status call sites. The generic `StatusBadge` and all non-status UI are
untouched; no schema/migration changes. Behaviour is exercised by unit +
consumer test suites.

## Model Used

Claude Opus 4.8 (`claude-opus-4-8`), extended thinking, with tool use /
code execution (file edits, local builds + vitest).

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change and contains no internal
Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [ ] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [x] All Paperclip CI gates are green
- [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: Paperclip <noreply@paperclip.ing>
2026-06-24 16:42:27 -05:00

104 lines
4.4 KiB
TypeScript

// @vitest-environment node
import { renderToStaticMarkup } from "react-dom/server";
import { describe, expect, it } from "vitest";
import { StatusGlyph } from "./StatusGlyph";
import { taskStatusIconVar } from "../lib/status-colors";
/**
* PAP-238 3b: the unified status glyph renders every status from ONE
* `viewBox="0 0 24 24"` SVG at a `sm 14 / md 16 / lg 20` scale, coloured from
* the AA-tuned `--status-task-icon-*` vars. These tests lock the geometry (the
* rev-4 spec hexes/paths), the size scale, the colour wiring and `in_queue`.
*/
describe("StatusGlyph", () => {
it("renders one 24-unit viewBox for every status (proportional scaling)", () => {
for (const status of Object.keys(taskStatusIconVar)) {
const html = renderToStaticMarkup(<StatusGlyph status={status} />);
expect(html).toContain('viewBox="0 0 24 24"');
expect(html).toContain("<svg");
}
});
it("maps sm/md/lg to 14/16/20 px", () => {
expect(renderToStaticMarkup(<StatusGlyph status="todo" size="sm" />)).toContain('width="14"');
expect(renderToStaticMarkup(<StatusGlyph status="todo" size="md" />)).toContain('width="16"');
expect(renderToStaticMarkup(<StatusGlyph status="todo" size="lg" />)).toContain('width="20"');
// Default size is md.
expect(renderToStaticMarkup(<StatusGlyph status="todo" />)).toContain('width="16"');
});
it("colours each status from its --status-task-icon-* var", () => {
for (const [status, cssVar] of Object.entries(taskStatusIconVar)) {
const html = renderToStaticMarkup(<StatusGlyph status={status} />);
expect(html).toContain(`var(${cssVar})`);
}
});
it("falls back to the backlog icon var for unknown statuses", () => {
const html = renderToStaticMarkup(<StatusGlyph status="mystery" />);
expect(html).toContain("var(--status-task-icon-backlog)");
});
it("gives backlog a uniform dashed ring (pathLength=100)", () => {
const html = renderToStaticMarkup(<StatusGlyph status="backlog" />);
expect(html).toContain('pathLength="100"');
expect(html).toContain('stroke-dasharray="6.25 6.25"');
});
it("gives todo a bare open ring (no inner shape)", () => {
const html = renderToStaticMarkup(<StatusGlyph status="todo" />);
expect(html).toContain('r="8.5"');
expect(html).not.toContain("<path");
expect(html).not.toContain("<rect");
});
it("gives in_progress a half-filled ring (liveness)", () => {
const html = renderToStaticMarkup(<StatusGlyph status="in_progress" />);
expect(html).toContain("M12 3.5 A8.5 8.5 0 0 1 12 20.5 Z");
});
it("gives in_review a ring + centre dot", () => {
const html = renderToStaticMarkup(<StatusGlyph status="in_review" />);
expect(html).toContain('r="3.6"');
});
it("gives done a filled disc with a knocked-out check in the surface colour", () => {
const html = renderToStaticMarkup(<StatusGlyph status="done" />);
expect(html).toContain('r="9.5"');
expect(html).toContain("M7.5 12.2 10.6 15.2 16.5 8.8");
expect(html).toContain("stroke-background");
});
it("gives blocked a ring + bar", () => {
const html = renderToStaticMarkup(<StatusGlyph status="blocked" />);
expect(html).toContain("<rect");
expect(html).toContain('width="10"');
});
it("gives cancelled a ring + slash", () => {
const html = renderToStaticMarkup(<StatusGlyph status="cancelled" />);
expect(html).toContain("M6.5 17.5 17.5 6.5");
});
it("renders in_queue as the blocked shape recoloured blue (in_progress var)", () => {
const queue = renderToStaticMarkup(<StatusGlyph status="in_queue" />);
const blocked = renderToStaticMarkup(<StatusGlyph status="blocked" />);
// Same geometry as blocked (ring + bar)…
expect(queue).toContain("<rect");
expect(queue).toContain('width="10"');
// …but coloured from the in_progress (blue) icon var, not blocked's red.
expect(queue).toContain("var(--status-task-icon-in_queue)");
expect(queue).not.toContain("var(--status-task-icon-blocked)");
expect(blocked).toContain("var(--status-task-icon-blocked)");
});
it("is decorative by default and labelled when given a title", () => {
expect(renderToStaticMarkup(<StatusGlyph status="todo" />)).toContain('aria-hidden="true"');
const labelled = renderToStaticMarkup(<StatusGlyph status="todo" title="Todo" />);
expect(labelled).toContain('role="img"');
expect(labelled).toContain('aria-label="Todo"');
expect(labelled).toContain("<title>Todo</title>");
});
});