summaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
authorPatrick Jackson <patrick@jackson.dev>2024-03-26 17:00:28 -0600
committerGitHub <noreply@github.com>2024-03-27 07:00:28 +0800
commit582f56e915a7c88eb0372496e298c9944f5832ae (patch)
treec95e19607288f9c740b1d76b477cede2c88a0466 /src/main.rs
parent7f05dc1a4af868b64906666c65020838cf2aa985 (diff)
downloadaichat-582f56e915a7c88eb0372496e298c9944f5832ae.tar.gz
feat: add `save_session` config item and `--save-session` cli option (#370)
* fix: sessions should save when exiting * feat: improve save sessions * feat: do not allow saving the temp session name * feat: allow creating a session without interactive use * feat: add `save_session` config and `--save-session` option --------- Co-authored-by: sigoden <sigoden@gmail.com>
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/main.rs b/src/main.rs
index 589676e..502f6d3 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -54,6 +54,9 @@ fn main() -> Result<()> {
if let Some(wrap) = &cli.wrap {
config.write().set_wrap(wrap)?;
}
+ if cli.save_session {
+ config.write().save_session = true;
+ }
if cli.light_theme {
config.write().light_theme = true;
}
@@ -111,9 +114,6 @@ fn start_directive(
no_stream: bool,
code_mode: bool,
) -> Result<()> {
- if let Some(session) = &config.read().session {
- session.guard_save()?;
- }
let input = Input::new(
text,
include.unwrap_or_default(),
@@ -141,7 +141,9 @@ fn start_directive(
let abort = create_abort_signal();
render_stream(&input, client.as_ref(), config, abort)?
};
+ // Save the message/session
config.write().save_message(input, &output)?;
+ config.write().end_session(false)?;
Ok(())
}