fix(web): let the view decide the blink, not the CSS colour class

A dot's animation was keyed on its colour class plus a component wrapper:
`html[data-pi-blink-fast="dim"] .tree-row .dot--ok` made green blink only inside
the session tree, `.dot--busy`/`.dot--err` blazed everywhere they appeared, and
`dot--steady` existed only to subtract what that selector had just added. Two
consequences the matrix in docs/session-dot.md already forbids: a failed task's
red blinked forever with no gesture to acknowledge it, and the same session
could blink in the list and sit solid in the stream head.

`DotView` now carries the rate (`blink: "fast" | "slow"`, omitted = solid) next
to the colour, and `<StatusDot>` renders it as `dot--blink-fast` /
`dot--blink-slow`. `dot--steady` is gone — to make a dot solid you omit `blink`.
app.css keeps exactly two dim rules, with no colour or component scoping and no
knowledge of *whether* anything blinks, only of when the shared clock dims it.

Filling in the matrix this exposed: parent `err`/`ok`/`busy` blink fast and
`compacting` slow; a viewed child or subagent failure is solid while an unviewed
one blinks; `interrupted` is the same solid dead red as `exited` (the plugin has
no interrupted, and in the plugin `exited` outranks its own unread flags —
`sessionDot(active)` is now rendered `viewed: true` for the stream head, so one
session can never show two different rates); task dots follow `:PiTasks`
(`taskDotView`, shared by the tray and the output modal) where only `running`
blinks, `completed` is solid green and `stopped` is amber attention. The
`/status` task card renders the same colours, solid, since nothing there
acknowledges anything.
This commit is contained in:
yuez committed 2026-10-28 08:14:25 +08:00
1 parent 604fec5ea0
commit e7ce064817
16 files changed
+658 -139

No files matched your search

+29 -4
View File
@@ -3,6 +3,17 @@ import { cn } from "@/lib/utils";
/** Status-dot vocabulary from the design's `:PiSessions` state matrix. */
export type DotStatus = "busy" | "compacting" | "idle" | "ok" | "err" | "attention" | "exited" | "dead";
/**
* Blink rate, in shared-clock phases (`web/src/lib/blink.ts`): `fast` follows
* `data-pi-blink-fast` (500ms), `slow` follows `data-pi-blink-slow` (1000ms).
*/
export type BlinkRate = "fast" | "slow";
/**
* Colour only. Whether a dot blinks is NOT encoded here: `dot--busy` is amber
* whether it pulses (a running turn) or not (a startup `connecting` chip), so a
* class-keyed dim rule cannot express the matrix. `blink` carries it instead.
*/
export const DOT_CLASS: Record<DotStatus, string> = {
busy: "dot--busy",
compacting: "dot--compacting",
@@ -14,6 +25,11 @@ export const DOT_CLASS: Record<DotStatus, string> = {
dead: "dot--dead",
};
export const BLINK_CLASS: Record<BlinkRate, string> = {
fast: "dot--blink-fast",
slow: "dot--blink-slow",
};
export type ServerStatus = "online" | "degraded" | "offline";
/** Server / connection status mapping (online → ok, degraded → attention, else exited). */
@@ -27,20 +43,29 @@ export function serverDotClass(status: ServerStatus | string | null | undefined)
export interface StatusDotProps {
status: DotStatus;
/**
* Blink rate decided by the *view* that owns the dot (`DotView.blink`), never
* by the DOM location or the colour class. Omitted/`null` = solid.
*/
blink?: BlinkRate | null;
title?: string;
className?: string;
/** Pin the dot solid (no blink) — nvim's "focused child error is steady red". */
steady?: boolean;
/** "You are here" overlay (nvim `PiSessionsListCurrent`, agent blue). */
current?: boolean;
/** Decorative by default; pass a title to expose the state to assistive tech. */
"aria-hidden"?: boolean;
}
export function StatusDot({ status, title, className, steady, current, ...rest }: StatusDotProps) {
export function StatusDot({ status, blink, title, className, current, ...rest }: StatusDotProps) {
return (
<span
className={cn("dot", DOT_CLASS[status], steady && "dot--steady", current && "dot--current", className)}
className={cn(
"dot",
DOT_CLASS[status],
blink ? BLINK_CLASS[blink] : null,
current && "dot--current",
className,
)}
title={title}
aria-label={title}
aria-hidden={title ? undefined : true}