@@ -337,16 +337,22 @@ fn test_new_for_remote_restores_spawn_startup_hints_and_dispatch_state() {
337337 super :: commands:: build_autojudge_startup_message ( "session_parent_123" ) ,
338338 ) ;
339339
340- let app = App :: new_for_remote ( Some ( session_id. to_string ( ) ) ) ;
340+ let mut app = App :: new_for_remote ( Some ( session_id. to_string ( ) ) ) ;
341+ let rt = tokio:: runtime:: Runtime :: new ( ) . unwrap ( ) ;
342+ let _guard = rt. enter ( ) ;
343+ let mut remote = crate :: tui:: backend:: RemoteConnection :: dummy ( ) ;
341344
342- assert ! ( app. pending_queued_dispatch) ;
343- assert ! ( app. is_processing( ) ) ;
344- assert ! ( app. processing_started. is_some ( ) ) ;
345+ assert ! ( ! app. pending_queued_dispatch) ;
346+ assert ! ( ! app. is_processing( ) ) ;
347+ assert ! ( app. processing_started. is_none ( ) ) ;
345348 assert ! ( matches!(
346349 crate :: tui:: TuiState :: status( & app) ,
347- ProcessingStatus :: Sending
350+ ProcessingStatus :: Idle
348351 ) ) ;
349- assert_eq ! ( app. status_notice( ) , Some ( "Autojudge starting" . to_string( ) ) ) ;
352+ assert_eq ! (
353+ app. status_notice( ) ,
354+ Some ( "Restored queued follow-up after reload" . to_string( ) )
355+ ) ;
350356 assert_eq ! ( app. hidden_queued_system_messages. len( ) , 1 ) ;
351357
352358 let startup_banner = app
@@ -363,6 +369,27 @@ fn test_new_for_remote_restores_spawn_startup_hints_and_dispatch_state() {
363369 ) ;
364370 assert ! ( startup_banner. content. contains( "user-visible mirror" ) ) ;
365371 assert ! ( startup_banner. content. contains( "session_parent_123" ) ) ;
372+
373+ rt. block_on ( super :: remote:: process_remote_followups (
374+ & mut app,
375+ & mut remote,
376+ ) ) ;
377+ assert_eq ! ( app. hidden_queued_system_messages. len( ) , 1 ) ;
378+ assert ! ( !app. is_processing( ) ) ;
379+
380+ remote. mark_history_loaded ( ) ;
381+ rt. block_on ( super :: remote:: process_remote_followups (
382+ & mut app,
383+ & mut remote,
384+ ) ) ;
385+
386+ assert ! ( app. hidden_queued_system_messages. is_empty( ) ) ;
387+ assert ! ( app. is_processing( ) ) ;
388+ assert ! ( matches!(
389+ crate :: tui:: TuiState :: status( & app) ,
390+ ProcessingStatus :: Sending
391+ ) ) ;
392+ assert ! ( app. current_message_id. is_some( ) ) ;
366393 } ) ;
367394}
368395
@@ -383,23 +410,39 @@ fn test_remote_startup_done_event_does_not_cancel_pending_judge_launch() {
383410 ) ;
384411
385412 let mut app = App :: new_for_remote ( Some ( session_id. to_string ( ) ) ) ;
413+ let rt = tokio:: runtime:: Runtime :: new ( ) . unwrap ( ) ;
414+ let _guard = rt. enter ( ) ;
386415 let mut remote = crate :: tui:: backend:: RemoteConnection :: dummy ( ) ;
387416
388- assert ! ( app. pending_queued_dispatch) ;
389- assert ! ( app. is_processing( ) ) ;
417+ assert ! ( ! app. pending_queued_dispatch) ;
418+ assert ! ( ! app. is_processing( ) ) ;
390419 assert_eq ! ( app. current_message_id, None ) ;
391420 assert_eq ! ( app. hidden_queued_system_messages. len( ) , 1 ) ;
392421
393422 app. handle_server_event ( crate :: protocol:: ServerEvent :: Done { id : 1 } , & mut remote) ;
394423
395- assert ! ( app. pending_queued_dispatch) ;
396- assert ! ( app. is_processing( ) ) ;
424+ assert ! ( ! app. pending_queued_dispatch) ;
425+ assert ! ( ! app. is_processing( ) ) ;
397426 assert ! ( matches!(
398427 crate :: tui:: TuiState :: status( & app) ,
399- ProcessingStatus :: Sending
428+ ProcessingStatus :: Idle
400429 ) ) ;
401430 assert_eq ! ( app. current_message_id, None ) ;
402431 assert_eq ! ( app. hidden_queued_system_messages. len( ) , 1 ) ;
432+
433+ remote. mark_history_loaded ( ) ;
434+ rt. block_on ( super :: remote:: process_remote_followups (
435+ & mut app,
436+ & mut remote,
437+ ) ) ;
438+
439+ assert ! ( app. hidden_queued_system_messages. is_empty( ) ) ;
440+ assert ! ( app. is_processing( ) ) ;
441+ assert ! ( matches!(
442+ crate :: tui:: TuiState :: status( & app) ,
443+ ProcessingStatus :: Sending
444+ ) ) ;
445+ assert ! ( app. current_message_id. is_some( ) ) ;
403446 } ) ;
404447}
405448
@@ -423,13 +466,19 @@ fn test_remote_startup_judge_hidden_prompt_dispatches_once_history_is_loaded() {
423466 let rt = tokio:: runtime:: Runtime :: new ( ) . unwrap ( ) ;
424467 let _guard = rt. enter ( ) ;
425468 let mut remote = crate :: tui:: backend:: RemoteConnection :: dummy ( ) ;
426- remote. mark_history_loaded ( ) ;
427469
428- assert ! ( app. pending_queued_dispatch) ;
429- assert ! ( app. is_processing( ) ) ;
470+ assert ! ( ! app. pending_queued_dispatch) ;
471+ assert ! ( ! app. is_processing( ) ) ;
430472 assert_eq ! ( app. current_message_id, None ) ;
431473
432- app. pending_queued_dispatch = false ;
474+ rt. block_on ( super :: remote:: process_remote_followups (
475+ & mut app,
476+ & mut remote,
477+ ) ) ;
478+ assert_eq ! ( app. hidden_queued_system_messages. len( ) , 1 ) ;
479+ assert ! ( !app. is_processing( ) ) ;
480+
481+ remote. mark_history_loaded ( ) ;
433482 rt. block_on ( super :: remote:: process_remote_followups (
434483 & mut app,
435484 & mut remote,
@@ -474,10 +523,11 @@ fn test_new_for_remote_fresh_spawn_restores_local_transcript() {
474523 super :: commands:: build_autojudge_startup_message ( "session_parent_123" ) ,
475524 ) ;
476525
477- let app = App :: new_for_remote_with_options ( Some ( session_id. to_string ( ) ) , true ) ;
526+ let mut app = App :: new_for_remote_with_options ( Some ( session_id. to_string ( ) ) , true ) ;
478527
479528 assert_eq ! ( crate :: tui:: TuiState :: provider_model( & app) , "gpt-5.4" ) ;
480- assert ! ( app. pending_queued_dispatch) ;
529+ assert ! ( !app. pending_queued_dispatch) ;
530+ assert ! ( !app. is_processing( ) ) ;
481531 assert_eq ! ( app. hidden_queued_system_messages. len( ) , 1 ) ;
482532 assert_eq ! ( app. display_messages( ) . len( ) , 2 ) ;
483533 assert ! (
@@ -489,6 +539,25 @@ fn test_new_for_remote_fresh_spawn_restores_local_transcript() {
489539 let startup_banner = app. display_messages ( ) . last ( ) . expect ( "startup banner" ) ;
490540 assert_eq ! ( startup_banner. role, "system" ) ;
491541 assert_eq ! ( startup_banner. title. as_deref( ) , Some ( "Autojudge" ) ) ;
542+
543+ let rt = tokio:: runtime:: Runtime :: new ( ) . unwrap ( ) ;
544+ let _guard = rt. enter ( ) ;
545+ let mut remote = crate :: tui:: backend:: RemoteConnection :: dummy ( ) ;
546+ rt. block_on ( super :: remote:: process_remote_followups (
547+ & mut app,
548+ & mut remote,
549+ ) ) ;
550+ assert_eq ! ( app. hidden_queued_system_messages. len( ) , 1 ) ;
551+ assert ! ( !app. is_processing( ) ) ;
552+
553+ remote. mark_history_loaded ( ) ;
554+ rt. block_on ( super :: remote:: process_remote_followups (
555+ & mut app,
556+ & mut remote,
557+ ) ) ;
558+ assert ! ( app. hidden_queued_system_messages. is_empty( ) ) ;
559+ assert ! ( app. is_processing( ) ) ;
560+ assert ! ( app. current_message_id. is_some( ) ) ;
492561 } ) ;
493562}
494563
0 commit comments