task: Add re-run task button to terminal title (#12379)

Release Notes:

- Added re-run task button to terminal title.

Close #12277

## Demo


https://github.com/zed-industries/zed/assets/5518/4cd05fa5-4255-412b-8583-68e22f86561e

---------

Co-authored-by: Piotr Osiewicz <piotr@zed.dev>
This commit is contained in:
Jason Lee 2024-05-29 17:40:43 +08:00 committed by GitHub
parent 36d0b71f27
commit 3c6c850390
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 77 additions and 16 deletions

View file

@ -9,7 +9,7 @@ use workspace::{tasks::schedule_resolved_task, Workspace};
mod modal;
mod settings;
pub use modal::Spawn;
pub use modal::{Rerun, Spawn};
pub fn init(cx: &mut AppContext) {
settings::TaskSettings::register(cx);
@ -20,7 +20,10 @@ pub fn init(cx: &mut AppContext) {
.register_action(move |workspace, action: &modal::Rerun, cx| {
if let Some((task_source_kind, mut last_scheduled_task)) =
workspace.project().update(cx, |project, cx| {
project.task_inventory().read(cx).last_scheduled_task()
project
.task_inventory()
.read(cx)
.last_scheduled_task(action.task_id.as_ref())
})
{
if action.reevaluate_context {

View file

@ -9,7 +9,7 @@ use gpui::{
};
use picker::{highlighted_match_with_paths::HighlightedText, Picker, PickerDelegate};
use project::{Project, TaskSourceKind};
use task::{ResolvedTask, TaskContext, TaskTemplate};
use task::{ResolvedTask, TaskContext, TaskId, TaskTemplate};
use ui::{
div, h_flex, v_flex, ActiveTheme, Button, ButtonCommon, ButtonSize, Clickable, Color,
FluentBuilder as _, Icon, IconButton, IconButtonShape, IconName, IconSize, IntoElement,
@ -54,6 +54,9 @@ pub struct Rerun {
/// 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]);