Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion src-tauri/src/services/provider/live.rs
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,24 @@ pub(crate) fn write_live_snapshot(app_type: &AppType, provider: &Provider) -> Re
match app_type {
AppType::Claude => {
let path = get_claude_settings_path();
let settings = sanitize_claude_settings_for_live(&provider.settings_config);
let mut settings = sanitize_claude_settings_for_live(&provider.settings_config);

if path.exists() {
if let Ok(existing) = read_json_file::<Value>(&path) {
if let (Some(existing_obj), Some(settings_obj)) =
(existing.as_object(), settings.as_object_mut())
{
for key in ["hooks", "includeCoAuthoredBy"] {
if !settings_obj.contains_key(key) {
if let Some(value) = existing_obj.get(key) {
settings_obj.insert(key.to_string(), value.clone());
}
}
}
}
}
}

write_json_file(&path, &settings)?;
}
AppType::Codex => {
Expand Down
20 changes: 19 additions & 1 deletion src-tauri/tests/provider_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,11 @@ fn provider_service_switch_claude_updates_live_and_state() {
},
"workspace": {
"path": "/tmp/workspace"
}
},
"hooks": {
"before": ["echo hello"]
},
"includeCoAuthoredBy": false
});
std::fs::write(
&settings_path,
Expand Down Expand Up @@ -649,6 +653,20 @@ fn provider_service_switch_claude_updates_live_and_state() {
"live settings.json should reflect new provider auth"
);

assert_eq!(
live_after.get("hooks"),
legacy_live.get("hooks"),
"hooks should be preserved when switching providers"
);

assert_eq!(
live_after
.get("includeCoAuthoredBy")
.and_then(|value| value.as_bool()),
Some(false),
"includeCoAuthoredBy should be preserved when switching providers"
);

let providers = state
.db
.get_all_providers(AppType::Claude.as_str())
Expand Down