@@ -550,42 +550,6 @@ pub(crate) async fn respond_to_server_request(
550550 . await
551551}
552552
553- /// Gets the diff content for commit message generation
554- #[ tauri:: command]
555- pub ( crate ) async fn get_commit_message_prompt (
556- workspace_id : String ,
557- state : State < ' _ , AppState > ,
558- app : AppHandle ,
559- ) -> Result < String , String > {
560- if remote_backend:: is_remote_mode ( & * state) . await {
561- let value = remote_backend:: call_remote (
562- & * state,
563- app,
564- "get_commit_message_prompt" ,
565- json ! ( { "workspaceId" : workspace_id } ) ,
566- )
567- . await ?;
568- return serde_json:: from_value ( value) . map_err ( |err| err. to_string ( ) ) ;
569- }
570-
571- // Get the diff from git
572- let diff = crate :: git:: get_workspace_diff ( & workspace_id, & state) . await ?;
573-
574- if diff. trim ( ) . is_empty ( ) {
575- return Err ( "No changes to generate commit message for" . to_string ( ) ) ;
576- }
577-
578- let commit_message_prompt = {
579- let settings = state. app_settings . lock ( ) . await ;
580- settings. commit_message_prompt . clone ( )
581- } ;
582-
583- Ok ( crate :: shared:: codex_aux_core:: build_commit_message_prompt (
584- & diff,
585- & commit_message_prompt,
586- ) )
587- }
588-
589553#[ tauri:: command]
590554pub ( crate ) async fn remember_approval_rule (
591555 workspace_id : String ,
@@ -634,22 +598,15 @@ pub(crate) async fn generate_commit_message(
634598
635599 let diff = crate :: git:: get_workspace_diff ( & workspace_id, & state) . await ?;
636600
637- if diff. trim ( ) . is_empty ( ) {
638- return Err ( "No changes to generate commit message for" . to_string ( ) ) ;
639- }
640-
641601 let commit_message_prompt = {
642602 let settings = state. app_settings . lock ( ) . await ;
643603 settings. commit_message_prompt . clone ( )
644604 } ;
645- let prompt = crate :: shared:: codex_aux_core:: build_commit_message_prompt (
646- & diff,
647- & commit_message_prompt,
648- ) ;
649- let response = crate :: shared:: codex_aux_core:: run_background_prompt_core (
605+ crate :: shared:: codex_aux_core:: generate_commit_message_core (
650606 & state. sessions ,
651607 workspace_id,
652- prompt,
608+ & diff,
609+ & commit_message_prompt,
653610 |workspace_id, thread_id| {
654611 let _ = app. emit (
655612 "app-server-event" ,
@@ -665,17 +622,8 @@ pub(crate) async fn generate_commit_message(
665622 } ,
666623 ) ;
667624 } ,
668- "Timeout waiting for commit message generation" ,
669- "Unknown error during commit message generation" ,
670625 )
671- . await ?;
672-
673- let trimmed = response. trim ( ) . to_string ( ) ;
674- if trimmed. is_empty ( ) {
675- return Err ( "No commit message was generated" . to_string ( ) ) ;
676- }
677-
678- Ok ( trimmed)
626+ . await
679627}
680628
681629#[ tauri:: command]
@@ -695,16 +643,10 @@ pub(crate) async fn generate_run_metadata(
695643 . await ;
696644 }
697645
698- let cleaned_prompt = prompt. trim ( ) ;
699- if cleaned_prompt. is_empty ( ) {
700- return Err ( "Prompt is required." . to_string ( ) ) ;
701- }
702-
703- let title_prompt = crate :: shared:: codex_aux_core:: build_run_metadata_prompt ( cleaned_prompt) ;
704- let response_text = crate :: shared:: codex_aux_core:: run_background_prompt_core (
646+ crate :: shared:: codex_aux_core:: generate_run_metadata_core (
705647 & state. sessions ,
706648 workspace_id,
707- title_prompt ,
649+ & prompt ,
708650 |workspace_id, thread_id| {
709651 let _ = app. emit (
710652 "app-server-event" ,
@@ -720,34 +662,6 @@ pub(crate) async fn generate_run_metadata(
720662 } ,
721663 ) ;
722664 } ,
723- "Timeout waiting for metadata generation" ,
724- "Unknown error during metadata generation" ,
725665 )
726- . await ?;
727-
728- let trimmed = response_text. trim ( ) ;
729- if trimmed. is_empty ( ) {
730- return Err ( "No metadata was generated" . to_string ( ) ) ;
731- }
732-
733- let json_value = crate :: shared:: codex_aux_core:: extract_json_value ( trimmed)
734- . ok_or_else ( || "Failed to parse metadata JSON" . to_string ( ) ) ?;
735- let title = json_value
736- . get ( "title" )
737- . and_then ( |v| v. as_str ( ) )
738- . map ( |v| v. trim ( ) . to_string ( ) )
739- . filter ( |v| !v. is_empty ( ) )
740- . ok_or_else ( || "Missing title in metadata" . to_string ( ) ) ?;
741- let worktree_name = json_value
742- . get ( "worktreeName" )
743- . or_else ( || json_value. get ( "worktree_name" ) )
744- . and_then ( |v| v. as_str ( ) )
745- . map ( crate :: shared:: codex_aux_core:: sanitize_run_worktree_name)
746- . filter ( |v| !v. is_empty ( ) )
747- . ok_or_else ( || "Missing worktree name in metadata" . to_string ( ) ) ?;
748-
749- Ok ( json ! ( {
750- "title" : title,
751- "worktreeName" : worktree_name
752- } ) )
666+ . await
753667}
0 commit comments