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:
1 parent
b6335a21a4
commit
668f77bf51
4 files changed
+31
-21
No files matched your search
@@ -541,13 +541,15 @@ function withCurrent(view: DotView, state: SessionState, viewed: boolean): DotVi
|
|||||||
* attention amber (`sessionStatusKey` still labels it "interrupted").
|
* attention amber (`sessionStatusKey` still labels it "interrupted").
|
||||||
*/
|
*/
|
||||||
function parentDot(state: SessionState): DotView {
|
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 (state.flags.error) return { status: "err" };
|
||||||
if (attentionPending(state)) return { status: "attention" };
|
if (attentionPending(state)) return { status: "attention" };
|
||||||
if (state.flags.done) return { status: "ok" };
|
if (state.flags.done) return { status: "ok" };
|
||||||
if (state.status === "busy") return { status: "busy" };
|
if (state.status === "busy") return { status: "busy" };
|
||||||
if (state.status === "compacting") return { status: "compacting" };
|
if (state.status === "compacting") return { status: "compacting" };
|
||||||
if (state.status === "interrupted") return { status: "dead" };
|
|
||||||
return { status: "idle" };
|
return { status: "idle" };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { useTranslation } from "react-i18next";
|
|||||||
|
|
||||||
import { Icon } from "@/components/icons";
|
import { Icon } from "@/components/icons";
|
||||||
import { Empty } from "@/components/ui/empty";
|
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 { toast } from "@/components/ui/toast";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
@@ -12,6 +12,7 @@ import { EntryBlock } from "./blocks";
|
|||||||
import { Composer } from "./composer";
|
import { Composer } from "./composer";
|
||||||
import type { ModelGroup } from "./data";
|
import type { ModelGroup } from "./data";
|
||||||
import { HeadChips } from "./head-chips";
|
import { HeadChips } from "./head-chips";
|
||||||
|
import { subagentDot } from "./session-state";
|
||||||
import { subagentTitle } from "./session-title";
|
import { subagentTitle } from "./session-title";
|
||||||
import type { TrayTab } from "./store";
|
import type { TrayTab } from "./store";
|
||||||
|
|
||||||
@@ -19,14 +20,6 @@ import "@/styles/pages/chat-telemetry.css";
|
|||||||
|
|
||||||
type ToolBlock = Extract<Block, { type: "tool" }>;
|
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 {
|
function str(value: unknown): string | undefined {
|
||||||
return typeof value === "string" && value.trim() ? value.trim() : undefined;
|
return typeof value === "string" && value.trim() ? value.trim() : undefined;
|
||||||
}
|
}
|
||||||
@@ -250,6 +243,10 @@ export function SubagentView({
|
|||||||
.catch(() => undefined);
|
.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 (
|
return (
|
||||||
<div
|
<div
|
||||||
className={cn("subagent-view", "subagent-view--child", className)}
|
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>
|
<span className="sub-back__label">{t("chat.subview.back")}</span>
|
||||||
</button>
|
</button>
|
||||||
<div className="stream-title">
|
<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}>
|
<h2 className="stream-name truncate" tabIndex={-1} title={task ? `${name} · ${task}` : name}>
|
||||||
{name}
|
{name}
|
||||||
</h2>
|
</h2>
|
||||||
|
|||||||
@@ -2,10 +2,12 @@ import type { ContextUsage, Entry, SessionState, Subagent, UsageTotals } from "@
|
|||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
|
import { StatusDot } from "@/components/ui/status-dot";
|
||||||
import { plural } from "@/lib/i18n";
|
import { plural } from "@/lib/i18n";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
import { formatDuration } from "./format";
|
import { formatDuration } from "./format";
|
||||||
|
import { subagentDot } from "./session-state";
|
||||||
import { synthesizeSubagentTimeline } from "./subagent-view";
|
import { synthesizeSubagentTimeline } from "./subagent-view";
|
||||||
|
|
||||||
import "@/styles/pages/chat-telemetry.css";
|
import "@/styles/pages/chat-telemetry.css";
|
||||||
@@ -24,14 +26,6 @@ const SUB_TONE: Record<Subagent["status"], string> = {
|
|||||||
dormant: "is-idle",
|
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 {
|
export interface TelemetryCounts {
|
||||||
/** `role === "user"` entries in the view's timeline. */
|
/** `role === "user"` entries in the view's timeline. */
|
||||||
turns: number;
|
turns: number;
|
||||||
@@ -175,6 +169,9 @@ export function Telemetry({ session, subagent, entries, className }: TelemetryPr
|
|||||||
|
|
||||||
if (subagent) {
|
if (subagent) {
|
||||||
const timeline = synthesizeSubagentTimeline(subagent, entries);
|
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 { turns, tools } = countTelemetry(timeline);
|
||||||
const created = subagent.createdAt;
|
const created = subagent.createdAt;
|
||||||
const end = ticking ? now : (subagent.lastActiveAt ?? created);
|
const end = ticking ? now : (subagent.lastActiveAt ?? created);
|
||||||
@@ -191,7 +188,7 @@ export function Telemetry({ session, subagent, entries, className }: TelemetryPr
|
|||||||
data-testid="telemetry"
|
data-testid="telemetry"
|
||||||
>
|
>
|
||||||
<span className={cn("telemetry__state", "sub-state", tone)} data-testid="telemetry-state">
|
<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}`)}
|
{t(`state.${subagent.status}`)}
|
||||||
</span>
|
</span>
|
||||||
{elapsed ? (
|
{elapsed ? (
|
||||||
|
|||||||
@@ -122,6 +122,16 @@ describe("sessionDot (parent rows)", () => {
|
|||||||
expect(sessionDot(state)).toEqual({ status: "dead" });
|
expect(sessionDot(state)).toEqual({ status: "dead" });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("interrupted is a dead process too (outranks error, attention and done)", () => {
|
||||||
|
// The plugin has no `interrupted`: any "not running" row is `exited`
|
||||||
|
// (sessions.lua:75-78), and `exited` sits at the top of dot_hl.
|
||||||
|
expect(sessionDot(makeSession({ status: "interrupted", flags: { error: true } })).status).toBe("dead");
|
||||||
|
expect(sessionDot(makeSession({ status: "interrupted", flags: { attention: true } })).status).toBe("dead");
|
||||||
|
expect(sessionDot(makeSession({ status: "interrupted", flags: { done: true } })).status).toBe("dead");
|
||||||
|
// …and it never wears the blue current marker either.
|
||||||
|
expect(sessionDot(makeSession({ status: "interrupted" }), { viewed: true })).toEqual({ status: "dead" });
|
||||||
|
});
|
||||||
|
|
||||||
it("attention beats done (flags.attention outranks flags.done)", () => {
|
it("attention beats done (flags.attention outranks flags.done)", () => {
|
||||||
const state = makeSession({
|
const state = makeSession({
|
||||||
flags: { attention: true, done: true },
|
flags: { attention: true, done: true },
|
||||||
|
|||||||
Reference in new issue
Block a user