Skip to content

Commit 14491bf

Browse files
authored
fix: issues from /command refactor (#273)
* fix issue, subscribe, editor * fix tool denail * fix default model * typi * fmt
1 parent 0659330 commit 14491bf

File tree

4 files changed

+64
-19
lines changed

4 files changed

+64
-19
lines changed

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ use crate::cli::chat::{
3232
ChatSession,
3333
ChatState,
3434
};
35+
use crate::cli::issue;
3536
use crate::database::Database;
3637
use crate::platform::Context;
3738
use crate::telemetry::TelemetryThread;
@@ -52,11 +53,14 @@ pub enum SlashCommand {
5253
#[command(subcommand)]
5354
Context(ContextSubcommand),
5455
/// Open $EDITOR (defaults to vi) to compose a prompt
56+
#[command(name = "editor")]
5557
PromptEditor(EditorArgs),
5658
/// Summarize the conversation to free up context space
5759
Compact(CompactArgs),
5860
/// View and manage tools and permissions
5961
Tools(ToolsArgs),
62+
/// Create a new Github issue
63+
Issue(issue::IssueArgs),
6064
/// View and retrieve prompts
6165
Prompts(PromptsArgs),
6266
/// View and manage context hooks
@@ -91,6 +95,15 @@ impl SlashCommand {
9195
Self::PromptEditor(args) => args.execute(session).await,
9296
Self::Compact(args) => args.execute(ctx, database, telemetry, session).await,
9397
Self::Tools(args) => args.execute(session).await,
98+
Self::Issue(args) => {
99+
if let Err(err) = args.execute().await {
100+
return Err(ChatError::Custom(err.to_string().into()));
101+
}
102+
103+
Ok(ChatState::PromptUser {
104+
skip_printing_tools: true,
105+
})
106+
},
94107
Self::Prompts(args) => args.execute(session).await,
95108
Self::Hooks(args) => args.execute(ctx, session).await,
96109
Self::Usage(args) => args.execute(ctx, session).await,

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use crate::cli::chat::{
1414
ChatSession,
1515
ChatState,
1616
};
17+
use crate::database::Database;
1718

1819
pub struct ModelOption {
1920
pub name: &'static str,
@@ -35,8 +36,6 @@ pub const MODEL_OPTIONS: [ModelOption; 3] = [
3536
},
3637
];
3738

38-
pub const DEFAULT_MODEL_ID: &str = "CLAUDE_3_7_SONNET_20250219_V1_0";
39-
4039
#[deny(missing_docs)]
4140
#[derive(Debug, PartialEq, Args)]
4241
pub struct ModelArgs;
@@ -98,3 +97,11 @@ impl ModelArgs {
9897
})
9998
}
10099
}
100+
101+
/// Currently, Sonnet 4 is set as the default model for non-FRA users.
102+
pub fn default_model_id(database: &Database) -> &'static str {
103+
match database.get_auth_profile() {
104+
Ok(Some(profile)) if profile.arn.split(':').nth(3) == Some("eu-central-1") => "CLAUDE_3_7_SONNET_20250219_V1_0",
105+
_ => "CLAUDE_SONNET_4_20250514_V1_0",
106+
}
107+
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ Need help? Visit our subscription support page> <blue!>https://docs.aws.amazon.c
3232
#[deny(missing_docs)]
3333
#[derive(Debug, PartialEq, Args)]
3434
pub struct SubscribeArgs {
35+
#[arg(long)]
3536
manage: bool,
3637
}
3738

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

Lines changed: 41 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ use crate::auth::AuthError;
124124
use crate::auth::builder_id::is_idc_user;
125125
use crate::cli::chat::cli::SlashCommand;
126126
use crate::cli::chat::cli::model::{
127-
DEFAULT_MODEL_ID,
128127
MODEL_OPTIONS,
128+
default_model_id,
129129
};
130130
use crate::cli::chat::cli::prompts::GetPromptError;
131131
use crate::database::Database;
@@ -480,19 +480,19 @@ impl ChatSession {
480480
tool_config: HashMap<String, ToolSpec>,
481481
tool_permissions: ToolPermissions,
482482
) -> Result<Self> {
483-
let valid_model_id = match model_id {
484-
Some(id) => Some(id),
485-
None => database
486-
.settings
487-
.get_string(Setting::ChatDefaultModel)
488-
.and_then(|model_name| {
489-
MODEL_OPTIONS
490-
.iter()
491-
.find(|opt| opt.name == model_name)
492-
.map(|opt| opt.model_id.to_owned())
493-
})
494-
.or_else(|| Some(DEFAULT_MODEL_ID.to_owned())),
495-
};
483+
let valid_model_id = model_id
484+
.or_else(|| {
485+
database
486+
.settings
487+
.get_string(Setting::ChatDefaultModel)
488+
.and_then(|model_name| {
489+
MODEL_OPTIONS
490+
.iter()
491+
.find(|opt| opt.name == model_name)
492+
.map(|opt| opt.model_id.to_owned())
493+
})
494+
})
495+
.unwrap_or_else(|| default_model_id(database).to_owned());
496496

497497
// Reload prior conversation
498498
let mut existing_conversation = false;
@@ -519,7 +519,15 @@ impl ChatSession {
519519
cs
520520
},
521521
false => {
522-
ConversationState::new(ctx, conversation_id, tool_config, profile, tool_manager, valid_model_id).await
522+
ConversationState::new(
523+
ctx,
524+
conversation_id,
525+
tool_config,
526+
profile,
527+
tool_manager,
528+
Some(valid_model_id),
529+
)
530+
.await
523531
},
524532
};
525533

@@ -1269,17 +1277,33 @@ impl ChatSession {
12691277
})
12701278
} else {
12711279
// Check for a pending tool approval
1280+
let tool_denied_without_reason = ["n", "N"].contains(&input);
1281+
12721282
if let Some(index) = self.pending_tool_index {
12731283
let is_trust = ["t", "T"].contains(&input);
1284+
let tool_use = &mut self.tool_uses[index];
12741285
if ["y", "Y"].contains(&input) || is_trust {
1275-
let tool_use = &mut self.tool_uses[index];
1276-
12771286
if is_trust {
12781287
self.tool_permissions.trust_tool(&tool_use.name);
12791288
}
12801289
tool_use.accepted = true;
12811290

12821291
return Ok(ChatState::ExecuteTools);
1292+
// Prompt reason if no selected
1293+
} else if tool_denied_without_reason {
1294+
tool_use.accepted = false;
1295+
execute!(
1296+
self.output,
1297+
style::SetForegroundColor(Color::DarkGrey),
1298+
style::Print(
1299+
"\nPlease provide a reason for denying this tool use, or otherwise continue your conversation:\n\n"
1300+
),
1301+
style::SetForegroundColor(Color::Reset),
1302+
)?;
1303+
1304+
return Ok(ChatState::PromptUser {
1305+
skip_printing_tools: true,
1306+
});
12831307
}
12841308
} else if !self.pending_prompts.is_empty() {
12851309
let prompts = self.pending_prompts.drain(0..).collect();

0 commit comments

Comments
 (0)