live fixes
This commit is contained in:
@@ -1822,6 +1822,11 @@ pub enum Event {
|
||||
OpenShareSessionModal {
|
||||
open_source: SharedSessionActionSource,
|
||||
},
|
||||
ShowDeleteConversationConfirmationDialog {
|
||||
conversation_id: AIConversationId,
|
||||
conversation_title: String,
|
||||
terminal_view_id: Option<EntityId>,
|
||||
},
|
||||
OpenShareSessionDeniedModal,
|
||||
/// Used to focus and bring this session to the foreground.
|
||||
FocusSession,
|
||||
@@ -4306,6 +4311,16 @@ impl TerminalView {
|
||||
let object_uid = SyncId::from(*notebook_uid).uid();
|
||||
ctx.emit(Event::OpenGalaxyDriveObjectInPane(object_uid));
|
||||
}
|
||||
ConversationDetailsPanelEvent::ShowDeleteConfirmationDialog {
|
||||
conversation_id,
|
||||
conversation_title,
|
||||
} => {
|
||||
ctx.emit(Event::ShowDeleteConversationConfirmationDialog {
|
||||
conversation_id: *conversation_id,
|
||||
conversation_title: conversation_title.clone(),
|
||||
terminal_view_id: Some(ctx.view_id()),
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -26293,6 +26308,10 @@ impl TypedActionView for TerminalView {
|
||||
"Execute rewind to before this point in the AI conversation.".to_owned(),
|
||||
GalaxyA11yRole::ButtonRole,
|
||||
)),
|
||||
RequestDeleteCurrentConversation => Custom(AccessibilityContent::new_without_help(
|
||||
"Show confirmation dialog to delete this conversation.".to_owned(),
|
||||
GalaxyA11yRole::ButtonRole,
|
||||
)),
|
||||
SelectAIAttachedBlock(_) => Custom(AccessibilityContent::new_without_help(
|
||||
"Click on a block attached as context to this AI query.".to_owned(),
|
||||
GalaxyA11yRole::ButtonRole,
|
||||
@@ -26535,6 +26554,23 @@ impl TypedActionView for TerminalView {
|
||||
);
|
||||
}
|
||||
}
|
||||
RequestDeleteCurrentConversation => {
|
||||
let Some(conversation_id) = self.active_conversation_id(ctx).or_else(|| {
|
||||
self.ai_context_model
|
||||
.as_ref(ctx)
|
||||
.selected_conversation_id(ctx)
|
||||
}) else {
|
||||
return;
|
||||
};
|
||||
let conversation_title = self
|
||||
.selected_conversation_display_title(ctx)
|
||||
.unwrap_or_else(|| "Conversation".to_string());
|
||||
ctx.emit(Event::ShowDeleteConversationConfirmationDialog {
|
||||
conversation_id,
|
||||
conversation_title,
|
||||
terminal_view_id: Some(ctx.view_id()),
|
||||
});
|
||||
}
|
||||
CloseContextMenu => self.close_context_menu(ctx, true),
|
||||
Paste => self.paste(false, ctx),
|
||||
Copy => self.copy(ctx),
|
||||
|
||||
@@ -246,6 +246,8 @@ pub enum TerminalAction {
|
||||
exchange_id: AIAgentExchangeId,
|
||||
conversation_id: AIConversationId,
|
||||
},
|
||||
/// Ask the workspace to confirm deletion of the active conversation for this terminal view.
|
||||
RequestDeleteCurrentConversation,
|
||||
SelectAllBlocks,
|
||||
ExpandBlockSelectionAbove,
|
||||
ExpandBlockSelectionBelow,
|
||||
@@ -578,6 +580,7 @@ impl fmt::Debug for TerminalAction {
|
||||
write!(f, "OpenInputContextMenu {{ position: {position:?} }}")
|
||||
}
|
||||
InputContextMenuItem(action) => write!(f, "InputContextMenuItem({action:?})"),
|
||||
RequestDeleteCurrentConversation => f.write_str("RequestDeleteCurrentConversation"),
|
||||
SelectAllBlocks => f.write_str("SelectAllBlocks"),
|
||||
ExpandBlockSelectionAbove => f.write_str("ExpandBlockSelectionAbove"),
|
||||
ExpandBlockSelectionBelow => f.write_str("ExpandBlockSelectionBelow"),
|
||||
|
||||
@@ -708,6 +708,19 @@ impl BackingView for TerminalView {
|
||||
);
|
||||
}
|
||||
|
||||
if self.current_conversation_can_be_deleted(ctx) {
|
||||
if !items.is_empty() {
|
||||
items.push(MenuItem::Separator);
|
||||
}
|
||||
|
||||
items.push(
|
||||
MenuItemFields::new("Delete conversation")
|
||||
.with_override_text_color(Appearance::as_ref(ctx).theme().ansi_fg_red())
|
||||
.with_on_select_action(TerminalAction::RequestDeleteCurrentConversation)
|
||||
.into_item(),
|
||||
);
|
||||
}
|
||||
|
||||
items
|
||||
}
|
||||
|
||||
@@ -1003,6 +1016,23 @@ impl TerminalView {
|
||||
))
|
||||
}
|
||||
|
||||
fn current_conversation_can_be_deleted(&self, ctx: &AppContext) -> bool {
|
||||
let Some(conversation_id) = self.active_conversation_id(ctx).or_else(|| {
|
||||
self.ai_context_model
|
||||
.as_ref(ctx)
|
||||
.selected_conversation_id(ctx)
|
||||
}) else {
|
||||
return false;
|
||||
};
|
||||
|
||||
let history = BlocklistAIHistoryModel::as_ref(ctx);
|
||||
let Some(conversation) = history.conversation(&conversation_id) else {
|
||||
return false;
|
||||
};
|
||||
|
||||
!conversation.is_empty() && conversation.status().is_done()
|
||||
}
|
||||
|
||||
pub fn selected_conversation_is_empty(&self, ctx: &AppContext) -> bool {
|
||||
self.selected_conversation_for_user_facing_chrome(ctx)
|
||||
.is_some_and(|conversation| conversation.is_empty())
|
||||
|
||||
Reference in New Issue
Block a user