assistant_tool: Pass an Entity<Project> to Tool::run (#26312)

This PR updates the `Tool::run` method to take an `Entity<Project>`
instead of a `WeakEntity<Project>`.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers
2025-03-07 23:30:56 +00:00
committed by GitHub
parent 921c24e274
commit e70d0edfac
7 changed files with 20 additions and 30 deletions
+2 -5
View File
@@ -4,7 +4,7 @@ use project::Project;
pub(crate) use session::*;
use assistant_tool::{Tool, ToolRegistry};
use gpui::{App, AppContext as _, Task, WeakEntity};
use gpui::{App, AppContext as _, Entity, Task};
use schemars::JsonSchema;
use serde::Deserialize;
use std::sync::Arc;
@@ -38,16 +38,13 @@ impl Tool for ScriptingTool {
fn run(
self: Arc<Self>,
input: serde_json::Value,
project: WeakEntity<Project>,
project: Entity<Project>,
cx: &mut App,
) -> Task<anyhow::Result<String>> {
let input = match serde_json::from_value::<ScriptingToolInput>(input) {
Err(err) => return Task::ready(Err(err.into())),
Ok(input) => input,
};
let Some(project) = project.upgrade() else {
return Task::ready(Err(anyhow::anyhow!("project dropped")));
};
let session = cx.new(|cx| Session::new(project, cx));
let lua_script = input.lua_script;