Repository navigation
feat(usage): make the spend entry an icon and read it on open - #730
Merged
Merged
Conversation
…versation Two comments on the first cut, both about where the control belongs: - The entry showed the running amount as text. That is the conversation header, whose job is the conversation — a number that changes every turn competes with the title for the eye. A receipt icon opens the same dialog without carrying the figure; the amount lives inside, where it has the token split next to it. Receipt rather than coins/wallet/circle: those read as "money in general", and the activity rail already uses a wallet for the account balance, whereas a receipt is the bill for this conversation. - Renaming lived in the conversation (a pencil in the top bar, later inside the usage sheet). The session list already owns it, so repeating it only lengthened the bar and put an editing action in an accounting view. Removed from both, along with `useRename` — nothing else used it. The label font for composed sheets is not part of this change, but the review images for it hit a real trap: PingFang.ttc no longer exists on current macOS, so a short font list falls through to a Latin-only face and every Han glyph becomes a tofu box. The sheets here go through the harness's own `load_font`, which already orders CJK faces first.
…ched one The amount came from the cached agent state, which is only as fresh as the last read: opening the thread, an agent reconnect, or a compaction event. Nothing re-read it when a run finished, so the panel kept showing the figure from whenever the conversation was opened — the same numbers every time, which is how it was reported. - Desktop: opening the panel re-reads the session (`revalidateAgentState`), and `agent_end` now revalidates too — a run's spend is final at that point, and the panel may already be on screen when it lands. The cached values stay visible until the fresh read arrives; nothing blanks out. - Mobile: the sheet's entry point re-reads through `refreshSessionUsage`, a new controller method. A failed read keeps the last known figures rather than emptying the sheet, and no request is made when no conversation is open. Verification is end-to-end, not just "the call happens": both harness mocks now answer a *later* read with a larger figure and the scenarios assert the panel shows it — `thread-usage` requires ¥1.3904 in the dialog where the header's cached value was ¥1.0904, and `usage-sheet` requires the same in the sheet and then on the top bar after closing. Those steps fail the capture run if the refresh stops reaching the UI. Unit tests cover the pieces: the desktop re-read fires on open and on run end (both fail against the previous code), and the mobile controller applies what a refresh returns while surviving a failure.
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.
Three changes to the session-spend entry, from reviewing the panel on both platforms.
1. The entry is an icon, not an amount
Both headers showed the running total as text (
¥1.0904). That puts a number that changes on every run in the most prominent slot of the header, and it competed with the thread title for width. It is now aReceiptText(bill) icon button — desktop 32×32, mobile 44×44 (touch target) — witharia-label"Token 用量与金额" andaria-haspopupon desktop. The amount is unaffected; it is one click away, in the panel.Chosen over Coins/CircleDollarSign/Wallet/PieChart/Gauge after rendering all six in the real UI: the first three read as "money/balance" (the desktop sidebar already uses a wallet for account credit), PieChart/Gauge read as "statistics/quota", and a bill matches what the panel actually shows — a session's itemised spend.
2. Opening the panel now reads the session instead of a cached snapshot
The number was stuck at whatever it was when the thread was opened:
agent_endforwarded the event to the message list but never re-read usage, and the click handler only toggled visibility.revalidateAgentState), and a run ending re-reads too, so a panel already on screen updates in place. The cached value stays visible until the new one arrives (no blank flash).refreshSessionUsage()on open; a failed read keeps the last known figures rather than clearing the sheet, and no request is sent when no session is open.3. Mobile: no rename in the conversation
The pencil sat in the top bar and again in the panel header, while every conversation in the list already has Rename in its row menu. Both were removed (and
useRename.tsdeleted — the sheet was its only other consumer), which frees the top-bar row for the title.Verification
npm run lint(eslint oversrc/shot+ tsc),npm run stylelint,vitest run— 1184 passed.tsc --noEmit,eslint .,jest— 1706 passed.¥1.3904, previously the cached¥1.0904), so a regression in the refresh fails the capture instead of only being visible to a human. Six icon-variant scenarios are included for the comparison above.Reviewed images (entry before/after, panel, unpriced model, icon candidates, both platforms) were rendered from the real UI against demo data.