Skip to content

Commit 2f1ba96

Browse files
authored
Merge pull request #128 from kbwo/feature/codex-2025-11-24
feat: update state detection strategy for codex
2 parents aa16ba8 + 9725b0a commit 2f1ba96

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

src/services/__tests__/stateDetector.codex.test.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,29 @@ describe('CodexStateDetector', () => {
4747
expect(state).toBe('waiting_input');
4848
});
4949

50+
it('should detect waiting_input state for multiline do you want prompt with yes', () => {
51+
// Arrange
52+
terminal = createMockTerminal([
53+
'Would you like to run the following command?',
54+
'',
55+
'Reason: Need to write to .git/worktrees metadata to stage changes for the requested commi',
56+
'',
57+
'$ git add test.ts',
58+
'',
59+
'› 1. Yes, proceed (y)',
60+
" 2. Yes, and don't ask again for this command (a)",
61+
' 3. No, and tell Codex what to do differently (esc)',
62+
'',
63+
'Press enter to confirm or esc to cancel',
64+
]);
65+
66+
// Act
67+
const state = detector.detectState(terminal, 'idle');
68+
69+
// Assert
70+
expect(state).toBe('waiting_input');
71+
});
72+
5073
it('should detect busy state for Esc to interrupt pattern', () => {
5174
// Arrange
5275
terminal = createMockTerminal([

src/services/stateDetector.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,14 @@ export class CodexStateDetector extends BaseStateDetector {
152152
return 'waiting_input';
153153
}
154154

155+
if (
156+
/(do you want|would you like)[\s\S]*?\n+[\s\S]*?\byes\b/.test(
157+
lowerContent,
158+
)
159+
) {
160+
return 'waiting_input';
161+
}
162+
155163
// Check for busy state
156164
if (/esc.*interrupt/i.test(lowerContent)) {
157165
return 'busy';

0 commit comments

Comments
 (0)