Skip to content
Merged
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
16 changes: 14 additions & 2 deletions apps/codex-plus-launcher/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -986,6 +986,15 @@ async fn activate_existing_codex_app(options: &LaunchOptions) -> anyhow::Result<
// 于是「切换登录方式后 model_provider 没跟着切换」「历史会话没被自动修复」,
// 只有管理工具的「重启」才生效(issue #2080)。失败不阻断激活,只记日志。
run_activation_provider_sync(&hooks, &settings).await;
if let Err(error) = codex_plus_core::relay_config::ensure_managed_session_provider_in_home(
&codex_plus_core::relay_config::default_codex_home_dir(),
&settings,
) {
let _ = codex_plus_core::diagnostic_log::append_diagnostic_log(
"launcher.managed_session_provider_repair_failed",
json!({ "message": error.to_string(), "phase": "activate_existing" }),
);
}
let launch_result = hooks
.launch_codex(
&app_dir,
Expand Down Expand Up @@ -1114,8 +1123,11 @@ impl LaunchHooks for LauncherHooks {
}
}

fn cleanup_unsupported_config(&self) -> anyhow::Result<()> {
self.core.cleanup_unsupported_config()
fn cleanup_unsupported_config(
&self,
settings: &codex_plus_core::settings::BackendSettings,
) -> anyhow::Result<()> {
self.core.cleanup_unsupported_config(settings)
}

async fn run_provider_sync(&self) -> anyhow::Result<()> {
Expand Down
14 changes: 11 additions & 3 deletions crates/codex-plus-core/src/launcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ pub trait LaunchHooks: Send + Sync {
async fn load_settings(&self) -> anyhow::Result<BackendSettings>;
async fn start_native_browser_compatibility(&self, _settings: &BackendSettings) {}
async fn stop_native_browser_compatibility(&self) {}
fn cleanup_unsupported_config(&self) -> anyhow::Result<()> {
fn cleanup_unsupported_config(&self, _settings: &BackendSettings) -> anyhow::Result<()> {
Ok(())
}
async fn run_provider_sync(&self) -> anyhow::Result<()>;
Expand Down Expand Up @@ -847,7 +847,7 @@ where
hooks.start_native_browser_compatibility(&settings).await;
let home = crate::relay_config::default_codex_home_dir();
timeline.mark("cleanup_unsupported_config", 10);
hooks.cleanup_unsupported_config()?;
hooks.cleanup_unsupported_config(&settings)?;
crate::relay_config::ensure_windows_sandbox_usable_for_current_user(&home)?;
if settings.provider_sync_enabled {
timeline.mark("provider_sync", 15);
Expand Down Expand Up @@ -1221,9 +1221,17 @@ impl LaunchHooks for DefaultLaunchHooks {
SettingsStore::default().load()
}

fn cleanup_unsupported_config(&self) -> anyhow::Result<()> {
fn cleanup_unsupported_config(&self, settings: &BackendSettings) -> anyhow::Result<()> {
let home = crate::relay_config::default_codex_home_dir();
crate::relay_config::cleanup_unsupported_approval_policies_in_home(&home)?;
if let Err(error) =
crate::relay_config::ensure_managed_session_provider_in_home(&home, settings)
{
let _ = crate::diagnostic_log::append_diagnostic_log(
"launcher.managed_session_provider_repair_failed",
serde_json::json!({ "message": error.to_string() }),
);
}
Ok(())
}

Expand Down
Loading
Loading