live fixes
This commit is contained in:
@@ -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