fix(usage): keep session spend accurate without emptying the modal - #612
Merged
Merged
Conversation
Only sum turn_completed usage. Drop cache-heavy fragments that have no modelCalls (those used a different cache split and made cached > input). Keep real turns that omit modelCalls. Persist spend in sessionStorage and say usage updates when a turn is still running.
Owner
|
Merged, thanks @Yy-702 — session spend now stays on |
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.
Summary
Follow-up to #611 (already merged). Local
/usagecould show cached > input (e.g. 144k vs 88k) because per-call / fragment packets were summed with theturn_completedsnapshot. A first filter then dropped real turns and the modal went empty mid-turn.turn_completed.modelCallswhen cache > input (or cache with no input).modelCallsif cache ≤ input.sessionStorageso HMR/reload does not wipe totals.Verified locally: 59,780 input / 57,984 cached / 97% hit.
Type of change
Checklist
pnpm test(sessionSpend + i18n)cargo testinsrc-tauri(no Rust change)src/i18n/messages.ts(en + zh + zh-TW)window.confirm/prompt/alertfor product dialogsdocs/llm-wikiupdated if behavior changed