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 result
} }
FrontendMode::Gui => { FrontendMode::Gui => {
// GUI runs on the main thread (Wayland requirement).
// Spawn the core event loop on a background task. // Spawn the core event loop on a background task.
let menu_handle = tokio::spawn(menu.run()); let menu_handle = tokio::spawn(menu.run());
// pikl_gui::run blocks until the user confirms/cancels. // macOS requires the GUI event loop on the main thread
// Run it on a blocking thread so we don't stall the // (AppKit constraint). block_on runs on the main thread,
// tokio runtime. // so calling the GUI directly here satisfies that.
let gui_handle = tokio::task::spawn_blocking(move || { // 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) 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 { #[cfg(not(target_os = "macos"))]
return Err(PiklError::Io(std::io::Error::other(e.to_string()))); {
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. // Wait for core to finish.