Skip to content

fix(app): show the TUI turn metrics in the debug bar - #57934

Merged
Hona merged 3 commits into
betafrom
shared-turn-tps
Oct 21, 2026
Merged

Hona merged 3 commits into
betafrom
shared-turn-tps

Conversation

@Hona

@Hona Hona commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

The debug bar's TPS divided one step's output tokens by the time from its first output event to the end of its stream. When a provider delivers output in a burst (Gemini tool calls, gateway-buffered text), that window is a few milliseconds, so the bar jumped to values like 4,000 tok/s. The TUI footer averages over the whole turn and stays stable.

This moves the TUI footer calculations into @opencode/util without changing them, and makes the debug bar show exactly the two numbers the TUI footer shows: turn duration and TPS.

flowchart LR
  M[session messages] --> T[SessionTurn.duration / tokensPerSecond]
  T --> D["@opencode/util/duration"]
  D --> F[TUI assistant footer]
  D --> B[GUI debug bar: TIME, TPS]
Loading
Before (GUI) After (GUI = TUI footer)
Cells TPS, TTFT, TTFA, E2E TIME, TPS
Message Latest step (live events) Latest footer step: ended the turn, failed, or retrying
TPS tokens output output + reasoning
TPS window first output event → streamed created → streamed, summed per step
Duration format 183s 3m 3s (same formatter as the TUI)
import { SessionTurn } from "@opencode/util/session-turn"
import { duration } from "@opencode/util/duration"

SessionTurn.tokensPerSecond(messages, message, { index, legacy })
SessionTurn.duration(messages, message, { index, legacy })
SessionTurn.legacy(messages)
duration(183_000) // "3m 3s"
  • Message is a structural interface in util, so util gains no dependency; client SessionMessageInfo values pass as is.
  • index and legacy are optional and let reactive callers avoid subscribing to the whole history, as the TUI footer already did.
  • TUI behavior is unchanged: the turn tests moved to packages/util/src/session-turn.test.ts with the same expectations, and Locale.duration re-exports the moved formatter.
  • The debug bar's event accumulator (debug/metrics.ts) is removed with TTFT, TTFA and E2E. The bar now reads only the message projection.
  • Tooltips describe the turn measurements in all 63 locales; the ttft, ttfa and e2e keys are removed.

Copilot AI balanced review requested due to automatic review settings October 21, 2026 21:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change looks sound. I ran the debug bar's TPS calculation on a burst-output step: on the base it gave 40,000 tok/s, and with this PR the bar uses SessionTurn.tokensPerSecond, which gives 50 tok/s, the same as the TUI footer. TTFT and E2E are unchanged. The turn logic moved into @opencode/util/session-turn unchanged, and no code still uses the removed rows.ts functions or metrics().tps. The tests in util, tui and gui-extensions pass, and type checks pass for all three packages. I didn't open the GUI debug bar itself, so a before/after screenshot from the app would be a useful addition.

Public API: unchanged. Only internal workspace modules are affected: the removed rows.ts functions, the new @opencode/util/session-turn module and the dropped ProviderMetrics.tps field.

No blocking concerns.

@Hona Hona changed the title fix(app): share turn TPS between the TUI and debug bar fix(app): show the TUI turn metrics in the debug bar Oct 21, 2026
@Hona
Hona merged commit 565a2e3 into beta Oct 21, 2026
4 checks passed
@Hona
Hona deleted the shared-turn-tps branch October 21, 2026 22:02
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.

2 participants