Repository navigation
fix(app): show the TUI turn metrics in the debug bar - #57934
Conversation
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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/utilwithout changing them, and makes the debug bar show exactly the two numbers the TUI footer shows: turn duration and TPS.outputoutput + reasoningstreamedcreated→streamed, summed per step183s3m 3s(same formatter as the TUI)Messageis a structural interface in util, so util gains no dependency; clientSessionMessageInfovalues pass as is.indexandlegacyare optional and let reactive callers avoid subscribing to the whole history, as the TUI footer already did.packages/util/src/session-turn.test.tswith the same expectations, andLocale.durationre-exports the moved formatter.debug/metrics.ts) is removed with TTFT, TTFA and E2E. The bar now reads only the message projection.ttft,ttfaande2ekeys are removed.