Skip to content

Commit 083e3d9

Browse files
authored
fix: slash command created agent not showing up post creation (#2399)
1 parent f0e1428 commit 083e3d9

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

crates/chat-cli/src/cli/chat/cli/profile.rs

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -145,20 +145,26 @@ impl AgentSubcommand {
145145
return Err(ChatError::Custom("Editor process did not exit with success".into()));
146146
}
147147

148-
let Ok(content) = os.fs.read(&path_with_file_name).await else {
149-
return Err(ChatError::Custom(
150-
format!(
151-
"Post write validation failed. Error opening {}. Aborting",
152-
path_with_file_name.display()
153-
)
154-
.into(),
155-
));
156-
};
157-
if let Err(e) = serde_json::from_slice::<Agent>(&content) {
158-
return Err(ChatError::Custom(
159-
format!("Post write validation failed for agent '{name}'. Malformed config detected: {e}")
160-
.into(),
161-
));
148+
let new_agent = Agent::load(os, &path_with_file_name, &mut None).await;
149+
match new_agent {
150+
Ok(agent) => {
151+
session.conversation.agents.agents.insert(agent.name.clone(), agent);
152+
},
153+
Err(e) => {
154+
execute!(
155+
session.stderr,
156+
style::SetForegroundColor(Color::Red),
157+
style::Print("Error: "),
158+
style::ResetColor,
159+
style::Print(&e),
160+
style::Print("\n"),
161+
)?;
162+
163+
return Err(ChatError::Custom(
164+
format!("Post write validation failed for agent '{name}'. Malformed config detected: {e}")
165+
.into(),
166+
));
167+
},
162168
}
163169

164170
execute!(

0 commit comments

Comments
 (0)