0010 — Map and Usage¶
The Map page was removed in 0.8.2 (2026-11-10): without agents inside the program it showed little; it comes back with the runner.
- Status: Implemented (see As built), for 0.4.0, after environments and access (0006). Part of the navigation plan (0004).
- Size: Map ~2 agent-days, Usage ~1.
Goal¶
See the whole system at a glance — who works on what, who talks to whom, who touches which environment — and how much of the subscription each session and project uses.
Map¶
Library: Cytoscape.js, vendored like htmx (no Node toolchain, no CDN).
Nodes: owner, coordinator, managers, sessions, workers, projects and their tasks, environments (local / test / live), intake sources.
Edges: hierarchy; session → task binding; messages (board comments; agent-to-agent messages seen
by the PreToolUse hook as the tool name plus its to field); session → environment access,
coloured by permission level; intake → proposal → task.
Badges: status (working / waiting / idle / ended), unread, waiting for the owner.
Views: Structure (coordinator in the centre → projects → manager → sessions and workers) and Now (edges of the last N minutes highlighted). Live over SSE: an event updates the affected nodes and edges without a reload.
API: GET /map/graph?view=structure|now&minutes=N returns nodes and edges as JSON for the page;
the hook receiver records message edges as events (session.message, recipient and time only, never
the message text).
Agents view¶
Decided 2026-11-09: the Map's default view shows how agents interact rather than the whole structure. Sessions sit in a box per project (Other when they have none) with the owner beside them; edges are who started whom, who wrote to whom and whom the owner commented, only of the last 7 days. A project filter keeps that project's box and, faded, the sessions of other projects linked to it, so cross-project links stay visible. Structure and Now remain one select away.
Who started whom is new data, read like a message edge: when a session calls the desktop tool
that starts a session, the PostToolUse hook's answer carries the new session's desktop id; relaybay
keeps that id and the caller, nothing else (session.launched, no migration). There is no backfill:
launches from before this release are not on the Map. Until relaybay knows a session with that id, the
child is a name-only node; then the edge reaches it.
Layout. The boxes go on a grid of their own, not through cose, which piles compound nodes on
top of each other.
Usage¶
Subscription use by session and model, per day and week and per project, read from the Claude Code
transcripts whose paths the hooks report (transcript_path). Read-only access to local files; the
totals are cached in the database with the file offset read so far. Nothing leaves the machine.
UI: a table and a small chart per day/week; filters by project, session and model; a link from a session to its usage.
Risks¶
| Risk | Mitigation |
|---|---|
| Transcript format changes between Claude Code versions | Tolerant parser, unknown lines skipped, version noted; Usage shows "unknown" instead of guessing |
| Large transcripts slow the server | Incremental reading by offset, in a background task |
| Map unreadable with many nodes | Collapse projects, filter by project, Now view shows only recent edges |
| Message edges leak content | Only sender, recipient and time are stored |
As built¶
Behaviour of Usage is in SPEC: Usage; the Map's is described here only. Where it differs from the plan above:
- Nodes. Coordinator, managers, workers and intake do not exist in the data yet, so they are not on the Map; the owner is in the middle and hierarchy edges run owner → project → task and environment. They join when the data holds them (0012).
- Layout. Cytoscape's built-in
cose, no extension. Positions are not stored. - CSP. Cytoscape 3.34.4 needs no
unsafe-eval. It adds one inline style element unless an element with its id exists;map.htmlholds that element andapp.cssholds the rule. The CSP did not change. - Message edges. Sender, recipient and time; the tool's name is not kept. Only
SendMessagecounts, from an explicit list, not any tool with atofield: another tool'stomay be a mail address. A recipient holding@with a domain,<, a comma or a semicolon is not recorded, and a sender has at most 20 recipients per minute. - Subagents. Their tokens live in
<transcript stem>/subagents/*.jsonl, which the hooks never report. The background reader finds them beside the reported transcript, under the same path rules and a cap of 200 files per session, and they count to the session. - Hostile lines. A transcript is data: numbers above 2^53, odd ids and days outside 2020-01-01 to tomorrow count as unknown, and a file that still fails stops only itself.
- Usage storage. Per-day rows carry their file, so a file that shrank can replace its own rows.
A third table,
usage_message, holds counted ids, because duplicates must be found across passes and across files. - Version not noted. The risk table above says "version noted"; only numbers, model, id and time are read from a line, and unknown lines are counted without it.