the runtime your coding agents live on
Rust agentagent-orchestrationaiai-agentsclaude-codeclicodexcoding-agentsdeveloper-toolsdevtoolsmultiplexerrustterminalterminal-multiplexerterminal-uitmuxtuiworkspace-manager
merge: reload keybinds
Ogulcan Celikb5b61c14841f
diff --cc src/app/mod.rsindex 87af63e52,842c91f94..a39ed4363--- a/src/app/mod.rs+++ b/src/app/mod.rs@@@ -2442,6 -2467,79 +2478,86 @@@ mod tests)}+ fn config_env_lock() -> &'static Mutex<()> {+ static LOCK: OnceLock<Mutex<()>> = OnceLock::new();+ LOCK.get_or_init(|| Mutex::new(()))+ }++ fn temp_config_path(name: &str) -> std::path::PathBuf {+ let unique = format!(+ "herdr-{name}-{}-{}",+ std::process::id(),+ std::time::SystemTime::now()+ .duration_since(std::time::UNIX_EPOCH)+ .unwrap()+ .as_nanos()+ );+ std::env::temp_dir().join(unique).join("config.toml")+ }++ #[test]+ fn reload_keybinds_updates_live_state() {+ let _guard = config_env_lock().lock().unwrap();+ let path = temp_config_path("reload-keybinds-success");+ std::fs::create_dir_all(path.parent().unwrap()).unwrap();- std::fs::write(&path, "[keys]\nnew_workspace = \"g\"\nprefix = \"ctrl+a\"\n").unwrap();++ std::fs::write(++ &path,++ "[keys]\nnew_workspace = \"g\"\nprefix = \"ctrl+a\"\n",++ )++ .unwrap();+ std::env::set_var(crate::config::CONFIG_PATH_ENV_VAR, &path);++ let mut app = test_app();+ app.reload_keybinds();++ assert_eq!(app.state.prefix_code, KeyCode::Char('a'));+ assert_eq!(app.state.prefix_mods, KeyModifiers::CONTROL);+ assert_eq!(+ app.state.keybinds.new_workspace,+ (KeyCode::Char('g'), KeyModifiers::empty())+ );+ assert!(app.state.config_diagnostic.is_none());+ let toast = app.state.toast.as_ref().unwrap();+ assert_eq!(toast.kind, crate::app::state::ToastKind::UpdateInstalled);+ assert_eq!(toast.title, "reloaded keybinds");+ assert_eq!(toast.context, "using config.toml");++ std::env::remove_var(crate::config::CONFIG_PATH_ENV_VAR);+ let _ = std::fs::remove_dir_all(path.parent().unwrap());+ }++ #[test]+ fn reload_keybinds_keeps_current_state_on_invalid_binding() {+ let _guard = config_env_lock().lock().unwrap();+ let path = temp_config_path("reload-keybinds-invalid");+ std::fs::create_dir_all(path.parent().unwrap()).unwrap();+ std::fs::write(&path, "[keys]\nnew_workspace = \"wat\"\n").unwrap();+ std::env::set_var(crate::config::CONFIG_PATH_ENV_VAR, &path);++ let mut app = test_app();+ let original_prefix = (app.state.prefix_code, app.state.prefix_mods);+ let original_keybinds = app.state.keybinds.new_workspace;+ app.reload_keybinds();+- assert_eq!((app.state.prefix_code, app.state.prefix_mods), original_prefix);++ assert_eq!(++ (app.state.prefix_code, app.state.prefix_mods),++ original_prefix++ );+ assert_eq!(app.state.keybinds.new_workspace, original_keybinds);+ assert!(app+ .state+ .config_diagnostic+ .as_deref()+ .is_some_and(|message| {+ message.contains("keys.new_workspace")+ && message.contains("keeping current keybinds")+ }));+ assert!(app.state.toast.is_none());++ std::env::remove_var(crate::config::CONFIG_PATH_ENV_VAR);+ let _ = std::fs::remove_dir_all(path.parent().unwrap());+ }+#[tokio::test]async fn raw_input_waits_when_reader_is_gone() {let result =diff --cc src/config.rsindex bd6b93b95,9992db282..b57d67f43--- a/src/config.rs+++ b/src/config.rs@@@ -819,6 -835,19 +835,25 @@@ pub fn config_path() -> PathBufconfig_dir().join("config.toml")}+ pub fn load_live_keybinds() -> Result<LiveKeybindConfig, Vec<String>> {+ let path = config_path();+ if !path.exists() {+ return Config::default().live_keybinds();+ }+- let content = std::fs::read_to_string(&path)- .map_err(|err| vec![format!("config read error: {err}; keeping current keybinds")])?;- let config = toml::from_str::<Config>(&content)- .map_err(|err| vec![format!("config parse error: {err}; keeping current keybinds")])?;++ let content = std::fs::read_to_string(&path).map_err(|err| {++ vec![format!(++ "config read error: {err}; keeping current keybinds"++ )]++ })?;++ let config = toml::from_str::<Config>(&content).map_err(|err| {++ vec![format!(++ "config parse error: {err}; keeping current keybinds"++ )]++ })?;+ config.live_keybinds()+ }+fn upsert_top_level_bool(content: &str, key: &str, value: bool) -> String {let replacement = format!("{key} = {value}");let mut lines: Vec<String> = content.lines().map(|line| line.to_string()).collect();