@@ -558,4 +558,54 @@ describe("runCodexAppServerAttempt", () => {
558558
559559 expect ( binding . authProfileId ) . toBe ( "openai-codex:bound" ) ;
560560 } ) ;
561+
562+ it ( "reuses the bound auth profile for app-server startup when params omit it" , async ( ) => {
563+ const sessionFile = path . join ( tempDir , "session.jsonl" ) ;
564+ const workspaceDir = path . join ( tempDir , "workspace" ) ;
565+ await writeCodexAppServerBinding ( sessionFile , {
566+ threadId : "thread-existing" ,
567+ cwd : workspaceDir ,
568+ authProfileId : "openai-codex:bound" ,
569+ model : "gpt-5.4-codex" ,
570+ modelProvider : "openai" ,
571+ dynamicToolsFingerprint : "[]" ,
572+ } ) ;
573+ const seenAuthProfileIds : Array < string | undefined > = [ ] ;
574+ let notify : ( notification : CodexServerNotification ) => Promise < void > = async ( ) => undefined ;
575+ __testing . setCodexAppServerClientFactoryForTests ( async ( _startOptions , authProfileId ) => {
576+ seenAuthProfileIds . push ( authProfileId ) ;
577+ return {
578+ request : async ( method : string ) => {
579+ if ( method === "thread/resume" ) {
580+ return { thread : { id : "thread-existing" } , modelProvider : "openai" } ;
581+ }
582+ if ( method === "turn/start" ) {
583+ return { turn : { id : "turn-1" , status : "inProgress" } } ;
584+ }
585+ throw new Error ( `unexpected method: ${ method } ` ) ;
586+ } ,
587+ addNotificationHandler : ( handler : typeof notify ) => {
588+ notify = handler ;
589+ return ( ) => undefined ;
590+ } ,
591+ addRequestHandler : ( ) => ( ) => undefined ,
592+ } as never ;
593+ } ) ;
594+ const params = createParams ( sessionFile , workspaceDir ) ;
595+ delete params . authProfileId ;
596+
597+ const run = runCodexAppServerAttempt ( params ) ;
598+ await vi . waitFor ( ( ) => expect ( seenAuthProfileIds ) . toEqual ( [ "openai-codex:bound" ] ) ) ;
599+ await notify ( {
600+ method : "turn/completed" ,
601+ params : {
602+ threadId : "thread-existing" ,
603+ turnId : "turn-1" ,
604+ turn : { id : "turn-1" , status : "completed" } ,
605+ } ,
606+ } ) ;
607+ await run ;
608+
609+ expect ( seenAuthProfileIds ) . toEqual ( [ "openai-codex:bound" ] ) ;
610+ } ) ;
561611} ) ;
0 commit comments