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
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
*.sh text eol=lf
.github/workflows/*.yml text eol=lf

# First-party scripts are embedded with include_str! and inspected by source-contract tests.
assets/inject/*.js text eol=lf

# Keep every byte-exact upstream theme asset stable on all checkout platforms.
assets/inject/upstream/**/*.js text eol=lf
assets/inject/upstream/**/*.css text eol=lf
Expand Down
54 changes: 35 additions & 19 deletions apps/codex-plus-launcher/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,16 +188,13 @@ async fn activate_existing_codex_app(options: &LaunchOptions) -> anyhow::Result<
hooks.start_helper(helper_port).await?;
}
let process_ids = codex_plus_core::watcher::find_codex_processes();
let mut activated = false;
#[cfg(windows)]
{
for process_id in &process_ids {
if codex_plus_core::windows_activate_process_window(*process_id) {
activated = true;
break;
}
}
}
let activated = process_ids
.iter()
.copied()
.any(codex_plus_core::windows_activate_process_window);
#[cfg(not(windows))]
let activated = false;
let injection_ready = if settings.enhancements_enabled {
hooks
.ensure_injection(options.debug_port, helper_port, &app_dir)
Expand Down Expand Up @@ -801,27 +798,46 @@ impl BridgeRuntimeService for LauncherRuntimeService {
}))
}

async fn open_manager(&self) -> anyhow::Result<Value> {
let target = codex_plus_core::install::spawn_companion(
codex_plus_core::install::MANAGER_BINARY,
std::iter::empty::<&str>(),
)
.map_err(|error| anyhow::anyhow!("启动管理工具失败:{error}"))?;
async fn open_manager(&self, payload: Value) -> anyhow::Result<Value> {
let navigation =
codex_plus_core::manager_navigation::save_pending_manager_navigation_from_payload(
&payload,
)?;
let target = codex_plus_core::install::open_or_activate_manager()
.map_err(|error| anyhow::anyhow!("启动管理工具失败:{error}"))
.map_err(|error| {
codex_plus_core::manager_navigation::rollback_pending_manager_navigation_after_launch_failure(
navigation.as_ref(),
error,
)
})?;
Ok(json!({
"status": "ok",
"path": target
"path": target,
"navigation": navigation
}))
}

async fn open_transient_manager(&self) -> anyhow::Result<Value> {
async fn open_transient_manager(&self, payload: Value) -> anyhow::Result<Value> {
let navigation =
codex_plus_core::manager_navigation::save_pending_manager_navigation_from_payload(
&payload,
)?;
let target = codex_plus_core::install::spawn_companion(
codex_plus_core::install::MANAGER_BINARY,
["--transient"],
)
.map_err(|error| anyhow::anyhow!("启动管理工具失败:{error}"))?;
.map_err(|error| anyhow::anyhow!("启动管理工具失败:{error}"))
.map_err(|error| {
codex_plus_core::manager_navigation::rollback_pending_manager_navigation_after_launch_failure(
navigation.as_ref(),
error,
)
})?;
Ok(json!({
"status": "ok",
"path": target
"path": target,
"navigation": navigation
}))
}

Expand Down
30 changes: 29 additions & 1 deletion apps/codex-plus-manager/src-tauri/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,13 @@ pub fn startup_options() -> CommandResult<StartupPayload> {
)
}

#[tauri::command]
pub fn consume_pending_manager_navigation()
-> Result<Option<codex_plus_core::manager_navigation::ManagerNavigationIntent>, String> {
codex_plus_core::manager_navigation::consume_pending_manager_navigation()
.map_err(|error| error.to_string())
}

pub fn startup_should_show_update() -> bool {
should_show_update(
std::env::args(),
Expand Down Expand Up @@ -3505,6 +3512,9 @@ pub async fn test_relay_profile(profile: RelayProfile) -> CommandResult<RelayPro
pub async fn test_stepwise_settings(
settings: BackendSettings,
) -> CommandResult<StepwiseTestPayload> {
let configured_protocol = codex_plus_core::settings::normalize_stepwise_protocol(
&settings.codex_app_stepwise_protocol,
);
match codex_plus_core::stepwise::test_connection(&settings).await {
Ok(result) => {
let error = result
Expand All @@ -3517,9 +3527,17 @@ pub async fn test_stepwise_settings(
.and_then(Value::as_array)
.map(Vec::len)
.unwrap_or_default();
let protocol = result
.get("protocol")
.and_then(Value::as_str)
.unwrap_or(&configured_protocol)
.to_string();
if error.is_empty() {
ok(
&format!("Stepwise 连接正常,测试返回 {item_count} 条建议。"),
&format!(
"Stepwise 连接正常({}),测试返回 {item_count} 条建议。",
stepwise_protocol_label(&protocol)
),
StepwiseTestPayload { item_count, error },
)
} else {
Expand All @@ -3539,6 +3557,16 @@ pub async fn test_stepwise_settings(
}
}

fn stepwise_protocol_label(protocol: &str) -> &str {
match protocol {
"chat_completions" => "Chat Completions",
"responses" => "Responses",
"anthropic_messages" => "Anthropic Messages",
"auto" => "自动兼容",
_ => protocol,
}
}

#[tauri::command]
pub async fn fetch_relay_profile_models(
profile: RelayProfile,
Expand Down
8 changes: 7 additions & 1 deletion apps/codex-plus-manager/src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::sync::atomic::{AtomicBool, Ordering};

use tauri::menu::{Menu, MenuItem};
use tauri::tray::{MouseButton, MouseButtonState, TrayIconBuilder, TrayIconEvent};
use tauri::{Manager, WindowEvent};
use tauri::{Emitter, Manager, WindowEvent};

const TRAY_ID: &str = "codex_plus_tray";

Expand All @@ -14,6 +14,7 @@ const TRAY_MENU_SHOW: &str = "tray_show_main";
const TRAY_MENU_DREAM_SKIN_APPLY: &str = "tray_apply_dream_skin";
const TRAY_MENU_QUIT: &str = "tray_quit_app";
const DREAM_SKIN_DEBUG_PORT: u16 = 9229;
const MANAGER_NAVIGATION_EVENT: &str = "manager-navigation-requested";

pub fn run() {
install_panic_logger();
Expand Down Expand Up @@ -64,6 +65,7 @@ pub fn run() {
.invoke_handler(tauri::generate_handler![
commands::backend_version,
commands::startup_options,
commands::consume_pending_manager_navigation,
commands::load_overview,
commands::launch_codex_plus,
commands::restart_codex_plus,
Expand Down Expand Up @@ -263,13 +265,17 @@ fn register_main_window_events<R: tauri::Runtime>(
let minimized_window = event_window.clone();
let close_event_window = event_window.clone();
let close_event_app = event_window.app_handle().clone();
let focus_event_window = event_window.clone();

event_window.on_window_event(move |event| match event {
WindowEvent::Resized(_) => {
if matches!(minimized_window.is_minimized(), Ok(true)) {
let _ = minimized_window.hide();
}
}
WindowEvent::Focused(true) => {
let _ = focus_event_window.emit(MANAGER_NAVIGATION_EVENT, ());
}
WindowEvent::CloseRequested { api, .. } => {
if APP_EXITING.load(Ordering::SeqCst) {
return;
Expand Down
Loading
Loading