@@ -486,13 +486,13 @@ describe("detectInferenceBackends", () => {
486486
487487 it ( "checks login status with the Codex executable discovered in a macOS app" , async ( ) => {
488488 const command = "/Applications/ChatGPT.app/Contents/Resources/codex" ;
489- const probed : Array < { command : string ; args : string [ ] } > = [ ] ;
489+ const probed : Array < { command : string ; args : string [ ] ; timeoutMs ?: number } > = [ ] ;
490490 const candidates = await detectInferenceBackends ( {
491491 env : { HOME : "/Users/tester" } ,
492492 platform : "darwin" ,
493493 deps : {
494- probeLocalCommand : async ( probedCommand , args = [ "--version" ] ) => {
495- probed . push ( { command : probedCommand , args } ) ;
494+ probeLocalCommand : async ( probedCommand , args = [ "--version" ] , opts = { } ) => {
495+ probed . push ( { command : probedCommand , args, timeoutMs : opts . timeoutMs } ) ;
496496 return {
497497 command : probedCommand ,
498498 found : probedCommand === command ,
@@ -504,7 +504,42 @@ describe("detectInferenceBackends", () => {
504504
505505 expect ( candidates ) . toMatchObject ( [ { kind : "codex-cli" , detail : "installed" } ] ) ;
506506 expect ( candidates [ 0 ] ?. credentials ) . toBeUndefined ( ) ;
507- expect ( probed ) . toContainEqual ( { command, args : [ "login" , "status" ] } ) ;
507+ expect ( probed ) . toContainEqual ( { command, args : [ "--version" ] , timeoutMs : 3_000 } ) ;
508+ expect ( probed ) . toContainEqual ( { command, args : [ "login" , "status" ] , timeoutMs : 3_000 } ) ;
509+ } ) ;
510+
511+ it ( "allows a cold ChatGPT app probe more time than generic CLI discovery" , async ( ) => {
512+ const command = "/Applications/ChatGPT.app/Contents/Resources/codex" ;
513+ const candidates = await detectInferenceBackends ( {
514+ env : { HOME : "/Users/tester" } ,
515+ platform : "darwin" ,
516+ deps : {
517+ probeLocalCommand : async ( probedCommand , args = [ "--version" ] , opts = { } ) => {
518+ if ( probedCommand !== command ) {
519+ return { command : probedCommand , found : false } ;
520+ }
521+ if ( args [ 0 ] === "login" ) {
522+ return { command : probedCommand , found : true , version : "Logged in using ChatGPT" } ;
523+ }
524+ return opts . timeoutMs === 3_000
525+ ? { command : probedCommand , found : true , version : "codex-cli 0.149.0" }
526+ : {
527+ command : probedCommand ,
528+ found : true ,
529+ timedOut : true ,
530+ error : "timed out after 1500ms" ,
531+ } ;
532+ } ,
533+ } ,
534+ } ) ;
535+
536+ expect ( candidates ) . toMatchObject ( [
537+ {
538+ kind : "codex-cli" ,
539+ credentials : true ,
540+ detail : "logged in · ChatGPT subscription" ,
541+ } ,
542+ ] ) ;
508543 } ) ;
509544
510545 it . each ( [
0 commit comments