fix(web): rebuild the session dot matrix from pi2.nvim
The Chat session list dot did not follow the plugin it mirrors (:PiSessions in pi2.nvim, lua/pi/ui/sessions.lua). Four things were wrong: - priority: attention outranked error and exited; the plugin order is exited > error > attention > done > busy > compacting > idle. - interrupted wore the attention amber, the same colour as "waiting for you"; it is a dead process, so it takes the solid exited red (dot--dead). - exited and dormant were collapsed into the hollow grey ring; a dead parent is the solid red one, the hollow ring is the dormant sub-session. - sub-sessions reused the parent matrix. They now follow child_dot_hl: a failed child is steady red while you are looking at it and blinking red while you are not, busy/compacting blink at the busy rate, and a child never shows green (the plugin forces done=false there). The current-tab marker (PiSessionsListCurrent) was missing entirely: the row the console has open now carries dot--current, steady on idle and blinking on busy, and never on top of a notification colour - same guard as refresh_current_markers. It is the browser analogue of the focused nvim tab, so no wire change is needed. Also drops the unreachable sessionDotClass() dead code, whose second mapping was the reason the divergence went unnoticed, and consolidates the three subagent dot tables into subagentDot(). Unread notifications now expire like the plugin's: done/error are unread markers, not states (on_agent_end only raises done for a tab that is not current, clear_flags wipes both on TabEnter). The store gained markSeen(), called when the routed session carries done/error, so a session you open stops being green or red. The canonical reducer and fixtures/ are untouched: this is a client-side view concern.
This commit is contained in:
1 parent
81e7f96a64
commit
bf01fd549d
5 files changed
+153
-66
No files matched your search
@@ -1,7 +1,7 @@
|
||||
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";
|
||||
export type DotStatus = "busy" | "compacting" | "idle" | "ok" | "err" | "attention" | "exited" | "dead";
|
||||
|
||||
export const DOT_CLASS: Record<DotStatus, string> = {
|
||||
busy: "dot--busy",
|
||||
@@ -11,6 +11,7 @@ export const DOT_CLASS: Record<DotStatus, string> = {
|
||||
err: "dot--err",
|
||||
attention: "dot--attention",
|
||||
exited: "dot--exited",
|
||||
dead: "dot--dead",
|
||||
};
|
||||
|
||||
export type ServerStatus = "online" | "degraded" | "offline";
|
||||
@@ -24,62 +25,22 @@ export function serverDotClass(status: ServerStatus | string | null | undefined)
|
||||
return DOT_CLASS.idle;
|
||||
}
|
||||
|
||||
export type SubagentStatus = "active" | "completed" | "failed" | "interrupted" | "dormant";
|
||||
|
||||
export function subagentDotClass(status: SubagentStatus | string): string {
|
||||
switch (status) {
|
||||
case "active":
|
||||
return DOT_CLASS.busy;
|
||||
case "completed":
|
||||
return DOT_CLASS.ok;
|
||||
case "failed":
|
||||
return DOT_CLASS.err;
|
||||
case "interrupted":
|
||||
return DOT_CLASS.attention;
|
||||
case "dormant":
|
||||
return DOT_CLASS.exited;
|
||||
default:
|
||||
return DOT_CLASS.idle;
|
||||
}
|
||||
}
|
||||
|
||||
export type SessionStatus = "starting" | "busy" | "compacting" | "idle" | "exited" | "interrupted" | "attention" | "done" | "error";
|
||||
|
||||
export function sessionDotClass(status: SessionStatus | string): string {
|
||||
switch (status) {
|
||||
case "busy":
|
||||
case "starting":
|
||||
return DOT_CLASS.busy;
|
||||
case "compacting":
|
||||
return DOT_CLASS.compacting;
|
||||
case "interrupted":
|
||||
case "attention":
|
||||
return DOT_CLASS.attention;
|
||||
case "done":
|
||||
return DOT_CLASS.ok;
|
||||
case "error":
|
||||
return DOT_CLASS.err;
|
||||
case "exited":
|
||||
return DOT_CLASS.exited;
|
||||
case "idle":
|
||||
return DOT_CLASS.idle;
|
||||
default:
|
||||
return DOT_CLASS.idle;
|
||||
}
|
||||
}
|
||||
|
||||
export interface StatusDotProps {
|
||||
status: DotStatus;
|
||||
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, ...rest }: StatusDotProps) {
|
||||
export function StatusDot({ status, title, className, steady, current, ...rest }: StatusDotProps) {
|
||||
return (
|
||||
<span
|
||||
className={cn("dot", DOT_CLASS[status], className)}
|
||||
className={cn("dot", DOT_CLASS[status], steady && "dot--steady", current && "dot--current", className)}
|
||||
title={title}
|
||||
aria-label={title}
|
||||
aria-hidden={title ? undefined : true}
|
||||
|
||||
Reference in new issue
Block a user