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

dismiss Claude Code's auto-mode opt-in modal so it stops swallowing the agent prompt

[._.]/ Adam Eivy751a1c7f2017
diff --git a/server/lib/tuiHandshake.js b/server/lib/tuiHandshake.js
index ea53bd6293..eb7e488d7a 100644
--- a/server/lib/tuiHandshake.js
+++ b/server/lib/tuiHandshake.js
@@ -275,6 +275,24 @@ export const BRACKETED_PASTE_MODE_PATTERN = /\x1b\[\?2004([hl])/g;
export const TUI_TRUST_PROMPT_PATTERN =
/trustthisfolder|isthisaprojectyou(?:created|trust)/i;
+// Claude Code's auto-mode opt-in offer ("Make auto mode your default permission
+// mode? → 1. Yes, set auto mode as my default permission mode / 2. No, keep
+// don't ask"), added in v2.1.233. Like the trust gate it is NOT bypassed by
+// `--dangerously-skip-permissions`, but unlike the trust gate it paints AFTER
+// the composer is live — bracketed-paste mode is already ON, so `ready` goes
+// true and the prompt is pasted straight into a modal that ignores it. Every
+// one of the four claude-code-tui agents launched on 2026-08-14 died
+// `paste-not-rendered` this way (agent-f71b794e et al.).
+//
+// The spawner answers "2. No, keep don't ask" rather than accepting the
+// highlighted default: option 1 rewrites the HUMAN's global default permission
+// mode in `~/.claude.json`, and an unattended agent must not mutate the
+// operator's config as a side effect of dismissing a dialog. Option 2 preserves
+// whatever posture the user already chose, and the agent's own session keeps
+// the `--dangerously-skip-permissions` it was launched with either way.
+export const TUI_AUTO_MODE_PROMPT_PATTERN =
+ /automodeyourdefaultpermissionmode|setautomodeasmydefaultpermissionmode/i;
+
// Antigravity (agy) needs a SECOND, positive readiness signal on top of paste
// mode. agy enables bracketed paste the moment it enters the alt screen — while
// it is still "Signing in…", before its folder-trust gate has painted and long
@@ -316,6 +334,13 @@ export function createInputReadyTracker({ readyTextPattern = null, directLaunch
let sawCommandRun = directLaunch;
let needsTrust = false;
let sawReadyText = false;
+ // Auto-mode offer: latched when seen, cleared once answered. `autoModeAnswered`
+ // makes the ack TERMINAL — `tail` is a rolling 4000-char window, so the modal's
+ // text lingers in it long after the dialog is gone and would otherwise re-arm
+ // the flag on the very next chunk, re-answering forever and pinning `ready`
+ // false until the 45s deadline. Arm-once, same as the gates above it.
+ let needsAutoModeChoice = false;
+ let autoModeAnswered = false;
let tail = '';
return {
// Ready once the TUI has RE-ENABLED bracketed-paste mode after the launch
@@ -324,10 +349,18 @@ export function createInputReadyTracker({ readyTextPattern = null, directLaunch
// initial ON does not count: sawCommandRun gates on the intervening OFF.)
// Providers that enable paste mode before their composer exists supply a
// readyTextPattern to close the gap.
+ // The auto-mode offer is the one gate that paints with paste mode already ON,
+ // so it must SUPPRESS ready — every other signal here says "go" while the
+ // modal is still swallowing input. Cleared by ackAutoModeChoice() once the
+ // spawner has answered it.
get ready() {
- return sawCommandRun && pasteModeOn && (!readyTextPattern || sawReadyText);
+ return sawCommandRun && pasteModeOn && !needsAutoModeChoice
+ && (!readyTextPattern || sawReadyText);
},
get needsTrust() { return needsTrust; },
+ get needsAutoModeChoice() { return needsAutoModeChoice; },
+ /** Spawner reports the dismissal keystrokes went out; re-arms `ready`. */
+ ackAutoModeChoice() { needsAutoModeChoice = false; autoModeAnswered = true; },
// rawText: un-stripped chunk (paste-mode toggles live here);
// strippedText: ANSI-stripped chunk (the trust-gate / composer text).
observe(rawText, strippedText) {
@@ -340,6 +373,7 @@ export function createInputReadyTracker({ readyTextPattern = null, directLaunch
if (strippedText) {
tail = (tail + strippedText.replace(/\s+/g, '')).slice(-OBSERVE_TAIL_MAX_LEN);
if (!needsTrust && TUI_TRUST_PROMPT_PATTERN.test(tail)) needsTrust = true;
+ if (!needsAutoModeChoice && !autoModeAnswered && TUI_AUTO_MODE_PROMPT_PATTERN.test(tail)) needsAutoModeChoice = true;
if (readyTextPattern && !sawReadyText && readyTextPattern.test(tail)) sawReadyText = true;
}
},
diff --git a/server/lib/tuiHandshake.test.js b/server/lib/tuiHandshake.test.js
index 611ed3a908..38b4f0df2d 100644
--- a/server/lib/tuiHandshake.test.js
+++ b/server/lib/tuiHandshake.test.js
@@ -1288,6 +1288,59 @@ describe('createInputReadyTracker', () => {
expect(agy.needsTrust).toBe(true);
});
+ // Claude Code v2.1.233's auto-mode offer. Unlike the trust gate it paints with
+ // bracketed paste ALREADY ON, so `ready` was true and the prompt went into a
+ // modal that ignored it — four agents died `paste-not-rendered` on 2026-08-14.
+ describe('claude auto-mode default offer', () => {
+ // Verbatim wording from agent-f71b794e's transcript.
+ const OFFER = 'Make auto mode your default permission mode?\n'
+ + ' ❯ 1. Yes, set auto mode as my default permission mode\n'
+ + ' 2. No, keep don\'t ask\n';
+
+ const readyTracker = () => {
+ const tracker = createInputReadyTracker();
+ tracker.observe(`${PASTE_OFF}${PASTE_ON}`, '');
+ return tracker;
+ };
+
+ it('suppresses ready while the offer is up, even with paste mode on', () => {
+ const tracker = readyTracker();
+ expect(tracker.ready).toBe(true); // composer live...
+
+ tracker.observe('', OFFER);
+ expect(tracker.needsAutoModeChoice).toBe(true);
+ expect(tracker.ready).toBe(false); // ...but the modal owns input now
+ });
+
+ it('re-arms ready once the spawner acks the dismissal', () => {
+ const tracker = readyTracker();
+ tracker.observe('', OFFER);
+ tracker.ackAutoModeChoice();
+ expect(tracker.needsAutoModeChoice).toBe(false);
+ expect(tracker.ready).toBe(true);
+ });
+
+ // The rolling tail keeps the modal text for 4000 chars after the dialog is
+ // gone. Without a terminal ack that stale text re-arms the flag on the next
+ // chunk — re-answering forever and pinning `ready` false to the 45s deadline.
+ it('does not re-arm from the stale tail after being answered', () => {
+ const tracker = readyTracker();
+ tracker.observe('', OFFER);
+ tracker.ackAutoModeChoice();
+
+ tracker.observe('', 'bypass permissions on'); // tail still holds the offer
+ expect(tracker.needsAutoModeChoice).toBe(false);
+ expect(tracker.ready).toBe(true);
+ });
+
+ it('leaves the tracker alone when no offer appears', () => {
+ const tracker = readyTracker();
+ tracker.observe('', 'Try "fix lint errors"');
+ expect(tracker.needsAutoModeChoice).toBe(false);
+ expect(tracker.ready).toBe(true);
+ });
+ });
+
it('matches a marker split across two PTY chunks (rolling tail)', () => {
const tracker = createInputReadyTracker();
tracker.observe('', '> Yes, I trust th');
diff --git a/server/services/agentTuiSpawning.js b/server/services/agentTuiSpawning.js
index 4c8cecb4dc..991bd11fbe 100644
--- a/server/services/agentTuiSpawning.js
+++ b/server/services/agentTuiSpawning.js
@@ -804,6 +804,7 @@ export async function spawnTuiAgent({
directLaunch: useDurableRunner,
});
let trustAccepted = false;
+ let autoModeDeclined = false;
// True once shell.js actually injects the `claude` command (after its
// round-trip readiness probe). The probe runs its OWN shell command first,
// which toggles bracketed-paste mode and would otherwise advance the
@@ -1591,6 +1592,21 @@ export async function spawnTuiAgent({
appendLine(`📟 Auto-confirmed ${tuiConfig.command} folder-trust prompt for session ${sessionId.slice(0, 8)}`);
return;
}
+ // Decline claude's "make auto mode your default permission mode?" offer
+ // (v2.1.233+). Unlike the trust gate this one paints AFTER the composer is
+ // live, so it swallows the paste and every retry unless it is cleared
+ // first — see TUI_AUTO_MODE_PROMPT_PATTERN. Arrow-down + Enter rather than
+ // the digit `2`: it lands on "No, keep don't ask" under both of Ink's
+ // selection models (digit-immediate-select and navigate-then-confirm),
+ // whereas a bare `\r` would accept the highlighted option 1 and rewrite the
+ // user's global permission default.
+ if (inputReady.needsAutoModeChoice && !autoModeDeclined) {
+ autoModeDeclined = true;
+ shellService.writeToSession(sessionId, '\x1b[B\r');
+ inputReady.ackAutoModeChoice();
+ appendLine(`📟 Declined ${tuiConfig.command} auto-mode default offer for session ${sessionId.slice(0, 8)}`);
+ return;
+ }
if (inputReady.ready && elapsed >= tuiConfig.promptDelayMs) {
safeSendPrompt('input-ready');
clearInterval(promptTimer);