agent_ui: Fix token count not getting shown in the TextThread (#34485)
Closes #34319 In this pr: https://github.com/zed-industries/zed/pull/33462 there was check added for early return for active_thread and message_editor as those are not present in the TextThread and only available in the Thread the token count was not getting triggered for TextThread this pr fixes that regression by moving the logic specific to Thread inside of thread view match. <img width="3024" height="1886" alt="CleanShot 2025-07-15 at 23 50 18@2x" src="https://github.com/user-attachments/assets/bd74ae8b-6c37-4cdd-ab95-d3c253b8a948" /> Release Notes: - Fix token count not getting shown in the TextThread
This commit is contained in:
parent
406ffb1e20
commit
875c86e3ef
1 changed files with 27 additions and 30 deletions
|
@ -1975,19 +1975,14 @@ impl AgentPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_token_count(&self, cx: &App) -> Option<AnyElement> {
|
fn render_token_count(&self, cx: &App) -> Option<AnyElement> {
|
||||||
let (active_thread, message_editor) = match &self.active_view {
|
match &self.active_view {
|
||||||
ActiveView::Thread {
|
ActiveView::Thread {
|
||||||
thread,
|
thread,
|
||||||
message_editor,
|
message_editor,
|
||||||
..
|
..
|
||||||
} => (thread.read(cx), message_editor.read(cx)),
|
} => {
|
||||||
ActiveView::AcpThread { .. } => {
|
let active_thread = thread.read(cx);
|
||||||
return None;
|
let message_editor = message_editor.read(cx);
|
||||||
}
|
|
||||||
ActiveView::TextThread { .. } | ActiveView::History | ActiveView::Configuration => {
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let editor_empty = message_editor.is_editor_fully_empty(cx);
|
let editor_empty = message_editor.is_editor_fully_empty(cx);
|
||||||
|
|
||||||
|
@ -2000,23 +1995,25 @@ impl AgentPanel {
|
||||||
let conversation_token_usage = thread.total_token_usage()?;
|
let conversation_token_usage = thread.total_token_usage()?;
|
||||||
|
|
||||||
let (total_token_usage, is_estimating) =
|
let (total_token_usage, is_estimating) =
|
||||||
if let Some((editing_message_id, unsent_tokens)) = active_thread.editing_message_id() {
|
if let Some((editing_message_id, unsent_tokens)) =
|
||||||
|
active_thread.editing_message_id()
|
||||||
|
{
|
||||||
let combined = thread
|
let combined = thread
|
||||||
.token_usage_up_to_message(editing_message_id)
|
.token_usage_up_to_message(editing_message_id)
|
||||||
.add(unsent_tokens);
|
.add(unsent_tokens);
|
||||||
|
|
||||||
(combined, unsent_tokens > 0)
|
(combined, unsent_tokens > 0)
|
||||||
} else {
|
} else {
|
||||||
let unsent_tokens = message_editor.last_estimated_token_count().unwrap_or(0);
|
let unsent_tokens =
|
||||||
|
message_editor.last_estimated_token_count().unwrap_or(0);
|
||||||
let combined = conversation_token_usage.add(unsent_tokens);
|
let combined = conversation_token_usage.add(unsent_tokens);
|
||||||
|
|
||||||
(combined, unsent_tokens > 0)
|
(combined, unsent_tokens > 0)
|
||||||
};
|
};
|
||||||
|
|
||||||
let is_waiting_to_update_token_count = message_editor.is_waiting_to_update_token_count();
|
let is_waiting_to_update_token_count =
|
||||||
|
message_editor.is_waiting_to_update_token_count();
|
||||||
|
|
||||||
match &self.active_view {
|
|
||||||
ActiveView::Thread { .. } => {
|
|
||||||
if total_token_usage.total == 0 {
|
if total_token_usage.total == 0 {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue