diff --git a/assets/icons/play.svg b/assets/icons/play.svg
index 2fc2a23aa9..2481bda7d6 100644
--- a/assets/icons/play.svg
+++ b/assets/icons/play.svg
@@ -1 +1,3 @@
-
+
diff --git a/crates/assistant/src/terminal_inline_assistant.rs b/crates/assistant/src/terminal_inline_assistant.rs
index 699786f4cc..479925b060 100644
--- a/crates/assistant/src/terminal_inline_assistant.rs
+++ b/crates/assistant/src/terminal_inline_assistant.rs
@@ -157,11 +157,11 @@ impl TerminalInlineAssistant {
PromptEditorEvent::StopRequested => {
self.stop_assist(assist_id, cx);
}
- PromptEditorEvent::ConfirmRequested => {
- self.finish_assist(assist_id, false, cx);
+ PromptEditorEvent::ConfirmRequested { execute } => {
+ self.finish_assist(assist_id, false, *execute, cx);
}
PromptEditorEvent::CancelRequested => {
- self.finish_assist(assist_id, true, cx);
+ self.finish_assist(assist_id, true, false, cx);
}
PromptEditorEvent::DismissRequested => {
self.dismiss_assist(assist_id, cx);
@@ -292,6 +292,7 @@ impl TerminalInlineAssistant {
&mut self,
assist_id: TerminalInlineAssistId,
undo: bool,
+ execute: bool,
cx: &mut WindowContext,
) {
self.dismiss_assist(assist_id, cx);
@@ -307,7 +308,7 @@ impl TerminalInlineAssistant {
assist.codegen.update(cx, |codegen, cx| {
if undo {
codegen.undo(cx);
- } else {
+ } else if execute {
codegen.complete(cx);
}
});
@@ -423,7 +424,7 @@ impl TerminalInlineAssist {
}
if assist.prompt_editor.is_none() {
- this.finish_assist(assist_id, false, cx);
+ this.finish_assist(assist_id, false, false, cx);
}
}
})
@@ -436,7 +437,7 @@ impl TerminalInlineAssist {
enum PromptEditorEvent {
StartRequested,
StopRequested,
- ConfirmRequested,
+ ConfirmRequested { execute: bool },
CancelRequested,
DismissRequested,
Resized { height_in_lines: u8 },
@@ -509,15 +510,15 @@ impl Render for PromptEditor {
]
}
CodegenStatus::Error(_) | CodegenStatus::Done => {
- vec![
- IconButton::new("cancel", IconName::Close)
- .icon_color(Color::Muted)
- .shape(IconButtonShape::Square)
- .tooltip(|cx| Tooltip::for_action("Cancel Assist", &menu::Cancel, cx))
- .on_click(
- cx.listener(|_, _, cx| cx.emit(PromptEditorEvent::CancelRequested)),
- ),
- if self.edited_since_done {
+ let cancel = IconButton::new("cancel", IconName::Close)
+ .icon_color(Color::Muted)
+ .shape(IconButtonShape::Square)
+ .tooltip(|cx| Tooltip::for_action("Cancel Assist", &menu::Cancel, cx))
+ .on_click(cx.listener(|_, _, cx| cx.emit(PromptEditorEvent::CancelRequested)));
+
+ if self.edited_since_done {
+ vec![
+ cancel,
IconButton::new("restart", IconName::RotateCw)
.icon_color(Color::Info)
.shape(IconButtonShape::Square)
@@ -531,19 +532,35 @@ impl Render for PromptEditor {
})
.on_click(cx.listener(|_, _, cx| {
cx.emit(PromptEditorEvent::StartRequested);
- }))
- } else {
+ })),
+ ]
+ } else {
+ vec![
+ cancel,
+ IconButton::new("accept", IconName::Check)
+ .icon_color(Color::Info)
+ .shape(IconButtonShape::Square)
+ .tooltip(|cx| {
+ Tooltip::for_action("Accept Generated Command", &menu::Confirm, cx)
+ })
+ .on_click(cx.listener(|_, _, cx| {
+ cx.emit(PromptEditorEvent::ConfirmRequested { execute: false });
+ })),
IconButton::new("confirm", IconName::Play)
.icon_color(Color::Info)
.shape(IconButtonShape::Square)
.tooltip(|cx| {
- Tooltip::for_action("Execute generated command", &menu::Confirm, cx)
+ Tooltip::for_action(
+ "Execute Generated Command",
+ &menu::SecondaryConfirm,
+ cx,
+ )
})
.on_click(cx.listener(|_, _, cx| {
- cx.emit(PromptEditorEvent::ConfirmRequested);
- }))
- },
- ]
+ cx.emit(PromptEditorEvent::ConfirmRequested { execute: true });
+ })),
+ ]
+ }
}
};
@@ -555,6 +572,7 @@ impl Render for PromptEditor {
.h_full()
.w_full()
.on_action(cx.listener(Self::confirm))
+ .on_action(cx.listener(Self::secondary_confirm))
.on_action(cx.listener(Self::cancel))
.on_action(cx.listener(Self::move_up))
.on_action(cx.listener(Self::move_down))
@@ -605,7 +623,7 @@ impl Render for PromptEditor {
.child(div().flex_1().child(self.render_prompt_editor(cx)))
.child(
h_flex()
- .gap_2()
+ .gap_1()
.pr_4()
.children(self.render_token_count(cx))
.children(buttons),
@@ -809,7 +827,7 @@ impl PromptEditor {
if self.edited_since_done {
cx.emit(PromptEditorEvent::StartRequested);
} else {
- cx.emit(PromptEditorEvent::ConfirmRequested);
+ cx.emit(PromptEditorEvent::ConfirmRequested { execute: false });
}
}
CodegenStatus::Error(_) => {
@@ -818,6 +836,12 @@ impl PromptEditor {
}
}
+ fn secondary_confirm(&mut self, _: &menu::SecondaryConfirm, cx: &mut ViewContext) {
+ if matches!(self.codegen.read(cx).status, CodegenStatus::Done) {
+ cx.emit(PromptEditorEvent::ConfirmRequested { execute: true });
+ }
+ }
+
fn move_up(&mut self, _: &MoveUp, cx: &mut ViewContext) {
if let Some(ix) = self.prompt_history_ix {
if ix > 0 {