Skip to content

fix(dashboard): span-close turn aggregator + active-session State pick#158

Merged
slabgorb merged 1 commit intodevelopfrom
fix/otel-dashboard-turn-aggregator
Apr 24, 2026
Merged

fix(dashboard): span-close turn aggregator + active-session State pick#158
slabgorb merged 1 commit intodevelopfrom
fix/otel-dashboard-turn-aggregator

Conversation

@slabgorb
Copy link
Copy Markdown
Owner

Summary

Fixes two OTEL dashboard bugs from the 2026-04-24 playtest (sq-playtest-pingpong lines 582, 598).

  • Bug 1 — Turns counter stuck at 0 (Timeline / Timing / Prompt / Lore all empty): The aggregator gated on a semantic turn_complete event that stopped arriving in live traffic. Span closes kept flowing, so Console + Subsystems worked while every per-turn tab stayed empty. The reducer now treats agent_span_close { name: "orchestrator.process_action" } as the canonical turn boundary, accumulating turn_id / player_id / genre / world from narrator.canonical_leak_audit and duration from turn.agent_llm.inference, then synthesizing a turn_complete on the process-action close. A late semantic turn_complete for the same turn_id replaces the synthesized entry instead of double-counting.
  • Bug 2 — State tab showed the wrong session: With multiple saves, debugState[0] landed on the oldest save. StateTab now picks the entry with the largest last_activity_ts (new optional field on SessionStateView; the paired server PR populates it).

Test plan

  • npx vitest run src/components/Dashboard — 19 tests pass (4 new)
  • Live verify: trigger a turn on /#/dashboard; header Turns counter increments; Timeline populates with a row; Timing p95 leaves
  • Live verify: with multiple saves, State tab shows the active session (not the oldest)

Wiring tests added:

  • DashboardApp-event-parsing.test.tsx — span-close sequence increments Turns; dedupe on late semantic turn_complete
  • StateTab.test.tsx — picks by last_activity_ts; falls back to index 0 when field absent (back-compat with un-deployed servers)

Paired with sidequest-server PR slabgorb/sidequest-server#39 for the server-side mtime sort, ?session_key= filter, and local_dm JSON extraction fix.

🤖 Generated with Claude Code

Two OTEL dashboard bugs from the 2026-04-24 playtest
(sq-playtest-pingpong lines 582, 598).

Bug 1 — Turns counter stuck at 0, Timeline / Timing / Prompt / Lore
empty. Root cause: the aggregator only counted the semantic
`turn_complete` event, which stopped reaching the stream in live
traffic. OTEL span closes (`orchestrator.process_action`,
`turn.agent_llm.inference`, `narrator.canonical_leak_audit`) kept
flowing — Console + Subsystems tabs filled while every per-turn tab
stayed empty.

Fix: treat `agent_span_close { name: "orchestrator.process_action" }`
as the canonical turn boundary. Accumulate `turn_id` / `player_id` /
genre / world from `narrator.canonical_leak_audit` (carries
`turn_id=<genre>:<world>:<player>:<N>`) and inference duration from
`turn.agent_llm.inference`, then synthesize a `turn_complete`
WatcherEvent on the `orchestrator.process_action` close. Dedupe by
`turn_id` so a late semantic `turn_complete` replaces the synthesized
entry rather than double-counting.

Bug 2 — State tab reads the first session from /api/debug/state,
which with multiple saves was usually the OLDEST save instead of the
active one. StateTab now picks the session with the largest
`last_activity_ts` (new field on `SessionStateView`; server-side sort
is handled in the paired server PR).

Wiring tests:
- increments Turns counter when orchestrator.process_action closes
  (feeds the exact 3-event sequence seen in playtest console logs)
- does not double-count when a real turn_complete follows a
  synthesized one for the same turn_id
- State tab picks the most-recently-touched session by last_activity_ts
- State tab falls back to first entry when last_activity_ts absent
  (back-compat with un-deployed servers)

Paired with sidequest-server PR #39 for the server-side sort +
`?session_key=` filter, plus the local_dm JSON extraction fix.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@slabgorb slabgorb merged commit 528d348 into develop Apr 24, 2026
1 check failed
@slabgorb slabgorb deleted the fix/otel-dashboard-turn-aggregator branch April 24, 2026 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant