From 0e2e005acba7b6c87038becac93de62787b56e1e Mon Sep 17 00:00:00 2001 From: Anthony Ronning <101225832+AnthonyRonning@users.noreply.github.com> Date: Sat, 22 Aug 2026 08:30:03 +0000 Subject: [PATCH 1/3] fix(agent): box session creation at Tauri boundary --- frontend/src-tauri/src/agent_tauri.rs | 35 +++++++++++++++++++++------ 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/frontend/src-tauri/src/agent_tauri.rs b/frontend/src-tauri/src/agent_tauri.rs index ef6c28e7b..eb8b897da 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,22 @@ pub async fn agent_save_project_root_order( .await } -#[tauri::command] -pub async fn agent_create_session( +#[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 { + service + .handle_for_user(&user_id) + .await? + .create_session(request) + .await + }) } #[tauri::command] @@ -641,6 +646,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 { From b5c0fd64024a0ad0894b0d8e39dd0e5e52c60284 Mon Sep 17 00:00:00 2001 From: Anthony Ronning <101225832+AnthonyRonning@users.noreply.github.com> Date: Sat, 22 Aug 2026 08:35:48 +0000 Subject: [PATCH 2/3] build(windows): reserve 8 MiB for Maple stack --- frontend/src-tauri/build.rs | 7 +++++++ 1 file changed, 7 insertions(+) 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 From b5d4d5a7537f1d67fe08fde45d383d7d77f1b2ab Mon Sep 17 00:00:00 2001 From: Anthony Ronning <101225832+AnthonyRonning@users.noreply.github.com> Date: Sat, 22 Aug 2026 08:38:32 +0000 Subject: [PATCH 3/3] lint(agent): guard session command stack shape --- frontend/src-tauri/src/agent_tauri.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/frontend/src-tauri/src/agent_tauri.rs b/frontend/src-tauri/src/agent_tauri.rs index eb8b897da..dec6daf67 100644 --- a/frontend/src-tauri/src/agent_tauri.rs +++ b/frontend/src-tauri/src/agent_tauri.rs @@ -394,6 +394,7 @@ pub async fn agent_save_project_root_order( .await } +#[deny(clippy::large_futures, clippy::large_stack_frames)] #[tauri::command(async)] pub fn agent_create_session( app_handle: AppHandle, @@ -404,11 +405,13 @@ pub fn agent_create_session( let _ = app_handle; let service = MapleAgentService::clone(state.inner()); Box::pin(async move { - service - .handle_for_user(&user_id) - .await? - .create_session(request) - .await + 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 }) }