Repository navigation
Conversation
Surface money spent per step and per turn in the session token usage view, alongside the existing token counts. - Render each step's incremental cost in the expandable table and the turn total in the collapsed summary line. - Add `Locale.formatCost` for USD amounts: two decimals at a cent or more, one truncated significant digit below, with tests.
Contributor
|
The following comment was made by an LLM, it may be inaccurate: |
1 task done
Author
|
Closing for now, it's not that important and I want to open another PR (I'm at limit of open PR now) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #53121
Type of change
What does this PR do?
Hello!
I was staring at the
debug.turn_tokensusage view and thought it would be nice to see the price next to the tokens.The view already splits a turn into steps by token counts, but there was no cost tracking in it. 👀
So this PR adds a
Costcolumn to the expanded table, plus a turn total on the collapsed summary line:+$0.0004, and a step with no price data shows—.· $0.0012 cost, only when at least one step actually reports a cost.Costheader is centered over the column; the values sit left-aligned, since nothing follows them.The formatting localized in a small
Locale.formatCosthelper:(these costs are insignificant anyway..)
The data was already sitting on each assistant message (
cost?: Money.USD), so nothing outside the TUI changed. 🙂How did you verify your code works?
Tested manually with
bun dev, switched to an old test session.From
packages/tui:bun test test/util/locale.test.ts— 4 pass, 19 expect() callsbun typecheck— clean (tsgo -b, no errors)oxlinton the changed files — 0 warnings, 0 errorsThe
formatCosttest coversundefined, zero, normal amounts, and sub-cent truncation ($0.005,$0.0004,$0.00003); thepadCentertest covers centering, including a width narrower than the text.The
TurnTokenUsagecolumn layout and cost aggregation themselves have no unit test.Screenshots / recordings
BEFORE (no

Costcolumn):AFTER examples:


Checklist