diff --git a/assets/icons/rotate_cw.svg b/assets/icons/rotate_cw.svg index 019367745f..2098de38c2 100644 --- a/assets/icons/rotate_cw.svg +++ b/assets/icons/rotate_cw.svg @@ -1 +1,4 @@ - + + + + diff --git a/assets/keymaps/default-linux.json b/assets/keymaps/default-linux.json index f52ddfcc26..f93c459ec6 100644 --- a/assets/keymaps/default-linux.json +++ b/assets/keymaps/default-linux.json @@ -17,6 +17,7 @@ "escape": "menu::Cancel", "ctrl-escape": "menu::Cancel", "ctrl-c": "menu::Cancel", + "alt-shift-enter": "menu::Restart", "alt-enter": ["picker::ConfirmInput", { "secondary": false }], "ctrl-alt-enter": ["picker::ConfirmInput", { "secondary": true }], "ctrl-shift-w": "workspace::CloseWindow", diff --git a/assets/keymaps/default-macos.json b/assets/keymaps/default-macos.json index 1ec898a84b..f821bc982d 100644 --- a/assets/keymaps/default-macos.json +++ b/assets/keymaps/default-macos.json @@ -24,6 +24,7 @@ "cmd-escape": "menu::Cancel", "ctrl-escape": "menu::Cancel", "ctrl-c": "menu::Cancel", + "alt-shift-enter": "menu::Restart", "cmd-shift-w": "workspace::CloseWindow", "shift-escape": "workspace::ToggleZoom", "cmd-o": "workspace::Open", diff --git a/crates/assistant/src/inline_assistant.rs b/crates/assistant/src/inline_assistant.rs index acca7ae1af..9c95b09854 100644 --- a/crates/assistant/src/inline_assistant.rs +++ b/crates/assistant/src/inline_assistant.rs @@ -1441,6 +1441,15 @@ impl Render for PromptEditor { ] } CodegenStatus::Error(_) | CodegenStatus::Done => { + let must_rerun = + self.edited_since_done || matches!(status, CodegenStatus::Error(_)); + // when accept button isn't visible, then restart maps to confirm + // when accept button is visible, then restart must be mapped to an alternate keyboard shortcut + let restart_key: &dyn gpui::Action = if must_rerun { + &menu::Confirm + } else { + &menu::Restart + }; vec![ IconButton::new("cancel", IconName::Close) .icon_color(Color::Muted) @@ -1450,23 +1459,22 @@ impl Render for PromptEditor { cx.listener(|_, _, cx| cx.emit(PromptEditorEvent::CancelRequested)), ) .into_any_element(), - if self.edited_since_done || matches!(status, CodegenStatus::Error(_)) { - IconButton::new("restart", IconName::RotateCw) - .icon_color(Color::Info) - .shape(IconButtonShape::Square) - .tooltip(|cx| { - Tooltip::with_meta( - "Restart Transformation", - Some(&menu::Confirm), - "Changes will be discarded", - cx, - ) - }) - .on_click(cx.listener(|_, _, cx| { - cx.emit(PromptEditorEvent::StartRequested); - })) - .into_any_element() - } else { + IconButton::new("restart", IconName::RotateCw) + .icon_color(Color::Muted) + .shape(IconButtonShape::Square) + .tooltip(|cx| { + Tooltip::with_meta( + "Regenerate Transformation", + Some(restart_key), + "Current change will be discarded", + cx, + ) + }) + .on_click(cx.listener(|_, _, cx| { + cx.emit(PromptEditorEvent::StartRequested); + })) + .into_any_element(), + if !must_rerun { IconButton::new("confirm", IconName::Check) .icon_color(Color::Info) .shape(IconButtonShape::Square) @@ -1475,6 +1483,8 @@ impl Render for PromptEditor { cx.emit(PromptEditorEvent::ConfirmRequested); })) .into_any_element() + } else { + div().into_any_element() }, ] } @@ -1491,6 +1501,7 @@ impl Render for PromptEditor { .py(cx.line_height() / 2.5) .on_action(cx.listener(Self::confirm)) .on_action(cx.listener(Self::cancel)) + .on_action(cx.listener(Self::restart)) .on_action(cx.listener(Self::move_up)) .on_action(cx.listener(Self::move_down)) .capture_action(cx.listener(Self::cycle_prev)) @@ -1837,6 +1848,10 @@ impl PromptEditor { } } + fn restart(&mut self, _: &menu::Restart, cx: &mut ViewContext) { + cx.emit(PromptEditorEvent::StartRequested); + } + fn cancel(&mut self, _: &editor::actions::Cancel, cx: &mut ViewContext) { match self.codegen.read(cx).status(cx) { CodegenStatus::Idle | CodegenStatus::Done | CodegenStatus::Error(_) => { diff --git a/crates/menu/src/menu.rs b/crates/menu/src/menu.rs index 0818a6e6ff..3c5dc2521f 100644 --- a/crates/menu/src/menu.rs +++ b/crates/menu/src/menu.rs @@ -19,5 +19,6 @@ actions!( SelectNext, SelectFirst, SelectLast, + Restart ] );