From 4d7dd009a885cc8f212e0364175e9626fd487953 Mon Sep 17 00:00:00 2001 From: eYdr1en <54525514+eYdr1en@users.noreply.github.com> Date: Thu, 29 Jan 2026 00:21:19 +0100 Subject: [PATCH 1/2] fix: unset COLORTERM to fix xterm.js rendering issues When COLORTERM=truecolor is inherited from the outer terminal (e.g., Ghostty), Claude Code's Ink UI tries to use truecolor mode which xterm.js doesn't handle correctly, causing rendering issues (gray/white backgrounds). This fix unsets COLORTERM in all PTY spawns so applications use standard 256-color mode which xterm.js fully supports. Fixes: https://github.com/xtermjs/xterm.js/issues/484 --- src/screen-manager.ts | 2 ++ src/session.ts | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/screen-manager.ts b/src/screen-manager.ts index e0c1c86..80c174f 100644 --- a/src/screen-manager.ts +++ b/src/screen-manager.ts @@ -258,7 +258,9 @@ export class ScreenManager extends EventEmitter { // Environment variables must be exported, not passed inline to nice // Using inline VAR=value before nice doesn't work correctly + // Unset COLORTERM to prevent truecolor issues - xterm.js doesn't handle inherited COLORTERM=truecolor well const envExports = [ + 'unset COLORTERM', 'export CLAUDEMAN_SCREEN=1', `export CLAUDEMAN_SESSION_ID=${sessionId}`, `export CLAUDEMAN_SCREEN_NAME=${screenName}`, diff --git a/src/session.ts b/src/session.ts index 2664e86..8c4d591 100644 --- a/src/session.ts +++ b/src/session.ts @@ -825,7 +825,7 @@ export class Session extends EventEmitter { cols: 120, rows: 40, cwd: this.workingDir, - env: { ...process.env, TERM: 'xterm-256color' }, + env: { ...process.env, TERM: 'xterm-256color', COLORTERM: undefined }, }); } catch (spawnErr) { console.error('[Session] Failed to spawn PTY for screen attachment:', spawnErr); @@ -888,6 +888,7 @@ export class Session extends EventEmitter { ...process.env, PATH: getAugmentedPath(), TERM: 'xterm-256color', + COLORTERM: undefined, // Inform Claude it's running within Claudeman (helps prevent self-termination) CLAUDEMAN_SCREEN: '1', CLAUDEMAN_SESSION_ID: this.id, @@ -1062,7 +1063,7 @@ export class Session extends EventEmitter { cols: 120, rows: 40, cwd: this.workingDir, - env: { ...process.env, TERM: 'xterm-256color' }, + env: { ...process.env, TERM: 'xterm-256color', COLORTERM: undefined }, }); } catch (spawnErr) { console.error('[Session] Failed to spawn PTY for shell screen attachment:', spawnErr); @@ -1098,6 +1099,7 @@ export class Session extends EventEmitter { env: { ...process.env, TERM: 'xterm-256color', + COLORTERM: undefined, CLAUDEMAN_SCREEN: '1', CLAUDEMAN_SESSION_ID: this.id, CLAUDEMAN_API_URL: process.env.CLAUDEMAN_API_URL || 'http://localhost:3000', @@ -1227,6 +1229,7 @@ export class Session extends EventEmitter { ...process.env, PATH: getAugmentedPath(), TERM: 'xterm-256color', + COLORTERM: undefined, // Inform Claude it's running within Claudeman CLAUDEMAN_SCREEN: '1', CLAUDEMAN_SESSION_ID: this.id, From 8f1cbd299c7a4103b876d874ae3dd922ef06b41c Mon Sep 17 00:00:00 2001 From: eYdr1en <54525514+eYdr1en@users.noreply.github.com> Date: Thu, 29 Jan 2026 01:39:08 +0100 Subject: [PATCH 2/2] fix: add --verbose flag for stream-json output format Claude CLI v2.1.22+ now requires --verbose when using --output-format=stream-json with -p/--print mode. Without this flag, the CLI errors with: "Error: When using --print, --output-format=stream-json requires --verbose" This broke the Ralph Loop wizard and plan orchestrator agents. --- src/session.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/session.ts b/src/session.ts index 8c4d591..96d989f 100644 --- a/src/session.ts +++ b/src/session.ts @@ -1213,6 +1213,7 @@ export class Session extends EventEmitter { '-p', '--dangerously-skip-permissions', '--output-format', 'stream-json', + '--verbose', // Required for stream-json output format ]; if (model) { args.push('--model', model);