fix(client): show token usage on replies when Show Cost is enabled - #2240
fix(client): show token usage on replies when Show Cost is enabled#2240Phoenix0531-sudo wants to merge 4 commits into
Conversation
|
我本地实际测试了这版,目前仍有两个问题,暂时不能合并:
以我测试的会话 建议后端按 |
Display settings already had show_cost, but chat replies never rendered it. Surface cumulative session input/output tokens on the latest completed assistant message when the toggle is on.
Addressed review on EKKOLearnAI#2240: 1. Do not let session-list 0/0 overwrite runtime session usage from usage.updated / run.completed during refreshSessionListOnly. 2. Aggregate session_usage rows by run_id (exact + prefix) and emit runUsage on run.completed for hermes / ekko / coding-agent. 3. Bind that runUsage to the completed assistant message and render it under Show Cost, instead of cumulative session counters. Tests cover MessageItem run usage rendering, session-list preservation, and getRecordedUsageByRun JSON aggregation.
e99fe23 to
315703e
Compare
|
Addressed both review points:
Validation:
Not yet done: persisting per-message usage into DB history for reload-after-restart. Live run + reconnect-in-session path is covered. |
Summary
Display settings already had a Show Cost toggle (
show_cost) with the hint “Show token usage in replies”, but chat bubbles never read that setting. With the toggle on, replies still looked empty of any token information.This wires the existing session
inputTokens/outputTokensintoMessageItemand shows them on the latest completed assistant reply whenshow_costis enabled. Management of the setting itself is unchanged; usage is still session-cumulative (same numbers the context meter already tracks).Validation
npm run test -- tests/client/message-item-token-usage.test.tsnpm run harness:checknpm run buildFixes #2140