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
7 changes: 7 additions & 0 deletions frontend/src-tauri/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
38 changes: 31 additions & 7 deletions frontend/src-tauri/src/agent_tauri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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<AgentCreateSessionRequest>,
) -> Result<AgentSessionDetail, String> {
) -> BoxFuture<'static, Result<AgentSessionDetail, String>> {
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]
Expand Down Expand Up @@ -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<AgentCreateSessionRequest>,
) -> std::pin::Pin<
Box<
dyn std::future::Future<Output = Result<AgentSessionDetail, String>>
+ Send
+ 'static,
>,
> = agent_create_session;
}

#[test]
fn service_events_project_to_the_stable_desktop_wire_contract() {
let status = AgentRuntimeStatus {
Expand Down
Loading