fix(remote): run commands on the main thread after authorization (#600)

Authorization for a remote window resumes on a Tokio worker, so the generated handler ran synchronous commands there, including ones reaching AppKit such as the clipboard check, while local windows run them on the main thread. The handler is now dispatched back to the main thread after authorization, and the request is rejected if dispatch fails.

Two app aborts seen in remote windows unwound through this task. The abort was not reproduced and its throw site is unconfirmed. Logging confirmed the thread change. An audit found no remote-only blocking path in the synchronous commands that move to the main thread.
Цей коміт міститься в:
l0ng-ai authored and GitHub committed 2026-11-01 01:31:01 +08:00
1 джерело 1d937d52e5
коміт b3c3150489
1 file changed
+10 -1
+10 -1
Переглянути файл
@@ -95,10 +95,19 @@ pub fn run() {
let label = label.to_owned();
let command = request.message.command().to_owned();
let invoke = invoke.clone();
let app = webview.app_handle().clone();
tauri::async_runtime::spawn(async move {
match connection.authorize_command(&label, &command).await {
Ok(()) => {
invoke(request);
let resolver = request.resolver.clone();
// Sync commands must run on the main thread, as they do in local windows.
if let Err(error) = app.run_on_main_thread(move || {
invoke(request);
}) {
resolver.reject(ide_core::IdeError::internal(format!(
"failed to dispatch command on the main thread: {error}"
)));
}
}
Err(error) => request.resolver.reject(error),
}