swarm ui: the agent's status message shows how long ago it was set
The card and its detail showed the message alone, so a message from an hour ago read like the current one. Both now add the age, (5m ago), which ticks like the other relative times. An agent with no message still shows a dash.
This commit is contained in:
parent
1cc1cb804d
commit
0547081138
1 changed files with 85 additions and 3 deletions
20
frontend/packages/swarm-ui/src/agent/detail/statusMessage.ts
Normal file
20
frontend/packages/swarm-ui/src/agent/detail/statusMessage.ts
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
// The agent's status message and when it set it, for the card and its detail.
|
||||
// Kept out of the component so `npm test` runs it.
|
||||
import type { AgentStatusSnapshot } from "../AgentTypes.js";
|
||||
|
||||
/** When the message was set, in ms since the epoch, or null when the agent has
|
||||
* set none or the time is not known. The wire carries seconds. */
|
||||
export function statusSetAtMs(
|
||||
snapshot: AgentStatusSnapshot | null,
|
||||
): number | null {
|
||||
const at = snapshot?.status_set_at;
|
||||
return typeof at === "number" && Number.isFinite(at) && at > 0
|
||||
? at * 1000
|
||||
: null;
|
||||
}
|
||||
|
||||
/** The message, or a dash when there is none. */
|
||||
export function statusText(snapshot: AgentStatusSnapshot | null): string {
|
||||
const text = snapshot?.status_text;
|
||||
return text === null || text === undefined || text === "" ? "—" : text;
|
||||
}
|
||||
Loading…
Reference in a new issue