mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-08-04 19:45:34 +08:00
feat(opencode): sync all providers to live config on directory change
Add additive mode support for OpenCode in sync_current_to_live: - Add AppType::is_additive_mode() to distinguish switch vs additive mode - Add AppType::all() iterator to avoid hardcoding app lists - Add sync_all_providers_to_live() for additive mode apps - Refactor sync_current_to_live to handle both modes Frontend changes (directory settings): - Track opencodeDirChanged in useDirectorySettings - Trigger syncCurrentProvidersLiveSafe when OpenCode dir changes - Add i18n strings for OpenCode directory settings
This commit is contained in:
@@ -282,6 +282,25 @@ impl AppType {
|
||||
AppType::OpenCode => "opencode",
|
||||
}
|
||||
}
|
||||
|
||||
/// Check if this app uses additive mode
|
||||
///
|
||||
/// - Switch mode (false): Only the current provider is written to live config (Claude, Codex, Gemini)
|
||||
/// - Additive mode (true): All providers are written to live config (OpenCode)
|
||||
pub fn is_additive_mode(&self) -> bool {
|
||||
matches!(self, AppType::OpenCode)
|
||||
}
|
||||
|
||||
/// Return an iterator over all app types
|
||||
pub fn all() -> impl Iterator<Item = AppType> {
|
||||
[
|
||||
AppType::Claude,
|
||||
AppType::Codex,
|
||||
AppType::Gemini,
|
||||
AppType::OpenCode,
|
||||
]
|
||||
.into_iter()
|
||||
}
|
||||
}
|
||||
|
||||
impl FromStr for AppType {
|
||||
|
||||
Reference in New Issue
Block a user