server-side TurnState in the harness, exposed via /api/state

new TurnState { Idle, Thinking, Compacting } on hive_ag3nt::events::Bus
with set_state + state_snapshot. the turn loops in hive-ag3nt and
hive-m1nd flip Thinking before drive_turn and Idle after; the
web_ui's /api/compact handler flips Compacting around compact_session.

per-agent /api/state grows turn_state + turn_state_since (unix
seconds). frontend prefers the server-reported state over the
client-derived one — setStateAbs takes the absolute since-time so
the 'last turn' chip reads the actual server-side duration instead
of the client's perceived gap between SSE events. SSE turn_start /
turn_end still drive state instantly between renders; /api/state
re-anchors on each turn_end refresh.

new compacting state gets its own purple badge with pulse
animation (mirrors thinking's amber). napping will slot in the
same way once the nap tool lands.
This commit is contained in:
müde 2026-05-15 20:46:38 +02:00
parent 0385d96bf3
commit 637085644d
7 changed files with 94 additions and 32 deletions

17
TODO.md
View file

@ -27,19 +27,10 @@ Pick anything from here when relevant. Cross-cutting design notes live in
## UI / UX
- **State badge: compacting + napping states.** Idle/thinking already
ship (driven from SSE turn_start/turn_end). Add `compacting 📦` and
`napping 😴` once the `/compact` trigger and `nap` tool exist —
both need a harness signal (an explicit `LiveEvent::StateChange`
variant or piggyback on Note).
- **Server-side state badge.** Today the badge is computed client-side
from `turn_start`/`turn_end` events. On page reload mid-turn the
history replay re-derives it, but with a `compacting` / `napping`
state coming and a non-trivial state machine it's better to track
authoritative state in the harness and expose it via
`GET /api/state` (`status: "thinking" | "idle" | "compacting" |
"napping"`). JS just renders. Drops the
derive-from-events-and-pray code path.
- **State badge: napping state.** Idle / thinking / compacting
already ship from server-side `TurnState`. Add `napping 😴`
once the `nap` tool exists — it just adds a new `TurnState`
variant the harness flips into for the duration of the nap.
- **Terminal: `/model` slash command.** Operator-typeable model
override from the terminal. Depends on the model-override work
above; once an override mechanism exists, wire a `/model <name>`