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
32
frontend/packages/swarm-ui/test/status-message.test.mjs
Normal file
32
frontend/packages/swarm-ui/test/status-message.test.mjs
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
// The agent status message and its age. Run by `npm test`, which Node runs
|
||||
// with its built-in test runner and type stripping, so the `.ts` module is
|
||||
// imported as it is.
|
||||
import assert from "node:assert/strict";
|
||||
import { test } from "node:test";
|
||||
import {
|
||||
statusSetAtMs,
|
||||
statusText,
|
||||
} from "../src/agent/detail/statusMessage.ts";
|
||||
|
||||
const snap = (status_text, status_set_at) => ({
|
||||
status_text,
|
||||
status_set_at,
|
||||
running: true,
|
||||
});
|
||||
|
||||
test("the set time is read from seconds to ms, or is nothing", () => {
|
||||
assert.equal(
|
||||
statusSetAtMs(snap("working", 1_731_000_000)),
|
||||
1_731_000_000_000,
|
||||
);
|
||||
assert.equal(statusSetAtMs(snap("working", null)), null);
|
||||
assert.equal(statusSetAtMs(snap("working", 0)), null);
|
||||
assert.equal(statusSetAtMs(null), null);
|
||||
});
|
||||
|
||||
test("an agent with no message shows a dash", () => {
|
||||
assert.equal(statusText(snap("fixing a bug", 1)), "fixing a bug");
|
||||
assert.equal(statusText(snap(null, 1)), "—");
|
||||
assert.equal(statusText(snap("", 1)), "—");
|
||||
assert.equal(statusText(null), "—");
|
||||
});
|
||||
Loading…
Reference in a new issue