@@ -476,13 +476,13 @@ describe("detectInferenceBackends", () => {
476476
477477 it ( "checks login status with the Codex executable discovered in a macOS app" , async ( ) => {
478478 const command = "/Applications/ChatGPT.app/Contents/Resources/codex" ;
479- const probed : Array < { command : string ; args : string [ ] } > = [ ] ;
479+ const probed : Array < { command : string ; args : string [ ] ; timeoutMs ?: number } > = [ ] ;
480480 const candidates = await detectInferenceBackends ( {
481481 env : { HOME : "/Users/tester" } ,
482482 platform : "darwin" ,
483483 deps : {
484- probeLocalCommand : async ( probedCommand , args = [ "--version" ] ) => {
485- probed . push ( { command : probedCommand , args } ) ;
484+ probeLocalCommand : async ( probedCommand , args = [ "--version" ] , opts = { } ) => {
485+ probed . push ( { command : probedCommand , args, timeoutMs : opts . timeoutMs } ) ;
486486 return {
487487 command : probedCommand ,
488488 found : probedCommand === command ,
@@ -494,7 +494,42 @@ describe("detectInferenceBackends", () => {
494494
495495 expect ( candidates ) . toMatchObject ( [ { kind : "codex-cli" , detail : "installed" } ] ) ;
496496 expect ( candidates [ 0 ] ?. credentials ) . toBeUndefined ( ) ;
497- expect ( probed ) . toContainEqual ( { command, args : [ "login" , "status" ] } ) ;
497+ expect ( probed ) . toContainEqual ( { command, args : [ "--version" ] , timeoutMs : 3_000 } ) ;
498+ expect ( probed ) . toContainEqual ( { command, args : [ "login" , "status" ] , timeoutMs : 3_000 } ) ;
499+ } ) ;
500+
501+ it ( "allows a cold ChatGPT app probe more time than generic CLI discovery" , async ( ) => {
502+ const command = "/Applications/ChatGPT.app/Contents/Resources/codex" ;
503+ const candidates = await detectInferenceBackends ( {
504+ env : { HOME : "/Users/tester" } ,
505+ platform : "darwin" ,
506+ deps : {
507+ probeLocalCommand : async ( probedCommand , args = [ "--version" ] , opts = { } ) => {
508+ if ( probedCommand !== command ) {
509+ return { command : probedCommand , found : false } ;
510+ }
511+ if ( args [ 0 ] === "login" ) {
512+ return { command : probedCommand , found : true , version : "Logged in using ChatGPT" } ;
513+ }
514+ return opts . timeoutMs === 3_000
515+ ? { command : probedCommand , found : true , version : "codex-cli 0.149.0" }
516+ : {
517+ command : probedCommand ,
518+ found : true ,
519+ timedOut : true ,
520+ error : "timed out after 1500ms" ,
521+ } ;
522+ } ,
523+ } ,
524+ } ) ;
525+
526+ expect ( candidates ) . toMatchObject ( [
527+ {
528+ kind : "codex-cli" ,
529+ credentials : true ,
530+ detail : "logged in · ChatGPT subscription" ,
531+ } ,
532+ ] ) ;
498533 } ) ;
499534
500535 it . each ( [
0 commit comments