rancher-ai-ui PR 346, round two: token usage after torchiaf's fixes

Our Request changes review (2026-11-16, at 79968cc) → torchiaf replied on all four threads and pushed a76d922 "Support no-usage/partial data conditions" and ca32860 "Add token-usage aria-label". Two passes again: Pass A with Cody's my-pr-review-new-commits (ai-skills c04c11a), Pass B with our process in a fresh agent.

The preview talks to 13.62, which changed since round one: its agent is the released v1.1.1 image (no usage route) and its llm-config has no active LLM, so the panel opens on "active LLM not specified" and never connects. The no-endpoint state and the spinner were seen for real; the other states were driven by stubs in the browser only (LLM config read patched, chat WebSocket and usage response faked). Nothing was written to his environment.

Where it stands

Two of the four threads are done and two are design calls he handed to UX, but the failure case from thread 3 is only half fixed: an agent without the endpoint now shows "Token usage not available", and a 500 on a refresh still drops a shown 1.8K to "Tokens used: 0".

The new states bring two real problems, the partial-data warning reaching mouse users only and a spinner that never stops when the chat can't start, plus a logging bug in the new error path. Nothing new is a blocker. Suggested as a Comment review with one thread reply and three inline comments (two optional nits on top). Your round-one Request changes stays as the PR's review decision until you approve or dismiss it.

CI: the token-usage spec is still red, now for a different reason. Agent PR 507 merged at 13:53, but CI installs the agent chart with its pinned image v1.2.0-alpha.7, which predates 507, so the footer stays on "Token usage not available". It turns green once an agent image with 507 is tagged and the chart points at it. That's the backend dependency you set aside, so it's not in the review.

Your four comments

Your commenttorchiaf's answerChecked at ca32860State
By Source shows ui-tools/agent, By Agent shows supervisor (TokenUsage.vue:59)"We don't have Human readable names defined for those kind of agent… keep those technical agent names", cc oboc-stsCode unchanged; the popover still shows the ids. sourceLabel still looks up aiConfig.form.section.usage.sources.*, which only his settings-page branch defines, so By Source picks up names when that lands.Answered: UX's call
The button's accessible name was only "8.5K in total" (TokenUsage.vue:101)"fixed by adding a specific aria-label"AX tree: button "Tokens used: 1.8K in total". The label goes through TextLabel's new ariaLabel prop to RcButton.Addressed
A failed usage request shows "Tokens used: 0", even over a shown 1.8K (useChatMessageComposable.ts:912)"We now show 'Token usage not available' when the endpoint is not exposed by the Agent."No endpoint: the real v1.1.1 agent answers 404 {"detail":"Not Found"} and the footer says "Token usage not available" with "The AI Agent does not provide usage data." on hover. Any other failure: fetchChatUsage returns {}, and a 500 on the refresh after an answer turns "1.8K in total" into "Tokens used: 0", disabled (stub).Half: the 500 case is still open
"Tokens used: 8.5K" vs the design's "Tokens spent: 17,964" (en-us.yaml:117)"I changed this to help users reading the data – the expanded number is always available in the panel", cc oboc-stsUnchanged on purpose.Answered: UX's call
Footer reads Token usage not available, tooltip The AI Agent does not provide usage data
Thread 3, fixed half: the real v1.1.1 agent (no usage route).
Footer reads Tokens used 1.8K in total
Thread 3, open half: 1.8K shown (stub)…
Footer reads Tokens used 0 after a failed refresh
…then a 500 on the refresh after an answer: "Tokens used: 0", disabled.

How the two passes compare

Pass A (Cody's new-commits process)Pass B (our process)Lands as
Thread statesAnswered · Addressed · Half · AnsweredSameOne reply, on thread 3
500 still reads as 0Yes, stubbed 500Yes, stubbed 500 and 503Thread 3 reply
Partial warning is mouse-onlyYes: AX tree, Tab order, axe cleanYes, plus the spinner has no text either; cites Preview.vueInline 1
Spinner never stops when the chat can't startYes, real 13.62 (borderline: a state he put to UX)Yes, real 13.62, as a suggestionInline 2
Body read twice, wrong error loggedNoted under thread 3Own suggestion, with a non-JSON 503 tooInline 3
aria-label joins two translated strings—Optional nit, repo uses one key with a parameterOptional nit
Unit test asserts a test id nothing rendersSeen, not filed (no-nit rule)Optional nitOptional nit
CI token spec red: image alpha.7 has no 507Yes, not filedYes, as a questionNote to you, not posted
"Chat not found" 404 shows "Tokens used: 0"Checked: accurate for a chat with nothing spentMentioned only for the wrong log lineDropped
Look-only (cursor, icon, copy)—Four itemsDesigner list below
CostIn session, about 45 min including setup and the 13.62 detourFresh agent, 11 min, 50 tool calls, ~190k tokens

New in a76d922 and ca32860

1

The partial-data warning only reaches mouse users

Pass APass B
Suggestion · ui

The icon-alert-alt carries the whole message in a hover tooltip. It has no accessible name and can't take focus: the AX tree has an empty text node for it, Tab from the count skips it, and the button is announced "Tokens used: 6K in total" with nothing about the count being incomplete. axe stays quiet because an icon without a role isn't flagged.

The "Token usage not available" label does the same with its reason, but that follows the footer's existing model label (LlmModelLabel.vue), so it isn't filed. The partial case is different: there is no visible text at all.

Partial icon next to the count, tooltip about partial data
Only on hover (stub: 3 calls, 1 unreported).
2

The spinner never stops when the chat can't start

Pass APass B
Suggestion · ui, real

Usage is null until a chat id exists, and the new template shows null as loading. On 13.62 today the panel says "active LLM not specified" and "Connection closed", and the footer still shows "Tokens used:" with the spinner after 30 seconds. Before this round it read "Tokens used: 0".

The PR description lists the spinner for "chat not ready / endpoint call ongoing"; a chat that errored never gets ready. It's a state question he partly put to UX, so it's your call whether it goes in.

Chat panel with a configuration error, Connection closed, and a spinning token usage footer
Real 13.62, no stubs, 30 s after opening.
3

Every failed usage call logs the wrong error

Pass APass B
Suggestion · ui

The body is read with data.json() before the status check, so the error branch's data.text() always throws "body stream already read". A 500 logs that TypeError instead of the agent's message, and a non-JSON 503 from the service proxy throws a SyntaxError even earlier. Seen in the console with the stubbed 500.

4

The button name joins two translated strings

Pass B
Optional nit

Other dynamic aria-labels in the repo use one key with a parameter (ui-tools-config/index.vue:456, Preview.vue:47), which lets a translation order the words.

5
Optional nit

Nothing renders content-partial, and the test title above says "in the label and in the popover" though the popover has no warning.

For the designer, not in the review

torchiaf already asked oboc-sts to approve the new states, so these stay off GitHub:

Checked, and not checked

Not checked:

What I'd post

A Comment review: one reply on thread 3, three inline comments, two optional nits. No replies on threads 1 and 4 (UX's call). Thread 2 you can resolve.

Review body

Thanks, the missing endpoint and the button name work now. A few points on the new states inline.

Reply on thread 3 · pkg/rancher-ai-ui/composables/useChatMessageComposable.ts:912

The missing endpoint works now. A failed request still reads as zero, though: after 1.8K, a 500 on the next refresh shows "Tokens used: 0" with the button disabled, because the catch returns an empty object and the footer renders it as a real count.

[before / after screenshots]

Inline 1 · pkg/rancher-ai-ui/components/console/TokenUsage.vue:170

This warning only reaches mouse users: the icon has no accessible name and can't take focus, so a screen reader hears "Tokens used: 6K in total" with nothing about the count being incomplete.

Inline 2 · pkg/rancher-ai-ui/components/console/TokenUsage.vue:110

When the chat can't start, this spinner never stops. With "active LLM not specified" and "Connection closed", the footer still shows "Tokens used:" spinning after 30 seconds, so a chat that failed looks like a count on its way.

[screenshot]

Inline 3 · pkg/rancher-ai-ui/composables/useAIAgentApiComposable.ts:412

The body is read here before the status check, so the `data.text()` below always throws "body stream already read": a failed request logs that TypeError instead of the agent's error.

Optional nit · pkg/rancher-ai-ui/components/console/TokenUsage.vue:137

Nit: this name joins two translated strings; the other dynamic aria-labels here use one key with a parameter.

Optional nit · pkg/rancher-ai-ui/components/console/__tests__/TokenUsage.test.ts:151

Nit: nothing renders `content-partial`, so this can't fail, and the test name above mentions a popover warning that isn't there.