From e7ce06481703544deee1818997ba3e195bf3bf93 Mon Sep 17 00:00:00 2001 From: yuez Date: Wed, 28 Oct 2026 08:14:25 +0800 Subject: [PATCH] fix(web): let the view decide the blink, not the CSS colour class MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 `` 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. --- web/src/components/ui/status-dot.tsx | 33 ++- web/src/features/chat/head-chips.tsx | 3 +- web/src/features/chat/modals.tsx | 5 +- web/src/features/chat/session-state.ts | 35 +-- web/src/features/chat/session-tray.tsx | 24 ++- web/src/features/chat/session-tree.tsx | 4 +- web/src/features/chat/subagent-view.tsx | 6 +- web/src/features/chat/telemetry.tsx | 2 +- web/src/features/status/tasks-card.tsx | 5 +- web/src/pages/chat.tsx | 13 +- web/src/styles/app.css | 17 +- web/src/styles/pages/chat.css | 6 +- web/tests/chat.tree.test.tsx | 59 ++++- web/tests/components.test.tsx | 57 +++-- web/tests/session-dot.test.ts | 253 ++++++++++++++++------ web/tests/status-dot.blink-css.test.ts | 275 ++++++++++++++++++++++++ 16 files changed, 658 insertions(+), 139 deletions(-) create mode 100644 web/tests/status-dot.blink-css.test.ts diff --git a/web/src/components/ui/status-dot.tsx b/web/src/components/ui/status-dot.tsx index 05b766c..3b20a76 100644 --- a/web/src/components/ui/status-dot.tsx +++ b/web/src/components/ui/status-dot.tsx @@ -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 = { busy: "dot--busy", compacting: "dot--compacting", @@ -14,6 +25,11 @@ export const DOT_CLASS: Record = { dead: "dot--dead", }; +export const BLINK_CLASS: Record = { + 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 ( {t("chat.tabTasks")} - {running ?