live fixes
This commit is contained in:
@@ -26,6 +26,7 @@ pub struct ActionButtonsConfig {
|
||||
pub view_details_item_id: Option<AgentConversationEntryId>,
|
||||
/// Conversation link URL (either to the transcript or live session) for copy link button.
|
||||
pub copy_link_url: Option<String>,
|
||||
pub delete_conversation_id: Option<AIConversationId>,
|
||||
}
|
||||
|
||||
impl ActionButtonsConfig {
|
||||
@@ -36,6 +37,7 @@ impl ActionButtonsConfig {
|
||||
&& self.fork_conversation_id.is_none()
|
||||
&& self.view_details_item_id.is_none()
|
||||
&& self.copy_link_url.is_none()
|
||||
&& self.delete_conversation_id.is_none()
|
||||
}
|
||||
|
||||
/// Create config for a task.
|
||||
@@ -58,6 +60,7 @@ impl ActionButtonsConfig {
|
||||
fork_conversation_id: None,
|
||||
view_details_item_id: None,
|
||||
copy_link_url,
|
||||
delete_conversation_id: None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,6 +78,7 @@ impl ActionButtonsConfig {
|
||||
fork_conversation_id: Some(conversation_id),
|
||||
view_details_item_id: None,
|
||||
copy_link_url,
|
||||
delete_conversation_id: Some(conversation_id),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -87,6 +91,7 @@ pub enum AgentDetailsButtonEvent {
|
||||
ForkConversation { conversation_id: AIConversationId },
|
||||
ViewDetails { item_id: AgentConversationEntryId },
|
||||
CopyLink { link: String },
|
||||
DeleteConversation { conversation_id: AIConversationId },
|
||||
}
|
||||
|
||||
/// Actions dispatched by button clicks (internal).
|
||||
@@ -97,6 +102,7 @@ pub enum AgentDetailsAction {
|
||||
ForkConversation,
|
||||
ViewDetails,
|
||||
CopyLink,
|
||||
DeleteConversation,
|
||||
}
|
||||
|
||||
/// Reusable action buttons row for details panel.
|
||||
@@ -107,6 +113,7 @@ pub struct ConversationActionButtonsRow {
|
||||
fork_conversation_button: ViewHandle<ActionButton>,
|
||||
view_details_button: ViewHandle<ActionButton>,
|
||||
copy_link_button: ViewHandle<ActionButton>,
|
||||
delete_conversation_button: ViewHandle<ActionButton>,
|
||||
}
|
||||
|
||||
impl ConversationActionButtonsRow {
|
||||
@@ -156,6 +163,15 @@ impl ConversationActionButtonsRow {
|
||||
)
|
||||
});
|
||||
|
||||
let delete_conversation_button = ctx.add_typed_action_view(|_| {
|
||||
Self::make_action_button(
|
||||
Icon::Trash,
|
||||
"Delete conversation",
|
||||
Some(AnsiColorIdentifier::Red),
|
||||
AgentDetailsAction::DeleteConversation,
|
||||
)
|
||||
});
|
||||
|
||||
Self {
|
||||
config: ActionButtonsConfig::default(),
|
||||
open_button,
|
||||
@@ -163,6 +179,7 @@ impl ConversationActionButtonsRow {
|
||||
fork_conversation_button,
|
||||
view_details_button,
|
||||
copy_link_button,
|
||||
delete_conversation_button,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -231,6 +248,9 @@ impl View for ConversationActionButtonsRow {
|
||||
if self.config.view_details_item_id.is_some() {
|
||||
row.add_child(ChildView::new(&self.view_details_button).finish());
|
||||
}
|
||||
if self.config.delete_conversation_id.is_some() && !cfg!(target_family = "wasm") {
|
||||
row.add_child(ChildView::new(&self.delete_conversation_button).finish());
|
||||
}
|
||||
|
||||
row.finish()
|
||||
}
|
||||
@@ -280,6 +300,11 @@ impl TypedActionView for ConversationActionButtonsRow {
|
||||
);
|
||||
}
|
||||
}
|
||||
AgentDetailsAction::DeleteConversation => {
|
||||
if let Some(conversation_id) = self.config.delete_conversation_id {
|
||||
ctx.emit(AgentDetailsButtonEvent::DeleteConversation { conversation_id });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1078,7 +1078,7 @@ impl AgentManagementView {
|
||||
open_action: Option<WorkspaceAction>,
|
||||
copy_link_url: Option<String>,
|
||||
) -> ActionButtonsConfig {
|
||||
if let Some(task_id) = entry.identity.ambient_agent_task_id {
|
||||
let mut config = if let Some(task_id) = entry.identity.ambient_agent_task_id {
|
||||
ActionButtonsConfig::for_task(
|
||||
task_id,
|
||||
&entry.display.status,
|
||||
@@ -1093,7 +1093,15 @@ impl AgentManagementView {
|
||||
copy_link_url,
|
||||
..Default::default()
|
||||
}
|
||||
};
|
||||
|
||||
if !entry.capabilities.can_delete
|
||||
|| !entry.display.status.to_conversation_status().is_done()
|
||||
{
|
||||
config.delete_conversation_id = None;
|
||||
}
|
||||
|
||||
config
|
||||
}
|
||||
|
||||
fn handle_action_buttons_event(
|
||||
@@ -1173,6 +1181,18 @@ impl AgentManagementView {
|
||||
ctx.clipboard()
|
||||
.write(ClipboardContent::plain_text(link.clone()));
|
||||
}
|
||||
AgentDetailsButtonEvent::DeleteConversation { conversation_id } => {
|
||||
let model = AgentConversationsModel::as_ref(ctx);
|
||||
let conversation_title = model
|
||||
.get_entry_by_id(item_id, ctx)
|
||||
.map(|entry| entry.display.title)
|
||||
.unwrap_or_else(|| "Conversation".to_string());
|
||||
ctx.emit(AgentManagementViewEvent::ShowDeleteConfirmationDialog {
|
||||
conversation_id: *conversation_id,
|
||||
conversation_title,
|
||||
terminal_view_id: None,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1395,6 +1415,16 @@ impl AgentManagementView {
|
||||
notebook_uid: *notebook_uid,
|
||||
});
|
||||
}
|
||||
ConversationDetailsPanelEvent::ShowDeleteConfirmationDialog {
|
||||
conversation_id,
|
||||
conversation_title,
|
||||
} => {
|
||||
ctx.emit(AgentManagementViewEvent::ShowDeleteConfirmationDialog {
|
||||
conversation_id: *conversation_id,
|
||||
conversation_title: conversation_title.clone(),
|
||||
terminal_view_id: None,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2232,7 +2262,14 @@ pub enum AgentManagementViewAction {
|
||||
|
||||
pub enum AgentManagementViewEvent {
|
||||
OpenNewTabAndRunWorkflow(Box<WorkflowType>),
|
||||
OpenPlanNotebook { notebook_uid: NotebookId },
|
||||
OpenPlanNotebook {
|
||||
notebook_uid: NotebookId,
|
||||
},
|
||||
ShowDeleteConfirmationDialog {
|
||||
conversation_id: AIConversationId,
|
||||
conversation_title: String,
|
||||
terminal_view_id: Option<galaxyui::EntityId>,
|
||||
},
|
||||
}
|
||||
|
||||
impl TypedActionView for AgentManagementView {
|
||||
|
||||
Reference in New Issue
Block a user