first pass of merging in warp (doesn't build)
This commit is contained in:
@@ -3,13 +3,10 @@
|
||||
use galaxyui::{Entity, SingletonEntity};
|
||||
use std::collections::HashMap;
|
||||
|
||||
use crate::{
|
||||
ai::{
|
||||
agent::conversation::{AIConversation, AIConversationId},
|
||||
blocklist::history_model::convert_persisted_conversation_to_ai_conversation_with_metadata,
|
||||
},
|
||||
persistence::model::AgentConversation,
|
||||
};
|
||||
|
||||
use crate::ai::agent::conversation::{AIConversation, AIConversationId};
|
||||
use crate::ai::blocklist::history_model::convert_persisted_conversation_to_ai_conversation_with_metadata;
|
||||
use crate::persistence::model::AgentConversation;
|
||||
|
||||
/// Singleton model that holds restored agent conversations on app startup.
|
||||
///
|
||||
@@ -52,6 +49,27 @@ impl RestoredAgentConversations {
|
||||
pub fn take_conversation(&mut self, id: &AIConversationId) -> Option<AIConversation> {
|
||||
self.conversations.remove(id)
|
||||
}
|
||||
|
||||
/// Takes and returns AIConversations for the given IDs, sorted by first exchange start time.
|
||||
pub fn take_conversations(
|
||||
&mut self,
|
||||
conversation_ids: &[AIConversationId],
|
||||
) -> Vec<AIConversation> {
|
||||
let mut conversations = Vec::new();
|
||||
for &conversation_id in conversation_ids {
|
||||
if let Some(conversation) = self.take_conversation(&conversation_id) {
|
||||
conversations.push(conversation);
|
||||
}
|
||||
}
|
||||
|
||||
// Sort by first exchange start time (oldest first)
|
||||
conversations.sort_by_key(|conversation| {
|
||||
conversation
|
||||
.first_exchange()
|
||||
.map(|exchange| exchange.start_time)
|
||||
});
|
||||
conversations
|
||||
}
|
||||
}
|
||||
|
||||
impl Entity for RestoredAgentConversations {
|
||||
|
||||
Reference in New Issue
Block a user