agent: Add token count in the thread view (#28037)

This PR adds the token count to the active thread view. It doesn't
behaves quite like Assistant 1 where it updates as you type, though; it
updates after you submit the message.

<img
src="https://github.com/user-attachments/assets/82d2a180-554a-43ee-b776-3743359b609b"
width="700" />

---

Release Notes:

- agent: Add token count in the thread view

---------

Co-authored-by: Agus Zubiaga <hi@aguz.me>
This commit is contained in:
Danilo Leal 2025-04-03 15:43:58 -03:00 committed by GitHub
parent e5b347b03a
commit b9724d9cbe
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 132 additions and 27 deletions

View file

@ -95,6 +95,12 @@ pub struct TokenUsage {
pub cache_read_input_tokens: u32,
}
impl TokenUsage {
pub fn total_tokens(&self) -> u32 {
self.input_tokens + self.output_tokens
}
}
impl Add<TokenUsage> for TokenUsage {
type Output = Self;