Skip to content

Commit a724d0c

Browse files
committed
feat: change new to resume, change import/export to save/load
1 parent 3f16e18 commit a724d0c

File tree

5 files changed

+54
-46
lines changed

5 files changed

+54
-46
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ pub struct Chat {
1717
/// prompt requests permissions to use a tool, unless --trust-all-tools is also used.
1818
#[arg(long)]
1919
pub no_interactive: bool,
20-
/// Start a new conversation and overwrites any previous conversation from this directory.
21-
#[arg(long)]
22-
pub new: bool,
20+
/// Resumes the previous conversation from this directory.
21+
#[arg(short, long)]
22+
pub resume: bool,
2323
/// The first question to ask
2424
pub input: Option<String>,
2525
/// Context profile to use

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ pub enum Command {
5151
subcommand: Option<PromptsSubcommand>,
5252
},
5353
Usage,
54-
Import {
54+
Load {
5555
path: String,
5656
},
57-
Export {
57+
Save {
5858
path: String,
5959
force: bool,
6060
},
@@ -818,15 +818,15 @@ impl Command {
818818
}
819819
},
820820
"usage" => Self::Usage,
821-
"import" => {
821+
"load" => {
822822
let Some(path) = parts.get(1) else {
823823
return Err("path is required".to_string());
824824
};
825-
Self::Import {
825+
Self::Load {
826826
path: (*path).to_string(),
827827
}
828828
},
829-
"export" => {
829+
"save" => {
830830
let force = parts.contains(&"-f") || parts.contains(&"--force");
831831
let Some(path) = parts.get(1) else {
832832
return Err("path is required".to_string());
@@ -835,7 +835,7 @@ impl Command {
835835
if !path.ends_with(".json") {
836836
path.push_str(".json");
837837
}
838-
Self::Export { path, force }
838+
Self::Save { path, force }
839839
},
840840
unknown_command => {
841841
let looks_like_path = {

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

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,8 @@ const WELCOME_TEXT: &str = color_print::cstr! {"<cyan!>
203203
const SMALL_SCREEN_WELCOME_TEXT: &str = color_print::cstr! {"<em>Welcome to <cyan!>Amazon Q</cyan!>!</em>"};
204204
const RESUME_TEXT: &str = color_print::cstr! {"<em>Picking up where we left off...</em>"};
205205

206-
const ROTATING_TIPS: [&str; 11] = [
206+
const ROTATING_TIPS: [&str; 12] = [
207+
color_print::cstr! {"You can resume the last conversation from your current directory by launching with <green!>q chat --resume</green!>"},
207208
color_print::cstr! {"Get notified whenever Q CLI finishes responding. Just run <green!>q settings chat.enableNotifications true</green!>"},
208209
color_print::cstr! {"You can use <green!>/editor</green!> to edit your prompt with a vim-like experience"},
209210
color_print::cstr! {"<green!>/usage</green!> shows you a visual breakdown of your current context window usage"},
@@ -263,8 +264,8 @@ const HELP_TEXT: &str = color_print::cstr! {"
263264
<em>clear</em> <black!>Clear all files from current context [--global]</black!>
264265
<em>hooks</em> <black!>View and manage context hooks</black!>
265266
<em>/usage</em> <black!>Show current session's context window usage</black!>
266-
<em>/import</em> <black!>Import conversation state from a JSON file</black!>
267-
<em>/export</em> <black!>Export conversation state to a JSON file</black!>
267+
<em>/load</em> <black!>Load conversation state from a JSON file</black!>
268+
<em>/save</em> <black!>Save conversation state to a JSON file</black!>
268269
269270
<cyan,em>MCP:</cyan,em>
270271
<black!>You can now configure the Amazon Q CLI to use MCP servers. \nLearn how: https://docs.aws.amazon.com/en_us/amazonq/latest/qdeveloper-ug/command-line-mcp.html</black!>
@@ -299,7 +300,7 @@ pub async fn launch_chat(database: &mut Database, telemetry: &TelemetryThread, a
299300
telemetry,
300301
args.input,
301302
args.no_interactive,
302-
args.new,
303+
args.resume,
303304
args.accept_all,
304305
args.profile,
305306
args.trust_all_tools,
@@ -314,7 +315,7 @@ pub async fn chat(
314315
telemetry: &TelemetryThread,
315316
input: Option<String>,
316317
no_interactive: bool,
317-
new_conversation: bool,
318+
resume_conversation: bool,
318319
accept_all: bool,
319320
profile: Option<String>,
320321
trust_all_tools: bool,
@@ -443,7 +444,7 @@ pub async fn chat(
443444
input,
444445
InputSource::new(database, prompt_request_sender, prompt_response_receiver)?,
445446
interactive,
446-
new_conversation,
447+
resume_conversation,
447448
client,
448449
|| terminal::window_size().map(|s| s.columns.into()).ok(),
449450
tool_manager,
@@ -530,7 +531,7 @@ impl ChatContext {
530531
mut input: Option<String>,
531532
input_source: InputSource,
532533
interactive: bool,
533-
new_conversation: bool,
534+
resume_conversation: bool,
534535
client: StreamingClient,
535536
terminal_width_provider: fn() -> Option<usize>,
536537
tool_manager: ToolManager,
@@ -542,22 +543,7 @@ impl ChatContext {
542543
let output_clone = output.clone();
543544

544545
let mut existing_conversation = false;
545-
let conversation_state = if new_conversation {
546-
let new_state = ConversationState::new(
547-
ctx_clone,
548-
conversation_id,
549-
tool_config,
550-
profile,
551-
Some(output_clone),
552-
tool_manager,
553-
)
554-
.await;
555-
556-
std::env::current_dir()
557-
.ok()
558-
.and_then(|cwd| database.set_conversation_by_path(cwd, &new_state).ok());
559-
new_state
560-
} else {
546+
let conversation_state = if resume_conversation {
561547
let prior = std::env::current_dir()
562548
.ok()
563549
.and_then(|cwd| database.get_conversation_by_path(cwd).ok())
@@ -585,6 +571,16 @@ impl ChatContext {
585571
)
586572
.await
587573
}
574+
} else {
575+
ConversationState::new(
576+
ctx_clone,
577+
conversation_id,
578+
tool_config,
579+
profile,
580+
Some(output_clone),
581+
tool_manager,
582+
)
583+
.await
588584
};
589585

590586
Ok(Self {
@@ -2812,7 +2808,7 @@ impl ChatContext {
28122808
skip_printing_tools: true,
28132809
}
28142810
},
2815-
Command::Import { path } => {
2811+
Command::Load { path } => {
28162812
macro_rules! tri {
28172813
($v:expr) => {
28182814
match $v {
@@ -2854,7 +2850,7 @@ impl ChatContext {
28542850
skip_printing_tools: true,
28552851
}
28562852
},
2857-
Command::Export { path, force } => {
2853+
Command::Save { path, force } => {
28582854
macro_rules! tri {
28592855
($v:expr) => {
28602856
match $v {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ pub const COMMANDS: &[&str] = &[
7676
"/compact",
7777
"/compact help",
7878
"/usage",
79-
"/import",
80-
"/export",
79+
"/save",
80+
"/load",
8181
];
8282

8383
pub fn generate_prompt(current_profile: Option<&str>, warning: bool) -> String {

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

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ mod test {
369369
subcommand: Some(CliRootCommands::Chat(Chat {
370370
accept_all: false,
371371
no_interactive: false,
372-
new: false,
372+
resume: false,
373373
input: None,
374374
profile: None,
375375
trust_all_tools: false,
@@ -408,7 +408,7 @@ mod test {
408408
CliRootCommands::Chat(Chat {
409409
accept_all: false,
410410
no_interactive: false,
411-
new: false,
411+
resume: false,
412412
input: None,
413413
profile: Some("my-profile".to_string()),
414414
trust_all_tools: false,
@@ -424,7 +424,7 @@ mod test {
424424
CliRootCommands::Chat(Chat {
425425
accept_all: false,
426426
no_interactive: false,
427-
new: false,
427+
resume: false,
428428
input: Some("Hello".to_string()),
429429
profile: Some("my-profile".to_string()),
430430
trust_all_tools: false,
@@ -440,7 +440,7 @@ mod test {
440440
CliRootCommands::Chat(Chat {
441441
accept_all: true,
442442
no_interactive: false,
443-
new: false,
443+
resume: false,
444444
input: None,
445445
profile: Some("my-profile".to_string()),
446446
trust_all_tools: false,
@@ -450,13 +450,25 @@ mod test {
450450
}
451451

452452
#[test]
453-
fn test_chat_with_no_interactive_new() {
453+
fn test_chat_with_no_interactive_and_resume() {
454454
assert_parse!(
455-
["chat", "--no-interactive", "--new"],
455+
["chat", "--no-interactive", "--resume"],
456456
CliRootCommands::Chat(Chat {
457457
accept_all: false,
458458
no_interactive: true,
459-
new: true,
459+
resume: true,
460+
input: None,
461+
profile: None,
462+
trust_all_tools: false,
463+
trust_tools: None,
464+
})
465+
);
466+
assert_parse!(
467+
["chat", "--no-interactive", "-r"],
468+
CliRootCommands::Chat(Chat {
469+
accept_all: false,
470+
no_interactive: true,
471+
resume: true,
460472
input: None,
461473
profile: None,
462474
trust_all_tools: false,
@@ -472,7 +484,7 @@ mod test {
472484
CliRootCommands::Chat(Chat {
473485
accept_all: false,
474486
no_interactive: false,
475-
new: false,
487+
resume: false,
476488
input: None,
477489
profile: None,
478490
trust_all_tools: true,
@@ -488,7 +500,7 @@ mod test {
488500
CliRootCommands::Chat(Chat {
489501
accept_all: false,
490502
no_interactive: false,
491-
new: false,
503+
resume: false,
492504
input: None,
493505
profile: None,
494506
trust_all_tools: false,
@@ -504,7 +516,7 @@ mod test {
504516
CliRootCommands::Chat(Chat {
505517
accept_all: false,
506518
no_interactive: false,
507-
new: false,
519+
resume: false,
508520
input: None,
509521
profile: None,
510522
trust_all_tools: false,

0 commit comments

Comments
 (0)