@@ -4,6 +4,7 @@ const mocks = vi.hoisted(() => ({
44 mockAuthAndSetupMachineIfNeeded : vi . fn ( ) ,
55 mockRunCodex : vi . fn ( ) ,
66 mockExtractCodexResumeFlag : vi . fn ( ) ,
7+ mockExtractCodexPassthroughArgs : vi . fn ( ) ,
78 mockExtractNoSandboxFlag : vi . fn ( ) ,
89 mockEnsureDaemonRunning : vi . fn ( ) ,
910} ) )
@@ -18,6 +19,7 @@ vi.mock('@/codex/runCodex', () => ({
1819
1920vi . mock ( '@/codex/cliArgs' , ( ) => ( {
2021 extractCodexResumeFlag : mocks . mockExtractCodexResumeFlag ,
22+ extractCodexPassthroughArgs : mocks . mockExtractCodexPassthroughArgs ,
2123} ) )
2224
2325vi . mock ( '@/utils/sandboxFlags' , ( ) => ( {
@@ -40,6 +42,10 @@ describe('handleCodexCommand', () => {
4042 noSandbox : false ,
4143 args,
4244 } ) )
45+ mocks . mockExtractCodexPassthroughArgs . mockImplementation ( ( args : string [ ] ) => ( {
46+ happyArgs : args ,
47+ codexArgs : [ ] ,
48+ } ) )
4349 mocks . mockExtractCodexResumeFlag . mockImplementation ( ( args : string [ ] ) => ( {
4450 resumeThreadId : null ,
4551 args,
@@ -60,6 +66,7 @@ describe('handleCodexCommand', () => {
6066 permissionMode : undefined ,
6167 model : undefined ,
6268 effort : undefined ,
69+ codexCliArgs : [ ] ,
6370 } )
6471 expect (
6572 mocks . mockEnsureDaemonRunning . mock . invocationCallOrder [ 0 ] ,
@@ -86,6 +93,35 @@ describe('handleCodexCommand', () => {
8693 permissionMode : undefined ,
8794 model : undefined ,
8895 effort : undefined ,
96+ codexCliArgs : [ ] ,
97+ } )
98+ } )
99+
100+ it ( 'passes only delimiter-separated args through to the Codex CLI' , async ( ) => {
101+ mocks . mockExtractCodexPassthroughArgs . mockReturnValue ( {
102+ happyArgs : [ '--started-by' , 'terminal' ] ,
103+ codexArgs : [ '--dangerously-bypass-approvals-and-sandbox' , '--config' , 'model="gpt-5.5"' ] ,
104+ } )
105+
106+ await handleCodexCommand ( [
107+ '--started-by' ,
108+ 'terminal' ,
109+ '--' ,
110+ '--dangerously-bypass-approvals-and-sandbox' ,
111+ '--config' ,
112+ 'model="gpt-5.5"' ,
113+ ] )
114+
115+ expect ( mocks . mockExtractNoSandboxFlag ) . toHaveBeenCalledWith ( [ '--started-by' , 'terminal' ] )
116+ expect ( mocks . mockRunCodex ) . toHaveBeenCalledWith ( {
117+ credentials : { token : 'token' } ,
118+ startedBy : 'terminal' ,
119+ noSandbox : false ,
120+ resumeThreadId : undefined ,
121+ permissionMode : undefined ,
122+ model : undefined ,
123+ effort : undefined ,
124+ codexCliArgs : [ '--dangerously-bypass-approvals-and-sandbox' , '--config' , 'model="gpt-5.5"' ] ,
89125 } )
90126 } )
91127
@@ -100,6 +136,7 @@ describe('handleCodexCommand', () => {
100136 permissionMode : 'yolo' ,
101137 model : undefined ,
102138 effort : undefined ,
139+ codexCliArgs : [ ] ,
103140 } )
104141 } )
105142
@@ -114,6 +151,7 @@ describe('handleCodexCommand', () => {
114151 permissionMode : 'yolo' ,
115152 model : undefined ,
116153 effort : undefined ,
154+ codexCliArgs : [ ] ,
117155 } )
118156 } )
119157
@@ -128,6 +166,7 @@ describe('handleCodexCommand', () => {
128166 permissionMode : undefined ,
129167 model : 'gpt-5.4' ,
130168 effort : 'xhigh' ,
169+ codexCliArgs : [ ] ,
131170 } )
132171 } )
133172} )
0 commit comments