Skip to content

Commit daed93c

Browse files
[fomat] Runs Clippy and cargo +nightly fmt (#2991)
Co-authored-by: Kenneth S. <[email protected]>
1 parent 5526328 commit daed93c

File tree

2 files changed

+86
-92
lines changed

2 files changed

+86
-92
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,7 @@ impl Agents {
781781
let tool_trusted = self.get_active().is_some_and(|a| {
782782
let server_name = match origin {
783783
ToolOrigin::Native => None,
784-
_ => Some(<ToolOrigin as Borrow<str>>::borrow(origin)),
784+
ToolOrigin::McpServer(_) => Some(<ToolOrigin as Borrow<str>>::borrow(origin)),
785785
};
786786
is_tool_in_allowlist(&a.allowed_tools, tool_name, server_name)
787787
});

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

Lines changed: 85 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -265,10 +265,8 @@ impl PromptsArgs {
265265

266266
// Update longest_name to include local prompts
267267
for name in &prompt_names {
268-
if name.contains(search_word.as_deref().unwrap_or("")) {
269-
if name.len() > longest_name.len() {
270-
longest_name = name;
271-
}
268+
if name.contains(search_word.as_deref().unwrap_or("")) && name.len() > longest_name.len() {
269+
longest_name = name;
272270
}
273271
}
274272

@@ -901,54 +899,52 @@ impl PromptsSubcommand {
901899
});
902900
}
903901
&prompts.global
902+
} else if local_exists {
903+
&prompts.local
904+
} else if global_exists {
905+
// Found global prompt, but user wants to edit local
906+
queue!(
907+
session.stderr,
908+
style::Print("\n"),
909+
style::SetForegroundColor(Color::Yellow),
910+
style::Print("Local prompt "),
911+
style::SetForegroundColor(Color::Cyan),
912+
style::Print(&name),
913+
style::SetForegroundColor(Color::Yellow),
914+
style::Print(" not found, but global version exists.\n"),
915+
style::Print("Use "),
916+
style::SetForegroundColor(Color::Cyan),
917+
style::Print("/prompts edit "),
918+
style::Print(&name),
919+
style::Print(" --global"),
920+
style::SetForegroundColor(Color::Yellow),
921+
style::Print(" to edit the global version, or\n"),
922+
style::Print("use "),
923+
style::SetForegroundColor(Color::Cyan),
924+
style::Print("/prompts create "),
925+
style::Print(&name),
926+
style::SetForegroundColor(Color::Yellow),
927+
style::Print(" to create a local override.\n"),
928+
style::SetForegroundColor(Color::Reset),
929+
)?;
930+
return Ok(ChatState::PromptUser {
931+
skip_printing_tools: true,
932+
});
904933
} else {
905-
if local_exists {
906-
&prompts.local
907-
} else if global_exists {
908-
// Found global prompt, but user wants to edit local
909-
queue!(
910-
session.stderr,
911-
style::Print("\n"),
912-
style::SetForegroundColor(Color::Yellow),
913-
style::Print("Local prompt "),
914-
style::SetForegroundColor(Color::Cyan),
915-
style::Print(&name),
916-
style::SetForegroundColor(Color::Yellow),
917-
style::Print(" not found, but global version exists.\n"),
918-
style::Print("Use "),
919-
style::SetForegroundColor(Color::Cyan),
920-
style::Print("/prompts edit "),
921-
style::Print(&name),
922-
style::Print(" --global"),
923-
style::SetForegroundColor(Color::Yellow),
924-
style::Print(" to edit the global version, or\n"),
925-
style::Print("use "),
926-
style::SetForegroundColor(Color::Cyan),
927-
style::Print("/prompts create "),
928-
style::Print(&name),
929-
style::SetForegroundColor(Color::Yellow),
930-
style::Print(" to create a local override.\n"),
931-
style::SetForegroundColor(Color::Reset),
932-
)?;
933-
return Ok(ChatState::PromptUser {
934-
skip_printing_tools: true,
935-
});
936-
} else {
937-
queue!(
938-
session.stderr,
939-
style::Print("\n"),
940-
style::SetForegroundColor(Color::Yellow),
941-
style::Print("Prompt "),
942-
style::SetForegroundColor(Color::Cyan),
943-
style::Print(&name),
944-
style::SetForegroundColor(Color::Yellow),
945-
style::Print(" not found.\n"),
946-
style::SetForegroundColor(Color::Reset),
947-
)?;
948-
return Ok(ChatState::PromptUser {
949-
skip_printing_tools: true,
950-
});
951-
}
934+
queue!(
935+
session.stderr,
936+
style::Print("\n"),
937+
style::SetForegroundColor(Color::Yellow),
938+
style::Print("Prompt "),
939+
style::SetForegroundColor(Color::Cyan),
940+
style::Print(&name),
941+
style::SetForegroundColor(Color::Yellow),
942+
style::Print(" not found.\n"),
943+
style::SetForegroundColor(Color::Reset),
944+
)?;
945+
return Ok(ChatState::PromptUser {
946+
skip_printing_tools: true,
947+
});
952948
};
953949

954950
let location = if global { "global" } else { "local" };
@@ -1030,47 +1026,45 @@ impl PromptsSubcommand {
10301026
});
10311027
}
10321028
&prompts.global
1029+
} else if local_exists {
1030+
&prompts.local
1031+
} else if global_exists {
1032+
queue!(
1033+
session.stderr,
1034+
style::Print("\n"),
1035+
style::SetForegroundColor(Color::Yellow),
1036+
style::Print("Local prompt "),
1037+
style::SetForegroundColor(Color::Cyan),
1038+
style::Print(&name),
1039+
style::SetForegroundColor(Color::Yellow),
1040+
style::Print(" not found, but global version exists.\n"),
1041+
style::Print("Use "),
1042+
style::SetForegroundColor(Color::Cyan),
1043+
style::Print("/prompts remove "),
1044+
style::Print(&name),
1045+
style::Print(" --global"),
1046+
style::SetForegroundColor(Color::Yellow),
1047+
style::Print(" to remove the global version.\n"),
1048+
style::SetForegroundColor(Color::Reset),
1049+
)?;
1050+
return Ok(ChatState::PromptUser {
1051+
skip_printing_tools: true,
1052+
});
10331053
} else {
1034-
if local_exists {
1035-
&prompts.local
1036-
} else if global_exists {
1037-
queue!(
1038-
session.stderr,
1039-
style::Print("\n"),
1040-
style::SetForegroundColor(Color::Yellow),
1041-
style::Print("Local prompt "),
1042-
style::SetForegroundColor(Color::Cyan),
1043-
style::Print(&name),
1044-
style::SetForegroundColor(Color::Yellow),
1045-
style::Print(" not found, but global version exists.\n"),
1046-
style::Print("Use "),
1047-
style::SetForegroundColor(Color::Cyan),
1048-
style::Print("/prompts remove "),
1049-
style::Print(&name),
1050-
style::Print(" --global"),
1051-
style::SetForegroundColor(Color::Yellow),
1052-
style::Print(" to remove the global version.\n"),
1053-
style::SetForegroundColor(Color::Reset),
1054-
)?;
1055-
return Ok(ChatState::PromptUser {
1056-
skip_printing_tools: true,
1057-
});
1058-
} else {
1059-
queue!(
1060-
session.stderr,
1061-
style::Print("\n"),
1062-
style::SetForegroundColor(Color::Yellow),
1063-
style::Print("Prompt "),
1064-
style::SetForegroundColor(Color::Cyan),
1065-
style::Print(&name),
1066-
style::SetForegroundColor(Color::Yellow),
1067-
style::Print(" not found.\n"),
1068-
style::SetForegroundColor(Color::Reset),
1069-
)?;
1070-
return Ok(ChatState::PromptUser {
1071-
skip_printing_tools: true,
1072-
});
1073-
}
1054+
queue!(
1055+
session.stderr,
1056+
style::Print("\n"),
1057+
style::SetForegroundColor(Color::Yellow),
1058+
style::Print("Prompt "),
1059+
style::SetForegroundColor(Color::Cyan),
1060+
style::Print(&name),
1061+
style::SetForegroundColor(Color::Yellow),
1062+
style::Print(" not found.\n"),
1063+
style::SetForegroundColor(Color::Reset),
1064+
)?;
1065+
return Ok(ChatState::PromptUser {
1066+
skip_printing_tools: true,
1067+
});
10741068
};
10751069

10761070
let location = if global { "global" } else { "local" };

0 commit comments

Comments
 (0)