Draw curves in the terminal, and stop waiting five seconds to hear
Docs / docs (push) Successful in 27s
Playwright Tests / test-playwright (1, 2) (push) Failing after 18m28s
Playwright Tests / test-playwright (2, 2) (push) Successful in 5m11s
pre-commit / pre-commit (push) Failing after 2m2s
Test Backend / test-backend (push) Failing after 2m32s
Compose Smoke Test / test-compose (push) Successful in 32s
Playwright Tests / merge-reports (push) Successful in 5m50s

`space` ticks runs on the serve dashboard's table and `enter` compares them:
one metric in braille, five distinct hues, and the table of what actually
differs under it. Both halves are routes that already existed — the browser's
own comparison endpoint for the curves, the runs export for the table, whose
input columns are filtered to the ones that vary.

The palette is hue rather than the web's lightness ramp on purpose: five steps
of one brand hue collapse to a single colour on a 16-colour tty.

The screen also subscribes to the engine's event bus over the same websocket a
browser uses, so a run that starts and finishes inside a tick is seen rather
than only recorded. `a` lists what a run left behind and fetches it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014SmyLMSqcJQ8tUL2qLj21s
This commit is contained in:
2026-08-30 12:51:08 +02:00
co-authored by Claude Opus 5
parent 45cc7504e1
commit f370601aec
12 changed files with 926 additions and 35 deletions
+26 -9
View File
@@ -805,7 +805,7 @@ def _status_screen(client: Client) -> Any:
)
+ Text(
f"{str(row.get('flow', '')):<16}"
f"{(row.get('duration_ms') or 0) / 1000:7.1f}s"
f"{_dur(row.get('duration_ms')):>8}"
f" {_ago(row.get('finished_at') or row.get('created_at')):>9}",
style="dim",
)
@@ -886,6 +886,19 @@ def _declared(client: Client, flows: Iterable[str]) -> dict[str, dict[str, Any]]
return known
def _dur(ms: Any) -> str:
"""How long something took, in the same notation `_ago` reads an age in.
A run measured in hours used to print four digits of seconds, because the
three places that formatted a duration each did it their own way.
"""
seconds = max(float(ms or 0.0), 0.0) / 1000
for span, unit in ((86400, "d"), (3600, "h"), (60, "min")):
if seconds >= span:
return f"{seconds / span:.1f}{unit}"
return f"{seconds:.1f}s"
def _ago(stamp: Any) -> str:
"""How long ago something happened, in the notation the screens use.
@@ -950,7 +963,7 @@ def cmd_runs(args: argparse.Namespace) -> int:
params = params[: room - 3] + "..."
_say(
f"{row['id']} {_status(row['status'], 9)} {row['flow']:<16} "
f"{row['duration_ms'] / 1000:7.1f}s {_ago(row.get('created_at')):>9} "
f"{_dur(row['duration_ms']):>8} {_ago(row.get('created_at')):>9} "
f"{_stamp(row):<22} {params}"
)
return 0
@@ -1131,12 +1144,20 @@ def _write_rows(rows: list[dict[str, Any]], fmt: str, out: str, hint: str = "")
LIST_SCAN = 10
def _list_names(client: Client, args: argparse.Namespace) -> int:
def metric_names(client: Client, ids: Iterable[str]) -> list[str]:
"""The metric names these runs carry, since a name is flow-qualified.
`train_loss` is recorded as `train.train_loss`, and asking for the bare
one matches nothing — so this is the answer to "what would match".
"""
for run_id in list(ids)[:LIST_SCAN]:
names = sorted({point["name"] for point in client.metrics(run_id)})
if names:
return names
return []
def _list_names(client: Client, args: argparse.Namespace) -> int:
filters = _selection(args)
if "until" in filters:
# The history spells the same bound `before`, where it is also the
@@ -1145,12 +1166,8 @@ def _list_names(client: Client, args: argparse.Namespace) -> int:
ids = args.run or [
row["id"] for row in client.runs(flow=args.flow, limit=LIST_SCAN, **filters)
]
for run_id in ids[:LIST_SCAN]:
names = sorted({point["name"] for point in client.metrics(run_id)})
if names:
_say("\n".join(names))
return 0
_say("No metrics recorded by these runs.")
names = metric_names(client, ids)
_say("\n".join(names) if names else "No metrics recorded by these runs.")
return 0