Skip to content

Commit 192be2a

Browse files
committed
fix: treat empty string as unset for chat.defaultAgent setting
When users run 'q settings chat.defaultAgent ""' to reset their default agent (as documented), the empty string was being treated as a valid agent name, causing an error message on every chat session start. This change treats empty strings as 'no default set', allowing users to cleanly reset to the built-in default agent without error messages. Fixes the misleading behavior described in the AWS documentation where setting an empty string should reset to built-in default silently.
1 parent bf6de44 commit 192be2a

1 file changed

Lines changed: 17 additions & 14 deletions

File tree

  • crates/chat-cli/src/cli/agent

crates/chat-cli/src/cli/agent/mod.rs

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -668,21 +668,24 @@ impl Agents {
668668
}
669669

670670
if let Some(user_set_default) = os.database.settings.get_string(Setting::ChatDefaultAgent) {
671-
if all_agents.iter().any(|a| a.name == user_set_default) {
672-
break 'active_idx user_set_default;
671+
// Treat empty strings as "no default set" to allow clean reset
672+
if !user_set_default.is_empty() {
673+
if all_agents.iter().any(|a| a.name == user_set_default) {
674+
break 'active_idx user_set_default;
675+
}
676+
let _ = queue!(
677+
output,
678+
style::SetForegroundColor(Color::Red),
679+
style::Print("Error"),
680+
style::SetForegroundColor(Color::Yellow),
681+
style::Print(format!(
682+
": user defined default {} not found. Falling back to in-memory default",
683+
user_set_default
684+
)),
685+
style::Print("\n"),
686+
style::SetForegroundColor(Color::Reset)
687+
);
673688
}
674-
let _ = queue!(
675-
output,
676-
style::SetForegroundColor(Color::Red),
677-
style::Print("Error"),
678-
style::SetForegroundColor(Color::Yellow),
679-
style::Print(format!(
680-
": user defined default {} not found. Falling back to in-memory default",
681-
user_set_default
682-
)),
683-
style::Print("\n"),
684-
style::SetForegroundColor(Color::Reset)
685-
);
686689
}
687690

688691
all_agents.push({

0 commit comments

Comments
 (0)