@@ -117,8 +117,11 @@ fn main_state(app: tauri::AppHandle) -> std::result::Result<ui::MainState, Strin
117117}
118118
119119/// Start desktop widget windows after the main page has painted its first frame.
120+ ///
121+ /// Run outside the WebView IPC callback so scheduling window creation on the
122+ /// main thread cannot reenter WebView2 while processing that callback.
120123#[ tauri:: command]
121- fn main_painted (
124+ async fn main_painted (
122125 window : tauri:: WebviewWindow ,
123126 app : tauri:: AppHandle ,
124127) -> std:: result:: Result < bool , String > {
@@ -181,8 +184,9 @@ async fn set_github_token(
181184 . map_err ( |error| error. to_string ( ) )
182185}
183186
187+ // Widget mutations schedule window creation and must also leave the IPC callback.
184188#[ tauri:: command]
185- fn set_widget_enabled (
189+ async fn set_widget_enabled (
186190 app : tauri:: AppHandle ,
187191 id : String ,
188192 enabled : bool ,
@@ -191,12 +195,15 @@ fn set_widget_enabled(
191195}
192196
193197#[ tauri:: command]
194- fn delete_widget ( app : tauri:: AppHandle , id : String ) -> std:: result:: Result < ( ) , String > {
198+ async fn delete_widget ( app : tauri:: AppHandle , id : String ) -> std:: result:: Result < ( ) , String > {
195199 ui:: delete_widget ( & app, & id) . map_err ( |error| error. to_string ( ) )
196200}
197201
198202#[ tauri:: command]
199- fn restore_widget ( app : tauri:: AppHandle , trash_name : String ) -> std:: result:: Result < ( ) , String > {
203+ async fn restore_widget (
204+ app : tauri:: AppHandle ,
205+ trash_name : String ,
206+ ) -> std:: result:: Result < ( ) , String > {
200207 ui:: restore_widget ( & app, & trash_name) . map_err ( |error| error. to_string ( ) )
201208}
202209
@@ -209,7 +216,7 @@ fn deleted_widget_preview(
209216}
210217
211218#[ tauri:: command]
212- fn purge_deleted_widget (
219+ async fn purge_deleted_widget (
213220 app : tauri:: AppHandle ,
214221 trash_name : String ,
215222) -> std:: result:: Result < ( ) , String > {
0 commit comments