diff --git a/src/config/mod.rs b/src/config/mod.rs index 2150683..722776e 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -135,6 +135,7 @@ const RAGS_DIR_NAME: &str = "rags"; const FUNCTIONS_DIR_NAME: &str = "functions"; const FUNCTIONS_BIN_DIR_NAME: &str = "bin"; const AGENTS_DIR_NAME: &str = "agents"; +const REPL_HISTORY_DIR_NAME: &str = "repl-history"; const GLOBAL_TOOLS_DIR_NAME: &str = "tools"; const GLOBAL_TOOLS_UTILS_DIR_NAME: &str = "utils"; const BASH_PROMPT_UTILS_FILE_NAME: &str = "prompt-utils.sh"; diff --git a/src/config/paths.rs b/src/config/paths.rs index 3d08d5e..742a92e 100644 --- a/src/config/paths.rs +++ b/src/config/paths.rs @@ -8,6 +8,8 @@ use super::{ SKILLS_DIR_NAME, WORKSPACE_MEMORY_DIR_NAME, }; use crate::client::ProviderModels; +use crate::config::REPL_HISTORY_DIR_NAME; +use crate::config::session::Session; use crate::utils::{get_env_name, list_file_names, normalize_env_name}; use anyhow::{Context, Result, anyhow, bail}; @@ -320,6 +322,20 @@ pub fn workspace_memory_dir_for(workspace_root: &Path) -> PathBuf { .join(MEMORY_DIR_NAME) } +pub fn repl_history_dir() -> PathBuf { + cache_path().join(REPL_HISTORY_DIR_NAME) +} + +pub fn repl_history_file(session: &Option) -> PathBuf { + let history_key = if let Some(session) = &session { + format!("session_{}", session.name().replace('/', "_")) + } else { + "default".to_string() + }; + + repl_history_dir().join(history_key) +} + pub fn log_config() -> Result<(LevelFilter, Option)> { let log_level = env::var(get_env_name("log_level")) .ok() diff --git a/src/repl/mod.rs b/src/repl/mod.rs index 5c41613..4193750 100644 --- a/src/repl/mod.rs +++ b/src/repl/mod.rs @@ -449,7 +449,8 @@ Type ".help" for additional help. } if app.save_shell_history { - let history_path = paths::config_dir().join("repl_history"); + let ctx = ctx.read(); + let history_path = paths::repl_history_file(&ctx.session); if let Ok(history) = FileBackedHistory::with_file(1000, history_path) { editor = editor.with_history(Box::new(history)); }