Cancel workflow step automatically when moving outside <step> tag (#15842)

Also, open edit suggestions automatically as soon as the edit step is
resolved.

Release Notes:

- N/A
This commit is contained in:
Antonio Scandurra 2024-08-06 11:30:09 +02:00 committed by GitHub
parent 7b5fdcee7f
commit 44ae9efb27
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 234 additions and 118 deletions

View file

@ -604,7 +604,7 @@ impl InlineAssistant {
}
}
fn finish_assist(&mut self, assist_id: InlineAssistId, undo: bool, cx: &mut WindowContext) {
pub fn finish_assist(&mut self, assist_id: InlineAssistId, undo: bool, cx: &mut WindowContext) {
if let Some(assist) = self.assists.get(&assist_id) {
let assist_group_id = assist.group_id;
if self.assist_groups[&assist_group_id].linked {
@ -715,8 +715,7 @@ impl InlineAssistant {
}
fn focus_assist(&mut self, assist_id: InlineAssistId, cx: &mut WindowContext) {
let assist = &self.assists[&assist_id];
let Some(editor) = assist.editor.upgrade() else {
let Some(assist) = self.assists.get(&assist_id) else {
return;
};
@ -729,6 +728,17 @@ impl InlineAssistant {
});
}
self.scroll_to_assist(assist_id, cx);
}
pub fn scroll_to_assist(&mut self, assist_id: InlineAssistId, cx: &mut WindowContext) {
let Some(assist) = self.assists.get(&assist_id) else {
return;
};
let Some(editor) = assist.editor.upgrade() else {
return;
};
let position = assist.range.start;
editor.update(cx, |editor, cx| {
editor.change_selections(None, cx, |selections| {
@ -844,6 +854,20 @@ impl InlineAssistant {
assist.codegen.update(cx, |codegen, cx| codegen.stop(cx));
}
pub fn status_for_assist(
&self,
assist_id: InlineAssistId,
cx: &WindowContext,
) -> Option<CodegenStatus> {
let assist = self.assists.get(&assist_id)?;
match &assist.codegen.read(cx).status {
CodegenStatus::Idle => Some(CodegenStatus::Idle),
CodegenStatus::Pending => Some(CodegenStatus::Pending),
CodegenStatus::Done => Some(CodegenStatus::Done),
CodegenStatus::Error(error) => Some(CodegenStatus::Error(anyhow!("{:?}", error))),
}
}
fn update_editor_highlights(&self, editor: &View<Editor>, cx: &mut WindowContext) {
let mut gutter_pending_ranges = Vec::new();
let mut gutter_transformed_ranges = Vec::new();
@ -2000,7 +2024,7 @@ pub struct Codegen {
_subscription: gpui::Subscription,
}
enum CodegenStatus {
pub enum CodegenStatus {
Idle,
Pending,
Done,