Fix token count not appearing for the first message (#30035)
Release Notes: - N/A Co-authored-by: Ben Brandt <benjamin.j.brandt@gmail.com>
This commit is contained in:
co-authored by
Ben Brandt
parent
5002156e32
commit
0fdc04532a
@@ -1462,6 +1462,7 @@ impl AssistantPanel {
|
||||
let thread = active_thread.thread().read(cx);
|
||||
let thread_id = thread.id().clone();
|
||||
let is_empty = active_thread.is_empty();
|
||||
let editor_empty = self.message_editor.read(cx).is_editor_fully_empty(cx);
|
||||
let last_usage = active_thread.thread().read(cx).last_usage().or_else(|| {
|
||||
maybe!({
|
||||
let amount = user_store.model_request_usage_amount()?;
|
||||
@@ -1484,7 +1485,7 @@ impl AssistantPanel {
|
||||
let account_url = zed_urls::account_url(cx);
|
||||
|
||||
let show_token_count = match &self.active_view {
|
||||
ActiveView::Thread { .. } => !is_empty,
|
||||
ActiveView::Thread { .. } => !is_empty || !editor_empty,
|
||||
ActiveView::PromptEditor { .. } => true,
|
||||
_ => false,
|
||||
};
|
||||
|
||||
@@ -315,6 +315,10 @@ impl MessageEditor {
|
||||
self.editor.read(cx).text(cx).trim().is_empty()
|
||||
}
|
||||
|
||||
pub fn is_editor_fully_empty(&self, cx: &App) -> bool {
|
||||
self.editor.read(cx).is_empty(cx)
|
||||
}
|
||||
|
||||
fn send_to_model(&mut self, window: &mut Window, cx: &mut Context<Self>) {
|
||||
let Some(ConfiguredModel { model, provider }) = self
|
||||
.thread
|
||||
|
||||
@@ -267,7 +267,7 @@ impl DetailedSummaryState {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
#[derive(Default, Debug)]
|
||||
pub struct TotalTokenUsage {
|
||||
pub total: usize,
|
||||
pub max: usize,
|
||||
|
||||
Reference in New Issue
Block a user