@@ -2315,8 +2315,8 @@ fn dropped_tool_call_ids(
23152315#[ cfg( test) ]
23162316mod root_thread_id_tests {
23172317 use super :: {
2318- is_root_session_thread_id, MemoryMessage , NotificationRecord , SharedReply ,
2319- SqliteMemoryActor ,
2318+ is_root_session_thread_id, BackgroundJobRecord , ClarificationTicketRecord , MemoryMessage ,
2319+ NotificationRecord , SharedReply , SqliteMemoryActor ,
23202320 } ;
23212321 use crate :: session:: SessionManager ;
23222322 use crate :: traits:: Memory ;
@@ -2391,6 +2391,98 @@ mod root_thread_id_tests {
23912391
23922392 assert_eq ! ( rows. len( ) , 1 ) ;
23932393 assert_eq ! ( rows[ 0 ] . notification_id, "tauri-notification" ) ;
2394+
2395+ for ( id, channel, updated_at_ms) in [
2396+ ( "tauri-job" , "tauri" , 1_i64 ) ,
2397+ ( "terminal-job" , "terminal" , 2_i64 ) ,
2398+ ] {
2399+ let ( tx, rx) = tokio:: sync:: oneshot:: channel ( ) ;
2400+ node. send_packet ( MemoryMessage :: UpsertBackgroundJob {
2401+ record : BackgroundJobRecord {
2402+ job_id : id. to_string ( ) ,
2403+ kind : "test" . to_string ( ) ,
2404+ chat_id : "chat-1" . to_string ( ) ,
2405+ channel : channel. to_string ( ) ,
2406+ thread_id : None ,
2407+ state : "waiting" . to_string ( ) ,
2408+ payload_json : "{}" . to_string ( ) ,
2409+ resume_after_restart : false ,
2410+ detached : false ,
2411+ last_error : None ,
2412+ created_at_ms : updated_at_ms,
2413+ updated_at_ms,
2414+ } ,
2415+ reply : SharedReply :: new ( tx) ,
2416+ } )
2417+ . await
2418+ . expect ( "enqueue background job" ) ;
2419+ rx. await
2420+ . expect ( "background job actor reply" )
2421+ . expect ( "insert background job" ) ;
2422+ }
2423+
2424+ let ( tx, rx) = tokio:: sync:: oneshot:: channel ( ) ;
2425+ node. send_packet ( MemoryMessage :: ListBackgroundJobs {
2426+ chat_id : None ,
2427+ channel : Some ( "tauri" . to_string ( ) ) ,
2428+ limit : 1 ,
2429+ reply : SharedReply :: new ( tx) ,
2430+ } )
2431+ . await
2432+ . expect ( "enqueue background job list" ) ;
2433+ let jobs = rx
2434+ . await
2435+ . expect ( "background job actor reply" )
2436+ . expect ( "list background jobs" ) ;
2437+ assert_eq ! ( jobs. len( ) , 1 ) ;
2438+ assert_eq ! ( jobs[ 0 ] . job_id, "tauri-job" ) ;
2439+
2440+ for ( id, channel, updated_at_ms) in [
2441+ ( "tauri-ticket" , "tauri" , 1_i64 ) ,
2442+ ( "terminal-ticket" , "terminal" , 2_i64 ) ,
2443+ ] {
2444+ let ( tx, rx) = tokio:: sync:: oneshot:: channel ( ) ;
2445+ node. send_packet ( MemoryMessage :: UpsertClarificationTicket {
2446+ record : ClarificationTicketRecord {
2447+ ticket_id : id. to_string ( ) ,
2448+ job_id : id. to_string ( ) ,
2449+ chat_id : "chat-1" . to_string ( ) ,
2450+ channel : channel. to_string ( ) ,
2451+ thread_id : None ,
2452+ tool_call_id : None ,
2453+ prompt : "Test" . to_string ( ) ,
2454+ choices_json : None ,
2455+ response : None ,
2456+ status : "waiting" . to_string ( ) ,
2457+ created_at_ms : updated_at_ms,
2458+ updated_at_ms,
2459+ } ,
2460+ reply : SharedReply :: new ( tx) ,
2461+ } )
2462+ . await
2463+ . expect ( "enqueue clarification ticket" ) ;
2464+ rx. await
2465+ . expect ( "clarification ticket actor reply" )
2466+ . expect ( "insert clarification ticket" ) ;
2467+ }
2468+
2469+ let ( tx, rx) = tokio:: sync:: oneshot:: channel ( ) ;
2470+ node. send_packet ( MemoryMessage :: ListClarificationTickets {
2471+ job_id : None ,
2472+ chat_id : None ,
2473+ channel : Some ( "tauri" . to_string ( ) ) ,
2474+ status : None ,
2475+ limit : 1 ,
2476+ reply : SharedReply :: new ( tx) ,
2477+ } )
2478+ . await
2479+ . expect ( "enqueue clarification ticket list" ) ;
2480+ let tickets = rx
2481+ . await
2482+ . expect ( "clarification ticket actor reply" )
2483+ . expect ( "list clarification tickets" ) ;
2484+ assert_eq ! ( tickets. len( ) , 1 ) ;
2485+ assert_eq ! ( tickets[ 0 ] . ticket_id, "tauri-ticket" ) ;
23942486 }
23952487
23962488 #[ tokio:: test]
0 commit comments