Show per-member token usage badges on panel bubbles
memberUsage was already populated for CLI members (from the result event) and Anthropic-API members (via the tool loop), but it was never written to the panel_member_done SSE event or the persisted content JSON, so the frontend had no token data to render. Add the token fields (input/output/cacheRead/cacheCreation) to both the SSE event and the persisted JSON, and render them via a shared buildPanelMemberMeta helper used by both the live stream and history, so the badge survives F5. OpenAI members (no per-turn tokens), error members, and pre-existing history without token fields fall through to no badge. The badge is display-only; aggregation into the worker/chain total via seedUsage is unchanged, so there is no double counting and no DB migration. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
17ba4840dd
commit
8e5a961e94
4 files changed
+50
-2
No files matched your search
@@ -245,7 +245,15 @@ public partial class AnthropicService
|
||||
}
|
||||
if (segments.Count > 0)
|
||||
{
|
||||
var content = JsonSerializer.Serialize(new { name, model = member.ModelId, layer, totalLayers, segments });
|
||||
var content = JsonSerializer.Serialize(new
|
||||
{
|
||||
name, model = member.ModelId, layer, totalLayers,
|
||||
inputTokens = memberUsage?.InputTokens ?? 0,
|
||||
outputTokens = memberUsage?.OutputTokens ?? 0,
|
||||
cacheReadTokens = memberUsage?.CacheReadTokens ?? 0,
|
||||
cacheCreationTokens = memberUsage?.CacheCreationTokens ?? 0,
|
||||
segments
|
||||
});
|
||||
await _db.SaveMessage(new MessageRecord
|
||||
{
|
||||
ChainId = chainId, Iteration = layer * 100 + index + 1,
|
||||
@@ -255,7 +263,14 @@ public partial class AnthropicService
|
||||
}
|
||||
|
||||
await SseHelper.TryWriteSse(response, "panel_member_done",
|
||||
new { index, name, model = member.ModelId, text }, sseCt, sseGate);
|
||||
new
|
||||
{
|
||||
index, name, model = member.ModelId, text,
|
||||
inputTokens = memberUsage?.InputTokens ?? 0,
|
||||
outputTokens = memberUsage?.OutputTokens ?? 0,
|
||||
cacheReadTokens = memberUsage?.CacheReadTokens ?? 0,
|
||||
cacheCreationTokens = memberUsage?.CacheCreationTokens ?? 0
|
||||
}, sseCt, sseGate);
|
||||
|
||||
return new PanelMemberResult { Index = index, Name = name, Model = member.ModelId, Text = text, Usage = memberUsage };
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user