diff --git a/frontend/src-tauri/build.rs b/frontend/src-tauri/build.rs index 536a2dbfe..397a6dfdb 100644 --- a/frontend/src-tauri/build.rs +++ b/frontend/src-tauri/build.rs @@ -6,6 +6,13 @@ fn main() { println!("cargo:rustc-link-lib=c++"); } + let target_arch = std::env::var("CARGO_CFG_TARGET_ARCH").unwrap_or_default(); + let target_env = std::env::var("CARGO_CFG_TARGET_ENV").unwrap_or_default(); + if target_os == "windows" && target_arch == "x86_64" && target_env == "msvc" { + const WINDOWS_STACK_RESERVE_BYTES: usize = 8 * 1024 * 1024; + println!("cargo:rustc-link-arg-bin=maple=/STACK:{WINDOWS_STACK_RESERVE_BYTES}"); + } + tauri_build::build(); // The deep-link plugin's build.rs overwrites CFBundleURLTypes in Info.plist diff --git a/frontend/src-tauri/src/agent_tauri.rs b/frontend/src-tauri/src/agent_tauri.rs index ef6c28e7b..dec6daf67 100644 --- a/frontend/src-tauri/src/agent_tauri.rs +++ b/frontend/src-tauri/src/agent_tauri.rs @@ -10,6 +10,7 @@ use crate::agent::{ }; use crate::agent_host::{AgentHostLifecycle, AgentRuntimeLifecycleOutcome}; use crate::maple_api::MapleApiAuthState; +use futures_util::future::BoxFuture; use serde::Serialize; use std::sync::Arc; use tauri::{AppHandle, Emitter, State}; @@ -393,18 +394,25 @@ pub async fn agent_save_project_root_order( .await } -#[tauri::command] -pub async fn agent_create_session( +#[deny(clippy::large_futures, clippy::large_stack_frames)] +#[tauri::command(async)] +pub fn agent_create_session( app_handle: AppHandle, state: State<'_, MapleAgentService>, user_id: String, request: Option, -) -> Result { +) -> BoxFuture<'static, Result> { let _ = app_handle; - handle_for_user(&state, &user_id) - .await? - .create_session(request) - .await + let service = MapleAgentService::clone(state.inner()); + Box::pin(async move { + let handle = service.handle_for_user(&user_id).await?; + #[allow( + clippy::large_futures, + reason = "the enclosing command future is heap-boxed before it crosses Tauri" + )] + let result = handle.create_session(request).await; + result + }) } #[tauri::command] @@ -641,6 +649,22 @@ mod tests { use serde_json::json; use std::collections::HashMap; + #[test] + fn create_session_command_keeps_the_tauri_boundary_boxed() { + let _: for<'a> fn( + AppHandle, + State<'a, MapleAgentService>, + String, + Option, + ) -> std::pin::Pin< + Box< + dyn std::future::Future> + + Send + + 'static, + >, + > = agent_create_session; + } + #[test] fn service_events_project_to_the_stable_desktop_wire_contract() { let status = AgentRuntimeStatus {