@@ -574,21 +574,13 @@ async fn run_ratatui_app(
574574 } ;
575575 match path {
576576 Some ( path) => {
577- let thread_id = if is_uuid {
578- match ThreadId :: from_string ( id_str) {
579- Ok ( thread_id) => thread_id,
580- Err ( _) => return missing_session_exit ( id_str, "fork" ) ,
581- }
582- } else {
583- match read_session_meta_line ( path. as_path ( ) )
577+ let thread_id =
578+ match resolve_session_thread_id ( path. as_path ( ) , is_uuid. then_some ( id_str) )
584579 . await
585- . ok ( )
586- . map ( |meta_line| meta_line. meta . id )
587580 {
588581 Some ( thread_id) => thread_id,
589582 None => return missing_session_exit ( id_str, "fork" ) ,
590- }
591- } ;
583+ } ;
592584 resume_picker:: SessionSelection :: Fork ( resume_picker:: SessionTarget {
593585 path,
594586 thread_id,
@@ -611,11 +603,7 @@ async fn run_ratatui_app(
611603 {
612604 Ok ( page) => match page. items . first ( ) {
613605 Some ( item) => {
614- match read_session_meta_line ( item. path . as_path ( ) )
615- . await
616- . ok ( )
617- . map ( |meta_line| meta_line. meta . id )
618- {
606+ match resolve_session_thread_id ( item. path . as_path ( ) , None ) . await {
619607 Some ( thread_id) => resume_picker:: SessionSelection :: Fork (
620608 resume_picker:: SessionTarget {
621609 path : item. path . clone ( ) ,
@@ -656,20 +644,14 @@ async fn run_ratatui_app(
656644 } ;
657645 match path {
658646 Some ( path) => {
659- let thread_id = if is_uuid {
660- match ThreadId :: from_string ( id_str) {
661- Ok ( thread_id) => thread_id,
662- Err ( _) => return missing_session_exit ( id_str, "resume" ) ,
663- }
664- } else {
665- match read_session_meta_line ( path. as_path ( ) )
666- . await
667- . ok ( )
668- . map ( |meta_line| meta_line. meta . id )
669- {
670- Some ( thread_id) => thread_id,
671- None => return missing_session_exit ( id_str, "resume" ) ,
672- }
647+ let thread_id = match resolve_session_thread_id (
648+ path. as_path ( ) ,
649+ is_uuid. then_some ( id_str) ,
650+ )
651+ . await
652+ {
653+ Some ( thread_id) => thread_id,
654+ None => return missing_session_exit ( id_str, "resume" ) ,
673655 } ;
674656 resume_picker:: SessionSelection :: Resume ( resume_picker:: SessionTarget {
675657 path,
@@ -697,11 +679,7 @@ async fn run_ratatui_app(
697679 )
698680 . await
699681 {
700- Ok ( Some ( path) ) => match read_session_meta_line ( path. as_path ( ) )
701- . await
702- . ok ( )
703- . map ( |meta_line| meta_line. meta . id )
704- {
682+ Ok ( Some ( path) ) => match resolve_session_thread_id ( path. as_path ( ) , None ) . await {
705683 Some ( thread_id) => {
706684 resume_picker:: SessionSelection :: Resume ( resume_picker:: SessionTarget {
707685 path,
@@ -824,6 +802,19 @@ async fn run_ratatui_app(
824802 app_result
825803}
826804
805+ pub ( crate ) async fn resolve_session_thread_id (
806+ path : & Path ,
807+ id_str_if_uuid : Option < & str > ,
808+ ) -> Option < ThreadId > {
809+ match id_str_if_uuid {
810+ Some ( id_str) => ThreadId :: from_string ( id_str) . ok ( ) ,
811+ None => read_session_meta_line ( path)
812+ . await
813+ . ok ( )
814+ . map ( |meta_line| meta_line. meta . id ) ,
815+ }
816+ }
817+
827818pub ( crate ) async fn read_session_cwd (
828819 config : & Config ,
829820 thread_id : ThreadId ,
0 commit comments