Truncate tool call labels to one line
This commit is contained in:
parent
f179eb9dd5
commit
3f87801fe0
1 changed files with 12 additions and 9 deletions
|
@ -183,16 +183,15 @@ impl ToolCall {
|
||||||
language_registry: Arc<LanguageRegistry>,
|
language_registry: Arc<LanguageRegistry>,
|
||||||
cx: &mut App,
|
cx: &mut App,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
|
let title = if let Some((first_line, _)) = tool_call.title.split_once("\n") {
|
||||||
|
first_line.to_owned() + "…"
|
||||||
|
} else {
|
||||||
|
tool_call.title
|
||||||
|
};
|
||||||
Self {
|
Self {
|
||||||
id: tool_call.id,
|
id: tool_call.id,
|
||||||
label: cx.new(|cx| {
|
label: cx
|
||||||
Markdown::new(
|
.new(|cx| Markdown::new(title.into(), Some(language_registry.clone()), None, cx)),
|
||||||
tool_call.title.into(),
|
|
||||||
Some(language_registry.clone()),
|
|
||||||
None,
|
|
||||||
cx,
|
|
||||||
)
|
|
||||||
}),
|
|
||||||
kind: tool_call.kind,
|
kind: tool_call.kind,
|
||||||
content: tool_call
|
content: tool_call
|
||||||
.content
|
.content
|
||||||
|
@ -233,7 +232,11 @@ impl ToolCall {
|
||||||
|
|
||||||
if let Some(title) = title {
|
if let Some(title) = title {
|
||||||
self.label.update(cx, |label, cx| {
|
self.label.update(cx, |label, cx| {
|
||||||
label.replace(title, cx);
|
if let Some((first_line, _)) = title.split_once("\n") {
|
||||||
|
label.replace(first_line.to_owned() + "…", cx)
|
||||||
|
} else {
|
||||||
|
label.replace(title, cx);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue