Move token count in prompt editor (#13524)

Moves the token count back up to the editor header.

Release Notes:

- N/A
This commit is contained in:
Nate Butler 2024-06-25 16:10:05 -04:00 committed by GitHub
parent e5d1cf84cf
commit 9f88460870
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -841,6 +841,42 @@ impl PromptLibrary {
h_flex()
.h_full()
.gap(Spacing::XXLarge.rems(cx))
.children(prompt_editor.token_count.map(
|token_count| {
let token_count: SharedString =
token_count.to_string().into();
let label_token_count: SharedString =
token_count.to_string().into();
h_flex()
.id("token_count")
.tooltip(move |cx| {
let token_count =
token_count.clone();
Tooltip::with_meta(
format!(
"{} tokens",
token_count.clone()
),
None,
format!(
"Model: {}",
current_model
.display_name()
),
cx,
)
})
.child(
Label::new(format!(
"{} tokens",
label_token_count.clone()
))
.color(Color::Muted),
)
},
))
.child(
IconButton::new(
"delete-prompt",
@ -920,38 +956,7 @@ impl PromptLibrary {
.on_action(cx.listener(Self::move_up_from_body))
.flex_grow()
.h_full()
.child(prompt_editor.body_editor.clone())
.children(prompt_editor.token_count.map(|token_count| {
let token_count: SharedString = token_count.to_string().into();
let label_token_count: SharedString =
token_count.to_string().into();
h_flex()
.id("token_count")
.absolute()
.bottom_1()
.right_4()
.flex_initial()
.px_2()
.py_1()
.tooltip(move |cx| {
let token_count = token_count.clone();
Tooltip::with_meta(
format!("{} tokens", token_count.clone()),
None,
format!("Model: {}", current_model.display_name()),
cx,
)
})
.child(
Label::new(format!(
"{} tokens",
label_token_count.clone()
))
.color(Color::Muted),
)
})),
.child(prompt_editor.body_editor.clone()),
),
)
}))