File tree Expand file tree Collapse file tree 2 files changed +30
-4
lines changed
Expand file tree Collapse file tree 2 files changed +30
-4
lines changed Original file line number Diff line number Diff line change @@ -115,16 +115,16 @@ export class CodexExec {
115115 commandArgs . push ( "--config" , `approval_policy="${ args . approvalPolicy } "` ) ;
116116 }
117117
118+ if ( args . threadId ) {
119+ commandArgs . push ( "resume" , args . threadId ) ;
120+ }
121+
118122 if ( args . images ?. length ) {
119123 for ( const image of args . images ) {
120124 commandArgs . push ( "--image" , image ) ;
121125 }
122126 }
123127
124- if ( args . threadId ) {
125- commandArgs . push ( "resume" , args . threadId ) ;
126- }
127-
128128 const env : Record < string , string > = { } ;
129129 if ( this . envOverride ) {
130130 Object . assign ( env , this . envOverride ) ;
Original file line number Diff line number Diff line change @@ -67,4 +67,30 @@ describe("CodexExec", () => {
6767 expect ( result . error . message ) . toMatch ( / C o d e x E x e c e x i t e d / ) ;
6868 }
6969 } ) ;
70+
71+ it ( "places resume args before image args" , async ( ) => {
72+ const { CodexExec } = await import ( "../src/exec" ) ;
73+ spawnMock . mockClear ( ) ;
74+ const child = new FakeChildProcess ( ) ;
75+ spawnMock . mockReturnValue ( child as unknown as child_process . ChildProcess ) ;
76+
77+ setImmediate ( ( ) => {
78+ child . stdout . end ( ) ;
79+ child . stderr . end ( ) ;
80+ child . emit ( "exit" , 0 , null ) ;
81+ } ) ;
82+
83+ const exec = new CodexExec ( "codex" ) ;
84+ for await ( const _ of exec . run ( { input : "hi" , images : [ "img.png" ] , threadId : "thread-id" } ) ) {
85+ // no-op
86+ }
87+
88+ const commandArgs = spawnMock . mock . calls [ 0 ] ?. [ 1 ] as string [ ] | undefined ;
89+ expect ( commandArgs ) . toBeDefined ( ) ;
90+ const resumeIndex = commandArgs ! . indexOf ( "resume" ) ;
91+ const imageIndex = commandArgs ! . indexOf ( "--image" ) ;
92+ expect ( resumeIndex ) . toBeGreaterThan ( - 1 ) ;
93+ expect ( imageIndex ) . toBeGreaterThan ( - 1 ) ;
94+ expect ( resumeIndex ) . toBeLessThan ( imageIndex ) ;
95+ } ) ;
7096} ) ;
You can’t perform that action at this time.
0 commit comments