Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: recognize Codex folder access trust choices

Adam Eivy08610f2d9728
diff --git a/server/lib/tuiHandshake.js b/server/lib/tuiHandshake.js
index fb4d6d999f..c93eb1e7c7 100644
--- a/server/lib/tuiHandshake.js
+++ b/server/lib/tuiHandshake.js
@@ -388,16 +388,18 @@ export const TUI_TRUST_PROMPT_PATTERN =
// Claude Code builds can render "No, exit" first and highlight it. Consumers must
// wait until the choices themselves have painted, then move off a highlighted
// decline choice instead of assuming a bare Enter always accepts the folder.
+// Codex 0.162.1 labels these choices "Trust and continue" and "Quit". Keep the
+// bare Quit match tied to a numbered option rather than its explanatory text.
// These patterns run against createInputReadyTracker's whitespace-free tail.
-const TUI_TRUST_ACCEPT_OPTION_PATTERN = /(?:yes,?itrustthisfolder|yes,?continue|\[a\]trustthisworkspace)/i;
-const TUI_TRUST_DECLINE_OPTION_PATTERN = /no,?(?:exit|quit)/i;
+const TUI_TRUST_ACCEPT_OPTION_PATTERN = /(?:yes,?itrustthisfolder|yes,?continue|trustandcontinue|\[a\]trustthisworkspace)/i;
+const TUI_TRUST_DECLINE_OPTION_PATTERN = /no,?(?:exit|quit)|\d+\.quit/i;
const TUI_HIGHLIGHT_PATTERN_PREFIX = String.raw`(?:❯|›|>)\d*\.?`;
const TUI_TRUST_HIGHLIGHTED_ACCEPT_PATTERN = new RegExp(
- `${TUI_HIGHLIGHT_PATTERN_PREFIX}(?:yes,?itrustthisfolder|yes,?continue)`,
+ `${TUI_HIGHLIGHT_PATTERN_PREFIX}(?:yes,?itrustthisfolder|yes,?continue|trustandcontinue)`,
'i',
);
const TUI_TRUST_HIGHLIGHTED_DECLINE_PATTERN = new RegExp(
- `${TUI_HIGHLIGHT_PATTERN_PREFIX}no,?(?:exit|quit)`,
+ `${TUI_HIGHLIGHT_PATTERN_PREFIX}(?:no,?(?:exit|quit)|quit)`,
'i',
);
diff --git a/server/services/agentTuiSpawning.test.js b/server/services/agentTuiSpawning.test.js
index 6962630625..e42fef5f35 100644
--- a/server/services/agentTuiSpawning.test.js
+++ b/server/services/agentTuiSpawning.test.js
@@ -1634,6 +1634,33 @@ describe('spawnTuiAgent runtime', () => {
expect(pasteCount()).toBe(1);
});
+ it('codex folder access: waits for a split Trust and continue choice before answering once', async () => {
+ runSpawn();
+ await flushMicrotasks();
+
+ await capturedOnData(Buffer.from(
+ `${PASTE_OFF}Folder access\n/workspace/example\nTrustthisfolder?\n`
+ + 'Codexcanread,edit,andrunfileshere,subjecttoyourpermissionsettings.\n'
+ + '› 1. Trust and cont',
+ ));
+ await vi.advanceTimersByTimeAsync(2000);
+ await flushMicrotasks();
+ expect(vi.mocked(shellService.writeToSession).mock.calls.some(([, data]) => data === '\r')).toBe(false);
+ expect(pasteCount()).toBe(0);
+
+ await capturedOnData(Buffer.from('inue\n2.Quit\nenter continue · esc quit\n'));
+ await vi.advanceTimersByTimeAsync(2000);
+ await flushMicrotasks();
+ expect(vi.mocked(shellService.writeToSession).mock.calls.filter(([, data]) => data === '\r')).toHaveLength(1);
+ expect(pasteCount()).toBe(0);
+ expect(agentLifecycle.finalizeAgent).not.toHaveBeenCalled();
+
+ await capturedOnData(Buffer.from(CODEX_COMPOSER));
+ await vi.advanceTimersByTimeAsync(2000);
+ await flushMicrotasks();
+ expect(pasteCount()).toBe(1);
+ });
+
it('tui-not-ready: claude that never shows an input prompt finalizes failure without pasting', async () => {
let resolveComplete;
const completeDone = new Promise((r) => { resolveComplete = r; });
diff --git a/server/services/tuiPromptRunner.test.js b/server/services/tuiPromptRunner.test.js
index 2acd0ecdff..fbe599d851 100644
--- a/server/services/tuiPromptRunner.test.js
+++ b/server/services/tuiPromptRunner.test.js
@@ -766,7 +766,22 @@ describe('executeTuiRun', () => {
await promise;
});
- it('confirms the Codex directory-trust gate before its idle path can paste', async () => {
+ it.each([
+ {
+ version: 'legacy',
+ dialog: 'You are in /workspace/example\n'
+ + 'Do you trust the contents of this directory? Working with untrusted contents comes with'
+ + ' higher risk of prompt injection.\n'
+ + '› 1. Yes, continue\n2. No, quit\nPress enter to continue\n',
+ answer: '\r',
+ },
+ {
+ version: '0.162.1 with Quit highlighted',
+ dialog: 'Folder access\n/workspace/example\nTrustthisfolder?\n'
+ + '1. Trust and continue\n› 2.Quit\nenter continue · esc quit\n',
+ answer: '\x1b[A\r',
+ },
+ ])('confirms the Codex $version trust gate before its idle path can paste', async ({ dialog, answer }) => {
vi.useFakeTimers({
toFake: ['setTimeout', 'clearTimeout', 'setInterval', 'clearInterval', 'Date'],
});
@@ -778,16 +793,11 @@ describe('executeTuiRun', () => {
await flushAsync();
const pty = ptyInstances[0];
- pty.emitData(
- 'You are in /tmp/portos-cd-cwd/agent-abc\n'
- + 'Do you trust the contents of this directory? Working with untrusted contents comes with'
- + ' higher risk of prompt injection.\n'
- + '› 1. Yes, continue\n2. No, quit\nPress enter to continue\n',
- );
+ pty.emitData(dialog);
// Past the idle threshold — the window the prompt used to be pasted in.
await vi.advanceTimersByTimeAsync(2000);
- expect(pty.write).toHaveBeenCalledWith('\r');
+ expect(pty.write).toHaveBeenCalledWith(answer);
expect(pty.write).not.toHaveBeenCalledWith(expect.stringContaining('\x1b[200~'));
pty.emitData('OpenAI Codex ready\n');