assistant2: Improve Lua script rendering (#26389)

This PR improves the rendering of Lua scripts provided to the scripting
tool.

We now render them in code blocks with syntax highlighting:

<img width="1297" alt="Screenshot 2025-03-10 at 2 40 51 PM"
src="https://github.com/user-attachments/assets/def65b5c-86a8-490f-aaa5-5cc1687fe01e"
/>

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2025-03-10 14:54:03 -04:00 committed by GitHub
parent 5ecc67f2ef
commit 02e970192f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 150 additions and 23 deletions

View file

@ -20,7 +20,7 @@ use uuid::Uuid;
use crate::context::{attach_context_to_message, ContextId, ContextSnapshot};
use crate::thread_store::SavedThread;
use crate::tool_use::{ToolUse, ToolUseState};
use crate::tool_use::{PendingToolUse, ToolUse, ToolUseState};
#[derive(Debug, Clone, Copy)]
pub enum RequestKind {
@ -653,11 +653,14 @@ impl Thread {
let output = output.await;
thread
.update(&mut cx, |thread, cx| {
thread
let pending_tool_use = thread
.tool_use
.insert_tool_output(tool_use_id.clone(), output);
cx.emit(ThreadEvent::ToolFinished { tool_use_id });
cx.emit(ThreadEvent::ToolFinished {
tool_use_id,
pending_tool_use,
});
})
.ok();
}
@ -679,11 +682,14 @@ impl Thread {
let output = output.await;
thread
.update(&mut cx, |thread, cx| {
thread
let pending_tool_use = thread
.scripting_tool_use
.insert_tool_output(tool_use_id.clone(), output);
cx.emit(ThreadEvent::ToolFinished { tool_use_id });
cx.emit(ThreadEvent::ToolFinished {
tool_use_id,
pending_tool_use,
});
})
.ok();
}
@ -742,8 +748,9 @@ pub enum ThreadEvent {
ToolFinished {
#[allow(unused)]
tool_use_id: LanguageModelToolUseId,
/// The pending tool use that corresponds to this tool.
pending_tool_use: Option<PendingToolUse>,
},
ScriptFinished,
}
impl EventEmitter<ThreadEvent> for Thread {}