feat(tui): show turn and session cost from odek limits - #23
Merged
Conversation
Integrate with odek serve's GET /api/limits endpoint. The client learns Limits() plus a ResolvePrices port of odek's per-model price overrides; the TUI fetches limits at startup and renders: - session spend in the header's left cluster, - per-turn cost in the finalized turn footer, - a cost row (with max_cost_usd cap when configured) in /stats. Cost derives from the done event's cumulative session token counters, so it stays correct across reconnect/resume. Prices resolve against the active model at render time, so /models switches need no refetch. When odek has no token prices configured the cost UI stays entirely hidden — odek never guesses provider prices, and neither does bodek. Coverage: new code paths at 100% (ResolvePrices, fetchLimits, handleLimitsMsg, formatUSD, lineCount); internal total 97.6% -> 97.9%.
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.
What
Integrates with odek serve's new
GET /api/limitsendpoint and surfaces cost in the UI:sh.016/stats: cost row with session rollup, plus· cap $Xwhenmax_cost_usdis configuredHow
client.Limits()+Limits/ModelPricetypes mirroring the odek contract, withResolvePrices— an exact port of odek's per-model price-override semantics (per-field fallback to flat prices).fetchModels); prices resolve against the active model at render time, so/modelsswitches need no refetch.doneevent token counters (session fields are cumulative, so totals stay correct across reconnect/resume).Verification
make fmt / vet / lint— clean, 0 issuesmake test— full race suite greenResolvePrices,fetchLimits,handleLimitsMsg,formatUSD,lineCount); internal total 97.6% → 97.9%