Per-turn cost display on each assistant message bubble (#503)#1159
Closed
bergeouss wants to merge 2 commits intonesquena:masterfrom
Closed
Per-turn cost display on each assistant message bubble (#503)#1159bergeouss wants to merge 2 commits intonesquena:masterfrom
bergeouss wants to merge 2 commits intonesquena:masterfrom
Conversation
…a#503) - messages.js: compute per-turn token/cost delta from cumulative usage at done event and store as _turnUsage on the last assistant message - ui.js: render per-turn usage on each assistant bubble that has _turnUsage, replacing the misleading cumulative-total-on-last-bubble - The context ring/composer footer still shows cumulative totals - Preserves backwards compatibility: old messages without _turnUsage simply won't show inline usage (no visual regression)
Extract _attachTurnUsage() to keep the done handler compact and within the 3300-char regression test window for S.busy=false ordering. Functional behavior unchanged — per-turn cost delta still computed and attached to the last assistant message._turnUsage.
Collaborator
|
Good implementation of per-turn cost display, @bergeouss! The delta-computation approach is the right way to convert cumulative The key design decisions look correct:
The guard The |
nesquena-hermes
added a commit
that referenced
this pull request
Apr 27, 2026
Merged as v0.50.227. 2634 tests passing, browser QA 21/21 (desktop + mobile). Full attribution below. Thanks to all 12 contributors: @jundev0001 (#1138), @franksong2702 (#1142, #1157, #1162), @dso2ng (#1143), @bergeouss (#1145, #1146, #1156, #1159), @jasonjcwu (#1149), @ccqqlo (#1161), @frap129 (#1165) Two fixes applied during integration and two more by the independent reviewer (@nesquena): - messages.js: per-turn cost delta capture order (#1159) - workspace.py: symlink target blocked-roots check + HOME sanity guard (#1149, #1165) - panels.js: cron unread counter bookkeeping (in-loop increment bug) - tests/test_symlink_cycle_detection.py: register workspace before session/new
Collaborator
|
Merged as v0.50.227 via batch PR #1168. Thank you @bergeouss! 🎉 |
JKJameson
pushed a commit
to JKJameson/hermes-webui
that referenced
this pull request
Apr 29, 2026
Merged as v0.50.227. 2634 tests passing, browser QA 21/21 (desktop + mobile). Full attribution below. Thanks to all 12 contributors: @jundev0001 (nesquena#1138), @franksong2702 (nesquena#1142, nesquena#1157, nesquena#1162), @dso2ng (nesquena#1143), @bergeouss (nesquena#1145, nesquena#1146, nesquena#1156, nesquena#1159), @jasonjcwu (nesquena#1149), @ccqqlo (nesquena#1161), @frap129 (nesquena#1165) Two fixes applied during integration and two more by the independent reviewer (@nesquena): - messages.js: per-turn cost delta capture order (nesquena#1159) - workspace.py: symlink target blocked-roots check + HOME sanity guard (nesquena#1149, nesquena#1165) - panels.js: cron unread counter bookkeeping (in-loop increment bug) - tests/test_symlink_cycle_detection.py: register workspace before session/new
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.
Thinking Path
Issue #503 identifies that the cost/token display attached to the last assistant message shows cumulative session totals (
S.session.input_tokens,S.session.output_tokens). This means the number attached to message 5 is the total cost of the entire conversation, not just that turn — which reads as misleading.The fix: compute a per-turn delta from the cumulative usage delivered in the
doneSSE event, store it on the message object, and render it individually on each assistant bubble.What Changed
static/messages.jsdoneSSE event handler, whend.usagearrives (cumulative totals), compute the delta vs the previous session totals (S.session.input_tokensetc.)_turnUsageon the last assistant message:{input_tokens, output_tokens, estimated_cost}_turnUsageif values actually increased (skips no-op turns)static/ui.jsS.messages, finds assistant messages with_turnUsage, and renders inline usage on each one's footeraicounter to correctly map message indices to.assistant-turnDOM rows (since user messages don't create assistant-turn rows)_syncCtxIndicator()— no information is lostBackwards compatibility
_turnUsage— they simply won't show inline usage, which is correct (we don't have per-turn data for them)_showTokenUsagesetting still gates the featureCloses #503