Skip to content

[agent] Add Turn timeline, real elapsed time, errors, and Usage #7

Description

@sam2tom

Context

The client already implements listTurns and retrieveTurn and models AgentTurn plus TokenUsage, but the UI never loads Turns. The current WorkTrace total is the sum of visible command durations and is not the Turn wall-clock duration.

Observable outcome: users can determine whether each Turn finished, where it failed, how long it took, and how many tokens the Core reported.

Acceptance criteria

  • Load every page of Turns for the selected Session and refresh them with durable Session/Item recovery.
  • Associate Items with their owning Turn by turn_id without losing existing conversation rendering.
  • Present queued, in_progress, waiting, completed, failed, and cancelled states with accessible labels.
  • Compute completed wall-clock time only from server started_at and completed_at; show a live elapsed value for active Turns and label it as running.
  • Display Turn errors without hiding already persisted Items.
  • Display input, output, total, cached, and reasoning token counts.
  • Render null or unavailable Usage and timestamps as Unknown, never as zero.
  • Keep Session aggregate Usage and per-Turn Usage visibly distinct.
  • Handle pagination, stale responses, Session switching, SSE terminal events, and durable recovery races.
  • Update docs/protocol-coverage.md to distinguish tool progress, Turn observability, Usage, and unavailable full tracing.
  • Prefer a feature-local TurnTimeline component and lib/test modules; minimize App.tsx, SessionsView.tsx, and style.css edits.

Validation

  • Run focused tests for pagination, all statuses, running/completed duration, missing timestamps, null/partial Usage, errors, and Session switching.
  • Verify terminal SSE events trigger a durable Turn refresh.
  • Verify empty, loading, failed, narrow-layout, and keyboard/screen-reader states.
  • Run pnpm check and git diff --check.
  • Run the repository .agents ignore check.

Non-goals

  • Do not sum command durations and label the result as Turn wall-clock time.
  • Do not invent per-Item timestamps or reconstruct a complete OpenAI Trace waterfall.
  • Do not estimate monetary cost.
  • Do not modify Parsar Core or make paid model requests.
  • Do not commit any .agents content.

Dependencies

Start from current main after the SSE recovery work in #3 is merged. Coordinate any SessionsView integration with #4 rather than reformatting shared code.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions