@@ -32,7 +32,7 @@ pub struct CodexClient {
3232
3333impl CodexClient {
3434 pub async fn new ( app : & AppHandle , session_id : String , config : CodexConfig ) -> Result < Self > {
35- log:: debug!( "Creating CodexClient for session: {}" , session_id) ;
35+ log:: debug!( "Creating CodexClient for session and config : {} {:?} " , session_id, config ) ;
3636
3737 // Build codex command based on configuration
3838 let ( command, args) : ( String , Vec < String > ) =
@@ -119,18 +119,10 @@ impl CodexClient {
119119
120120 // API key will be provided via environment variable - no need to modify provider config
121121
122- // Use model from profile if available, otherwise from config
123- let profile = profiles. get ( & config. provider )
124- . or_else ( || profiles. get ( & config. provider . to_lowercase ( ) ) ) ;
125-
126- let model_to_use = if let Some ( profile) = profile {
127- & profile. model
128- } else {
129- & config. model
130- } ;
131-
132- if !model_to_use. is_empty ( ) {
133- cmd. arg ( "-c" ) . arg ( format ! ( "model={}" , model_to_use) ) ;
122+ // Always use model from config (user selection), not from profile
123+ // This ensures user's model choice in the GUI takes precedence
124+ if !config. model . is_empty ( ) {
125+ cmd. arg ( "-c" ) . arg ( format ! ( "model={}" , config. model) ) ;
134126 }
135127 } else {
136128 // Fallback to original logic for custom providers
@@ -259,9 +251,9 @@ impl CodexClient {
259251 log:: debug!( "Starting stdout reader for session: {}" , session_id_clone) ;
260252
261253 while let Ok ( Some ( line) ) = lines. next_line ( ) . await {
262- // log::debug!("Received line from codex: {}", line);
254+ log:: debug!( "📥 Received line from codex: {}" , line) ;
263255 if let Ok ( event) = serde_json:: from_str :: < Event > ( & line) {
264- // log::debug!("Parsed event: {:?}", event);
256+ log:: debug!( "📨 Parsed event: {:?}" , event) ;
265257
266258 // Log the event for debugging
267259 if let Some ( event_session_id) = get_session_id_from_event ( & event) {
@@ -293,6 +285,7 @@ impl CodexClient {
293285 async fn send_submission ( & self , submission : Submission ) -> Result < ( ) > {
294286 if let Some ( stdin_tx) = & self . stdin_tx {
295287 let json = serde_json:: to_string ( & submission) ?;
288+ log:: debug!( "📤 Sending JSON to codex: {}" , json) ;
296289 stdin_tx. send ( json) ?;
297290 }
298291 Ok ( ( ) )
@@ -309,6 +302,32 @@ impl CodexClient {
309302 self . send_submission ( submission) . await
310303 }
311304
305+ pub async fn send_user_input_with_media ( & self , message : String , media_paths : Vec < String > ) -> Result < ( ) > {
306+ log:: debug!( "🎯 [CodexClient] send_user_input_with_media called:" ) ;
307+ log:: debug!( " 💬 message: {}" , message) ;
308+ log:: debug!( " 📸 media_paths: {:?}" , media_paths) ;
309+ log:: debug!( " 📊 media_paths count: {}" , media_paths. len( ) ) ;
310+
311+ let mut items = vec ! [ InputItem :: Text { text: message } ] ;
312+
313+ // Add media files as LocalImage items - codex will convert to base64 automatically
314+ for path in media_paths {
315+ let path_buf = std:: path:: PathBuf :: from ( path. clone ( ) ) ;
316+ log:: debug!( " 🔗 Adding local image path: {}" , path) ;
317+ items. push ( InputItem :: LocalImage { path : path_buf } ) ;
318+ }
319+
320+ log:: debug!( " 📦 Total items in submission: {}" , items. len( ) ) ;
321+
322+ let submission = Submission {
323+ id : Uuid :: new_v4 ( ) . to_string ( ) ,
324+ op : Op :: UserInput { items } ,
325+ } ;
326+
327+ log:: debug!( " 🚀 Sending submission to codex" ) ;
328+ self . send_submission ( submission) . await
329+ }
330+
312331 pub async fn send_exec_approval ( & self , approval_id : String , approved : bool ) -> Result < ( ) > {
313332 let decision = if approved { "allow" } else { "deny" } . to_string ( ) ;
314333
0 commit comments