Skip to content

feat(ai): admin view-transcript UI for crew/agent runs (AI-045)#340

Merged
mrviduus merged 1 commit into
mainfrom
ai-045-transcript-ui
Jun 16, 2026
Merged

feat(ai): admin view-transcript UI for crew/agent runs (AI-045)#340
mrviduus merged 1 commit into
mainfrom
ai-045-transcript-ui

Conversation

@mrviduus

Copy link
Copy Markdown
Owner

AI-045 — Admin "view transcript" UI (Phase 7)

Makes the multi-agent reasoning chain inspectable. Every crew run (crew.autopublish/crew.seo) and single-agent run (studybuddy) already persists an agent_run row with a nested-step transcript (researcher→drafter→critic→editor); this surfaces it in the admin app. No schema change, no new table — read-only over the existing Phase 6 agent_run.

Backend (2 read endpoints, mirror GetTraces/GetTrace)

  • GET /admin/ai-quality/agent-runs?agent=&limit=&offset= — list, newest-first, agent filter = exact-or-prefix (crew. narrows to all crew runs), clamp 1–100. List projection omits the heavy StepsJson+Output and truncates Goal to 120 chars (guarded).
  • GET /admin/ai-quality/agent-runs/{id} — detail with full raw StepsJson + Output, 404 on unknown.
  • StepsJson passed through raw, parsed client-side (same pattern as TraceDetailDto) — no brittle second server-side schema.

Frontend (new Transcripts tab on AiQualityPage)

Modeled on TracesTab/TraceModal: filterable list (All / crew.autopublish / crew.seo / studybuddy) + pager → click row → modal. The modal parses stepsJson into the step tree — each sub_agent is a collapsible {stage} · {agentName} panel with per-step usage; the critic is special-cased + default-expanded, rendering its JSON verdict as score chips (factual_accuracy/tone/length/banned_phrases) + a severity-colored issue list (blocker red / major amber / minor gray). Defensive throughout — malformed/empty/non-JSON steps fall back to raw, never throw.

The casing contract is load-bearing (a mismatch = blank transcript)

DbAgentRunWriter serializes run.Steps with default STJ options (a direct JsonSerializer.Serialize, unaffected by the HTTP pipeline's web-defaults), so the stored shape is mixed: top-level AgentStep records → PascalCase (Index/Kind/Payload/At), the sub_agent payload anon-object → camelCase (stage/agentName/status/usage/steps), the nested AgentUsage record → PascalCase, inner llm_response payload new { text } → camelCase. The frontend reads each exactly. CrewTranscriptJsonContractTests (pure, no DB) serializes a real 4-stage crew.autopublish run through the same factory+options and asserts every key the UI depends on, with negative asserts so it fails loudly if anyone ever puts camelCase/web options on the writer. (QA-added; adversarial review confirmed the contract correct end-to-end, 0 P1/P2.)

Tests

  • CrewTranscriptJsonContractTests (5, pure) — the write↔read casing contract.
  • AdminAgentRunsEndpointTests (integration, live-server — same fixture as the rest of the suite, run by CI's docker job).
  • dotnet test tests/TextStack.UnitTests407 pass; StudyBuddy set-equality green.
  • dotnet format --verify-no-changes → clean.
  • pnpm -C apps/admin exec tsc --noEmit + build → clean.

Notes

Per-description deep-link from the AutoPublish/SEO pages (by the runIds their crew-generate endpoints already return) is a deliberate fast-follow; this PR is the self-contained AI-quality tab. Admin-only (/admin/* auth) — Goal can carry user passages / book source, acceptable for the owner's audit surface. UI is build-verified; browser-check needs an admin session (owner-side).

🤖 Generated with Claude Code

Makes the multi-agent reasoning chain inspectable. Read-only over the
existing Phase 6 agent_run — no schema change, no new table.

- Backend: GET /admin/ai-quality/agent-runs (list, filter by agent,
  newest-first, omits heavy StepsJson/Output, Goal truncated) +
  /agent-runs/{id} (detail, raw StepsJson). Mirrors GetTraces/GetTrace;
  StepsJson passed through raw, parsed client-side.
- Frontend: Transcripts tab on AiQualityPage (list+modal, modeled on
  TracesTab/TraceModal). Parses the step tree; critic step special-cased
  (score chips + severity-colored issues), default-expanded. Defensive —
  malformed/non-JSON steps fall back to raw, never throw.
- Casing contract is load-bearing (mismatch = blank transcript):
  DbAgentRunWriter uses default STJ → mixed Pascal/camel. Frontend reads
  each key exactly; CrewTranscriptJsonContractTests locks it with
  negative asserts that fail if anyone adds web/camelCase options.

407 unit + admin tsc/build green. Per-description deep-link = fast-follow.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@mrviduus mrviduus merged commit 9e33122 into main Jun 16, 2026
5 checks passed
@mrviduus mrviduus deleted the ai-045-transcript-ui branch June 16, 2026 04:01
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