fix(web): a dead process outranks its own unread flags

Review caught two holes in the previous commit.

interrupted was ranked below error/attention/done, so an interrupted session
with a stale error flag still blinked red, one with pending attention still
wore the amber dot, and one with a done flag still turned green. In the
plugin there is no interrupted at all: any non-running row is exited
(sessions.lua:75-78) and exited sits at the top of dot_hl. interrupted now
shares that slot.

The subagent tables were not actually consolidated: subagent-view.tsx and
telemetry.tsx each kept their own SUB_DOT, still painting interrupted amber
and completed green. All three now go through subagentDot(); in a subagent
view the row is the one you have open, so a failed child is steady red there.
This commit is contained in:
yuez committed 2026-10-27 19:13:35 +08:00
1 parent b6335a21a4
commit 668f77bf51
4 files changed
+31 -21

No files matched your search

+4 -2
View File
@@ -541,13 +541,15 @@ function withCurrent(view: DotView, state: SessionState, viewed: boolean): DotVi
* attention amber (`sessionStatusKey` still labels it "interrupted").
*/
function parentDot(state: SessionState): DotView {
if (state.status === "exited") return { status: "dead" };
// `interrupted` sits with `exited`: both mean the process is gone, and in the
// plugin every "not running" row is `exited` (sessions.lua:75-78), which is
// why a dead row outranks its own unread error/attention/done flags.
if (state.status === "exited" || state.status === "interrupted") return { status: "dead" };
if (state.flags.error) return { status: "err" };
if (attentionPending(state)) return { status: "attention" };
if (state.flags.done) return { status: "ok" };
if (state.status === "busy") return { status: "busy" };
if (state.status === "compacting") return { status: "compacting" };
if (state.status === "interrupted") return { status: "dead" };
return { status: "idle" };
}
+11 -10
View File
@@ -4,7 +4,7 @@ import { useTranslation } from "react-i18next";
import { Icon } from "@/components/icons";
import { Empty } from "@/components/ui/empty";
import { StatusDot, type DotStatus } from "@/components/ui/status-dot";
import { StatusDot } from "@/components/ui/status-dot";
import { toast } from "@/components/ui/toast";
import { cn } from "@/lib/utils";
@@ -12,6 +12,7 @@ import { EntryBlock } from "./blocks";
import { Composer } from "./composer";
import type { ModelGroup } from "./data";
import { HeadChips } from "./head-chips";
import { subagentDot } from "./session-state";
import { subagentTitle } from "./session-title";
import type { TrayTab } from "./store";
@@ -19,14 +20,6 @@ import "@/styles/pages/chat-telemetry.css";
type ToolBlock = Extract<Block, { type: "tool" }>;
const SUB_DOT: Record<Subagent["status"], DotStatus> = {
active: "busy",
completed: "ok",
failed: "err",
interrupted: "attention",
dormant: "exited",
};
function str(value: unknown): string | undefined {
return typeof value === "string" && value.trim() ? value.trim() : undefined;
}
@@ -250,6 +243,10 @@ export function SubagentView({
.catch(() => undefined);
}
// The child view is the session you are looking at, so its unread markers are
// already consumed (`viewed: true`) — a failed child is steady red here.
const dot = subagentDot(subagent, { viewed: true });
return (
<div
className={cn("subagent-view", "subagent-view--child", className)}
@@ -282,7 +279,11 @@ export function SubagentView({
<span className="sub-back__label">{t("chat.subview.back")}</span>
</button>
<div className="stream-title">
<StatusDot status={SUB_DOT[subagent.status]} title={t(`state.${subagent.status}`)} />
<StatusDot
status={dot.status}
steady={dot.steady}
title={t(`state.${subagent.status}`)}
/>
<h2 className="stream-name truncate" tabIndex={-1} title={task ? `${name} · ${task}` : name}>
{name}
</h2>
+6 -9
View File
@@ -2,10 +2,12 @@ import type { ContextUsage, Entry, SessionState, Subagent, UsageTotals } from "@
import { useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import { StatusDot } from "@/components/ui/status-dot";
import { plural } from "@/lib/i18n";
import { cn } from "@/lib/utils";
import { formatDuration } from "./format";
import { subagentDot } from "./session-state";
import { synthesizeSubagentTimeline } from "./subagent-view";
import "@/styles/pages/chat-telemetry.css";
@@ -24,14 +26,6 @@ const SUB_TONE: Record<Subagent["status"], string> = {
dormant: "is-idle",
};
const SUB_DOT: Record<Subagent["status"], string> = {
active: "dot--busy",
completed: "dot--ok",
failed: "dot--err",
interrupted: "dot--attention",
dormant: "dot--exited",
};
export interface TelemetryCounts {
/** `role === "user"` entries in the view's timeline. */
turns: number;
@@ -175,6 +169,9 @@ export function Telemetry({ session, subagent, entries, className }: TelemetryPr
if (subagent) {
const timeline = synthesizeSubagentTimeline(subagent, entries);
// The subagent view is the session you have open: its unread markers are
// already consumed, so a failed child is steady red here.
const dot = subagentDot(subagent, { viewed: true });
const { turns, tools } = countTelemetry(timeline);
const created = subagent.createdAt;
const end = ticking ? now : (subagent.lastActiveAt ?? created);
@@ -191,7 +188,7 @@ export function Telemetry({ session, subagent, entries, className }: TelemetryPr
data-testid="telemetry"
>
<span className={cn("telemetry__state", "sub-state", tone)} data-testid="telemetry-state">
<span className={cn("dot", SUB_DOT[subagent.status])} aria-hidden="true" />
<StatusDot status={dot.status} steady={dot.steady} />
{t(`state.${subagent.status}`)}
</span>
{elapsed ? (