fix
Some checks failed
CI / Lint (push) Has been cancelled
CI / Test (push) Has been cancelled

This commit is contained in:
2026-03-16 10:11:23 -04:00
parent 5e076b8682
commit 18c98b5469

View File

@@ -662,20 +662,33 @@ async fn run_interactive(
result
}
FrontendMode::Gui => {
// GUI runs on the main thread (Wayland requirement).
// Spawn the core event loop on a background task.
let menu_handle = tokio::spawn(menu.run());
// pikl_gui::run blocks until the user confirms/cancels.
// Run it on a blocking thread so we don't stall the
// tokio runtime.
let gui_handle = tokio::task::spawn_blocking(move || {
// macOS requires the GUI event loop on the main thread
// (AppKit constraint). block_on runs on the main thread,
// so calling the GUI directly here satisfies that.
// Spawned tasks (menu, signals, streaming) continue on
// worker threads.
//
// On Linux, spawn_blocking is fine since Wayland doesn't
// have the main-thread restriction.
#[cfg(target_os = "macos")]
{
pikl_gui::run(action_tx, event_rx)
.map_err(|e| PiklError::Io(std::io::Error::other(e.to_string())))
});
.map_err(|e| PiklError::Io(std::io::Error::other(e.to_string())))?;
}
if let Err(e) = gui_handle.await {
return Err(PiklError::Io(std::io::Error::other(e.to_string())));
#[cfg(not(target_os = "macos"))]
{
let gui_handle = tokio::task::spawn_blocking(move || {
pikl_gui::run(action_tx, event_rx)
.map_err(|e| PiklError::Io(std::io::Error::other(e.to_string())))
});
if let Err(e) = gui_handle.await {
return Err(PiklError::Io(std::io::Error::other(e.to_string())));
}
}
// Wait for core to finish.