Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions crates/chat-cli/src/cli/chat/cli/persist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use crossterm::style::{
};

use crate::cli::ConversationState;
use crate::cli::chat::context::ContextFilePath;
use crate::cli::chat::{
ChatError,
ChatSession,
Expand Down Expand Up @@ -102,6 +103,21 @@ impl PersistSubcommand {
std::mem::swap(&mut new_state.tool_manager, &mut session.conversation.tool_manager);
std::mem::swap(&mut new_state.mcp_enabled, &mut session.conversation.mcp_enabled);
std::mem::swap(&mut new_state.model_info, &mut session.conversation.model_info);
// For context, we would only take paths that are not in the current agent
// And we'll place them as temporary context
// Note that we are NOT doing the same with hooks because hooks are more
// instrinsically linked to agent and it affects the behavior of an agent
if let Some(cm) = &new_state.context_manager {
if let Some(existing_cm) = &mut session.conversation.context_manager {
let existing_paths = &mut existing_cm.paths;
for incoming_path in &cm.paths {
if !existing_paths.contains(incoming_path) {
existing_paths
.push(ContextFilePath::Session(incoming_path.get_path_as_str().to_string()));
Comment on lines +115 to +116
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should also check if incoming_path was a session-path?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are all deserialized as Agent path actually. So it is included in here.

}
}
}
}
std::mem::swap(
&mut new_state.context_manager,
&mut session.conversation.context_manager,
Expand Down
3 changes: 1 addition & 2 deletions crates/chat-cli/src/cli/chat/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ impl Serialize for ContextFilePath {
S: Serializer,
{
match self {
ContextFilePath::Agent(path) => path.serialize(serializer),
ContextFilePath::Session(_) => Err(serde::ser::Error::custom("Session paths are not serialized")),
ContextFilePath::Agent(path) | ContextFilePath::Session(path) => path.serialize(serializer),
}
}
}
Expand Down