MCPcopy Create free account
hub / github.com/aws/amazon-q-developer-cli / prompt_user

Method prompt_user

crates/chat-cli/src/cli/chat/mod.rs:2010–2117  ·  view source on GitHub ↗

Read input from the user.

(&mut self, os: &Os, skip_printing_tools: bool)

Source from the content-addressed store, hash-verified

2008
2009 /// Read input from the user.
2010 async fn prompt_user(&mut self, os: &Os, skip_printing_tools: bool) -> Result<ChatState, ChatError> {
2011 execute!(self.stderr, cursor::Show)?;
2012
2013 // Check token usage and display warnings if needed
2014 if self.pending_tool_index.is_none() {
2015 // Only display warnings when not waiting for tool approval
2016 if let Err(err) = self.display_char_warnings(os).await {
2017 warn!("Failed to display character limit warnings: {}", err);
2018 }
2019 }
2020
2021 let show_tool_use_confirmation_dialog = !skip_printing_tools && self.pending_tool_index.is_some();
2022 if show_tool_use_confirmation_dialog {
2023 execute!(
2024 self.stderr,
2025 StyledText::secondary_fg(),
2026 style::Print("\nAllow this action? Use '"),
2027 StyledText::success_fg(),
2028 style::Print("t"),
2029 StyledText::secondary_fg(),
2030 style::Print("' to trust (always allow) this tool for the session. ["),
2031 StyledText::success_fg(),
2032 style::Print("y"),
2033 StyledText::secondary_fg(),
2034 style::Print("/"),
2035 StyledText::success_fg(),
2036 style::Print("n"),
2037 StyledText::secondary_fg(),
2038 style::Print("/"),
2039 StyledText::success_fg(),
2040 style::Print("t"),
2041 StyledText::secondary_fg(),
2042 style::Print("]:\n\n"),
2043 StyledText::reset(),
2044 )?;
2045 }
2046
2047 // Do this here so that the skim integration sees an updated view of the context *during the current
2048 // q session*. (e.g., if I add files to context, that won't show up for skim for the current
2049 // q session unless we do this in prompt_user... unless you can find a better way)
2050 #[cfg(unix)]
2051 if let Some(ref context_manager) = self.conversation.context_manager {
2052 use std::sync::Arc;
2053
2054 use crate::cli::chat::consts::DUMMY_TOOL_NAME;
2055
2056 let tool_names = self
2057 .conversation
2058 .tool_manager
2059 .tn_map
2060 .keys()
2061 .filter(|name| *name != DUMMY_TOOL_NAME)
2062 .cloned()
2063 .collect::<Vec<_>>();
2064 self.input_source
2065 .put_skim_command_selector(os, Arc::new(context_manager.clone()), tool_names);
2066 }
2067

Callers 1

nextMethod · 0.80

Calls 15

MetaEventClass · 0.85
CustomClass · 0.85
display_char_warningsMethod · 0.80
to_stringMethod · 0.80
read_user_inputMethod · 0.80
take_clipboard_pastesMethod · 0.80
joinMethod · 0.80
mapMethod · 0.80
reset_paste_countMethod · 0.80

Tested by

no test coverage detected