acp_thread: Forward token usage from PromptResponse to thread UI#53693
acp_thread: Forward token usage from PromptResponse to thread UI#53693hahahuy wants to merge 2 commits intozed-industries:mainfrom
Conversation
|
Thank you for your pull request and welcome to our community. We could not parse the GitHub identity of the following contributors: hahuy.
|
96b2b66 to
ca80822
Compare
|
We require contributors to sign our Contributor License Agreement, and we don't have @hahahuy on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'. |
|
@cla-bot check |
|
We require contributors to sign our Contributor License Agreement, and we don't have @hahahuy on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'. |
|
The cla-bot has been summoned, and re-checked this pull request! |
|
@cla-bot check |
|
We require contributors to sign our Contributor License Agreement, and we don't have @hahahuy on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'. |
|
The cla-bot has been summoned, and re-checked this pull request! |
|
@cla-bot check |
|
The cla-bot has been summoned, and re-checked this pull request! |
Extract r.usage from each PromptResponse turn and call update_token_usage() so the token count ring in the agent panel shows live data. Guard against max_tokens == 0 (ACP protocol has no context-window field) by rendering a plain "N tokens" label instead of a broken "0% • N / 0" ring. Add two gpui tests: usage populated and usage absent.
b82b1e6 to
052e81a
Compare



Fixes #53130
Summary
External ACP agents (e.g. Claude Code CLI) return token usage in
PromptResponsevia theunstable_session_usagefeature, which Zed already enables. Previously this data was discarded —token_usagestayedNoneon theAcpThread, sorender_token_usage()returned early and showed nothing.Changes:
acp_thread.rs: Extractr.usagein theOk(r)branch ofrun_turnand callupdate_token_usage()each turn.thread_view.rs: Add amax_tokens == 0branch inrender_token_usage— since the ACP protocol does not expose context window size, render a plain"N tokens"label instead of a circular progress ring (which would show meaningless"0% • N / 0").#[gpui::test]tests: one asserting usage is populated after a turn with usage data, one assertingtoken_usagestaysNonewhenPromptResponsehas no usage.Test plan
claudeCLI) and send a message"1.5k tokens") appears in the thread header after the first responsecargo test -p acp_thread test_token_usageRelease Notes: