Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
chore: Sever terminal_view <-> tasks_ui dependency (#20946)
Piotr Osiewicz536d7e53553d
diff --git a/Cargo.lock b/Cargo.lockindex a8ff3abe015..f7587449b1e 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -12196,6 +12196,7 @@ dependencies = ["ui","util","workspace",+ "zed_actions",][[package]]@@ -12299,7 +12300,6 @@ dependencies = ["shellexpand 2.1.2","smol","task",- "tasks_ui","terminal","theme","ui",diff --git a/crates/tasks_ui/Cargo.toml b/crates/tasks_ui/Cargo.tomlindex 265755319b8..528d2383293 100644--- a/crates/tasks_ui/Cargo.toml+++ b/crates/tasks_ui/Cargo.toml@@ -25,7 +25,7 @@ ui.workspace = trueutil.workspace = trueworkspace.workspace = truelanguage.workspace = true-+zed_actions.workspace = true[dev-dependencies]editor = { workspace = true, features = ["test-support"] }diff --git a/crates/tasks_ui/src/lib.rs b/crates/tasks_ui/src/lib.rsindex 38b15403e27..02ced4f4791 100644--- a/crates/tasks_ui/src/lib.rs+++ b/crates/tasks_ui/src/lib.rs@@ -3,6 +3,7 @@ use editor::{tasks::task_context, Editor};use gpui::{AppContext, Task as AsyncTask, ViewContext, WindowContext};use modal::TasksModal;use project::{Location, WorktreeId};+use task::TaskId;use workspace::tasks::schedule_task;use workspace::{tasks::schedule_resolved_task, Workspace};@@ -25,9 +26,13 @@ pub fn init(cx: &mut AppContext) {.read(cx).task_inventory().and_then(|inventory| {- inventory- .read(cx)- .last_scheduled_task(action.task_id.as_ref())+ inventory.read(cx).last_scheduled_task(+ action+ .task_id+ .as_ref()+ .map(|id| TaskId(id.clone()))+ .as_ref(),+ )}){if action.reevaluate_context {diff --git a/crates/tasks_ui/src/modal.rs b/crates/tasks_ui/src/modal.rsindex 3de116702a4..3c7b767d5cb 100644--- a/crates/tasks_ui/src/modal.rs+++ b/crates/tasks_ui/src/modal.rs@@ -3,13 +3,13 @@ use std::sync::Arc;use crate::active_item_selection_properties;use fuzzy::{StringMatch, StringMatchCandidate};use gpui::{- impl_actions, rems, Action, AnyElement, AppContext, DismissEvent, EventEmitter, FocusableView,+ rems, Action, AnyElement, AppContext, DismissEvent, EventEmitter, FocusableView,InteractiveElement, Model, ParentElement, Render, SharedString, Styled, Subscription, Task,View, ViewContext, VisualContext, WeakView,};use picker::{highlighted_match_with_paths::HighlightedText, Picker, PickerDelegate};use project::{task_store::TaskStore, TaskSourceKind};-use task::{ResolvedTask, TaskContext, TaskId, TaskTemplate};+use task::{ResolvedTask, TaskContext, TaskTemplate};use ui::{div, h_flex, v_flex, ActiveTheme, Button, ButtonCommon, ButtonSize, Clickable, Color,FluentBuilder as _, Icon, IconButton, IconButtonShape, IconName, IconSize, IntoElement,@@ -18,48 +18,7 @@ use ui::{};use util::ResultExt;use workspace::{tasks::schedule_resolved_task, ModalView, Workspace};--use serde::Deserialize;--/// Spawn a task with name or open tasks modal-#[derive(PartialEq, Clone, Deserialize, Default)]-pub struct Spawn {- #[serde(default)]- /// Name of the task to spawn.- /// If it is not set, a modal with a list of available tasks is opened instead.- /// Defaults to None.- pub task_name: Option<String>,-}--impl Spawn {- pub fn modal() -> Self {- Self { task_name: None }- }-}--/// Rerun last task-#[derive(PartialEq, Clone, Deserialize, Default)]-pub struct Rerun {- /// Controls whether the task context is reevaluated prior to execution of a task.- /// If it is not, environment variables such as ZED_COLUMN, ZED_FILE are gonna be the same as in the last execution of a task- /// If it is, these variables will be updated to reflect current state of editor at the time task::Rerun is executed.- /// default: false- #[serde(default)]- pub reevaluate_context: bool,- /// Overrides `allow_concurrent_runs` property of the task being reran.- /// Default: null- #[serde(default)]- pub allow_concurrent_runs: Option<bool>,- /// Overrides `use_new_terminal` property of the task being reran.- /// Default: null- #[serde(default)]- pub use_new_terminal: Option<bool>,-- /// If present, rerun the task with this ID, otherwise rerun the last task.- pub task_id: Option<TaskId>,-}--impl_actions!(task, [Rerun, Spawn]);+pub use zed_actions::{Rerun, Spawn};/// A modal used to spawn new tasks.pub(crate) struct TasksModalDelegate {diff --git a/crates/terminal_view/Cargo.toml b/crates/terminal_view/Cargo.tomlindex 09b0b0d2d5d..64b979cdd69 100644--- a/crates/terminal_view/Cargo.toml+++ b/crates/terminal_view/Cargo.toml@@ -24,7 +24,6 @@ itertools.workspace = truelanguage.workspace = trueproject.workspace = truetask.workspace = true-tasks_ui.workspace = truesearch.workspace = trueserde.workspace = trueserde_json.workspace = truediff --git a/crates/terminal_view/src/terminal_panel.rs b/crates/terminal_view/src/terminal_panel.rsindex 6d64ac1a48c..2ca7561bdbe 100644--- a/crates/terminal_view/src/terminal_panel.rs+++ b/crates/terminal_view/src/terminal_panel.rs@@ -218,7 +218,7 @@ impl TerminalPanel {// context menu will be gone the moment we spawn the modal..action("Spawn task",- tasks_ui::Spawn::modal().boxed_clone(),+ zed_actions::Spawn::modal().boxed_clone(),)});diff --git a/crates/terminal_view/src/terminal_view.rs b/crates/terminal_view/src/terminal_view.rsindex 6a23e45f549..21d20599b9a 100644--- a/crates/terminal_view/src/terminal_view.rs+++ b/crates/terminal_view/src/terminal_view.rs@@ -1044,8 +1044,8 @@ impl Item for TerminalView {.shape(ui::IconButtonShape::Square).tooltip(|cx| Tooltip::text("Rerun task", cx)).on_click(move |_, cx| {- cx.dispatch_action(Box::new(tasks_ui::Rerun {- task_id: Some(task_id.clone()),+ cx.dispatch_action(Box::new(zed_actions::Rerun {+ task_id: Some(task_id.0.clone()),allow_concurrent_runs: Some(true),use_new_terminal: Some(false),reevaluate_context: false,diff --git a/crates/zed_actions/src/lib.rs b/crates/zed_actions/src/lib.rsindex 2f33583429f..53f5b202a86 100644--- a/crates/zed_actions/src/lib.rs+++ b/crates/zed_actions/src/lib.rs@@ -58,3 +58,43 @@ pub struct OpenRecent {}gpui::impl_actions!(projects, [OpenRecent]);gpui::actions!(projects, [OpenRemote]);++/// Spawn a task with name or open tasks modal+#[derive(PartialEq, Clone, Deserialize, Default)]+pub struct Spawn {+ #[serde(default)]+ /// Name of the task to spawn.+ /// If it is not set, a modal with a list of available tasks is opened instead.+ /// Defaults to None.+ pub task_name: Option<String>,+}++impl Spawn {+ pub fn modal() -> Self {+ Self { task_name: None }+ }+}++/// Rerun last task+#[derive(PartialEq, Clone, Deserialize, Default)]+pub struct Rerun {+ /// Controls whether the task context is reevaluated prior to execution of a task.+ /// If it is not, environment variables such as ZED_COLUMN, ZED_FILE are gonna be the same as in the last execution of a task+ /// If it is, these variables will be updated to reflect current state of editor at the time task::Rerun is executed.+ /// default: false+ #[serde(default)]+ pub reevaluate_context: bool,+ /// Overrides `allow_concurrent_runs` property of the task being reran.+ /// Default: null+ #[serde(default)]+ pub allow_concurrent_runs: Option<bool>,+ /// Overrides `use_new_terminal` property of the task being reran.+ /// Default: null+ #[serde(default)]+ pub use_new_terminal: Option<bool>,++ /// If present, rerun the task with this ID, otherwise rerun the last task.+ pub task_id: Option<String>,+}++impl_actions!(task, [Spawn, Rerun]);