File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -40,3 +40,11 @@ test('close confirm dialog reads close action values from query params instead o
4040 assert . doesNotMatch ( html , / s u b m i t \( " t r a y " \) / ) ;
4141 assert . doesNotMatch ( html , / s u b m i t \( " e x i t " \) / ) ;
4242} ) ;
43+
44+ test ( 'close confirm dialog only schedules frontend close fallback for tray actions' , async ( ) => {
45+ const html = await readHtml ( ) ;
46+
47+ assert . match ( html , / i f \( a c t i o n = = = t r a y A c t i o n \) \{ / ) ;
48+ assert . match ( html , / r e c o v e r y T i m e r = w i n d o w \. s e t T i m e o u t \( / ) ;
49+ assert . match ( html , / w i n d o w \. c l o s e \( \) ; / ) ;
50+ } ) ;
Original file line number Diff line number Diff line change @@ -339,8 +339,12 @@ pub(crate) fn desktop_bridge_submit_close_prompt(
339339 append_desktop_log,
340340 ) {
341341 append_desktop_log ( & format ! (
342- "failed to persist remembered close action; continuing with selected action: {error}"
342+ "failed to persist remembered close action; aborting selected action: {error}"
343343 ) ) ;
344+ return BackendBridgeResult {
345+ ok : false ,
346+ reason : Some ( error) ,
347+ } ;
344348 }
345349 }
346350
@@ -362,6 +366,15 @@ pub(crate) fn desktop_bridge_submit_close_prompt(
362366 finish_tray_close_prompt_cleanup ( cleanup_result, append_desktop_log)
363367 }
364368 CloseAction :: Exit => {
369+ if let Some ( prompt_window) =
370+ app_handle. get_webview_window ( window:: close_confirm:: CLOSE_CONFIRM_WINDOW_LABEL )
371+ {
372+ if let Err ( error) = prompt_window. close ( ) {
373+ append_desktop_log ( & format ! (
374+ "Failed to close confirm prompt window before exit: {error}"
375+ ) ) ;
376+ }
377+ }
365378 crate :: lifecycle:: events:: request_immediate_exit (
366379 & app_handle,
367380 crate :: lifecycle:: events:: ImmediateExitTrigger :: ClosePromptExitAction ,
Original file line number Diff line number Diff line change @@ -147,8 +147,9 @@ where
147147{
148148 let Some ( state_path) = crate :: desktop_state:: resolve_desktop_state_path ( packaged_root_dir)
149149 else {
150- log ( "close behavior state path is unavailable; skipping close action persistence" ) ;
151- return Ok ( ( ) ) ;
150+ let message = "close behavior state path is unavailable; skipping close action persistence" ;
151+ log ( message) ;
152+ return Err ( message. to_string ( ) ) ;
152153 } ;
153154
154155 write_cached_close_action_at_path ( action, & state_path, & log)
@@ -379,4 +380,17 @@ mod tests {
379380 None
380381 ) ;
381382 }
383+
384+ #[ test]
385+ fn write_cached_close_action_errors_when_state_path_is_unavailable ( ) {
386+ let result = super :: write_cached_close_action ( Some ( CloseAction :: Tray ) , None , & noop_log) ;
387+
388+ assert_eq ! (
389+ result,
390+ Err (
391+ "close behavior state path is unavailable; skipping close action persistence"
392+ . to_string( )
393+ )
394+ ) ;
395+ }
382396}
Original file line number Diff line number Diff line change @@ -243,16 +243,18 @@ <h1 id="title"></h1>
243243 return ;
244244 }
245245
246- recoveryTimer = window . setTimeout ( ( ) => {
247- recoveryTimer = null ;
248- if ( document . visibilityState !== "hidden" ) {
249- error . textContent = copy . submitStalled ;
250- setPending ( false ) ;
246+ if ( action === trayAction ) {
247+ recoveryTimer = window . setTimeout ( ( ) => {
248+ recoveryTimer = null ;
249+ if ( document . visibilityState !== "hidden" ) {
250+ error . textContent = copy . submitStalled ;
251+ setPending ( false ) ;
252+ }
253+ } , 1500 ) ;
254+
255+ if ( typeof window . close === "function" ) {
256+ window . close ( ) ;
251257 }
252- } , 1500 ) ;
253-
254- if ( typeof window . close === "function" ) {
255- window . close ( ) ;
256258 }
257259 } catch ( _invokeError ) {
258260 error . textContent = copy . submitError ;
You can’t perform that action at this time.
0 commit comments