Watch
0
0
Fork
You've already forked hyperhive
0

swarm ui: say what a subagent's age counts from, and the list's two lookup passes

A running status shows 'running since', a stale one shows no age, since its
time is when the run began. The reference now says the status reads and the row
lookups are two passes, so the list waits up to four seconds in all.
This commit is contained in:
iris 2026-11-15 15:38:28 +01:00 • committed by mara
commit c56faf9dff
3 changed files with 35 additions and 13 deletions

View file

@ -15,7 +15,7 @@ import { Badge } from "@hive/shared/badge.js";
import { AgentTermPreview } from "./AgentTermPreview.js";
import {
isDimmed,
lastActive,
ageUnix,
runLabel,
stateLabel,
stillListed,
@ -51,7 +51,7 @@ export function SubagentTerms({ agentName }: { agentName: string }) {
{subagents?.map((sub) => {
const { name } = sub;
const runs = runLabel(sub);
const active = lastActive(sub);
const active = ageUnix(sub);
const status = stateLabel(sub);
const stale = isDimmed(sub, nowS);
return (

View file

@ -22,7 +22,7 @@ import { Popover } from "../../ui/popover/Popover.js";
import { RelativeTime } from "../../ui/relative-time/RelativeTime.js";
import { termPaths } from "./term-paths.js";
import {
lastActive,
ageUnix,
runLabel,
runningLabel,
splitRunning,
@ -56,9 +56,9 @@ function Entry({
{stateLabel(sub) && (
<span class="ui-subagents-menu-age">{stateLabel(sub)}</span>
)}
{lastActive(sub) !== null && (
{ageUnix(sub) !== null && (
<span class="ui-subagents-menu-age">
<RelativeTime epochMs={(lastActive(sub) ?? 0) * 1000} />
<RelativeTime epochMs={(ageUnix(sub) ?? 0) * 1000} />
</span>
)}
</>

View file

@ -68,12 +68,15 @@ export function isDimmed(sub: Subagent, nowS: number): boolean {
}
/**
* A word for a state that is neither running nor unknown, to show beside the
* subagent: `finished`, or `stopped reporting` for a stale status. Empty
* when running or when the daemon published no status.
* The word shown before a subagent's age, which says what the age counts from:
* `running since` for a running status, `finished` for a finished one,
* `stopped reporting` for a stale one. Empty when the daemon published no
* status, where the age is the newest row's.
*/
export function stateLabel(sub: Subagent): string {
switch (sub.state ?? null) {
case "running":
return "running since";
case "finished":
return "finished";
case "stale":
@ -83,6 +86,15 @@ export function stateLabel(sub: Subagent): string {
}
}
/**
* The time to show as an age, unix seconds, or `null` for none. A stale
* status has none: its time is when the run began, which would read as when
* the daemon stopped reporting.
*/
export function ageUnix(sub: Subagent): number | null {
return (sub.state ?? null) === "stale" ? null : lastActive(sub);
}
/** Newest first; a subagent whose time could not be read sorts last. */
export function byRecency(a: Subagent, b: Subagent): number {
const ta = lastActive(a) ?? -Infinity;