the universal sandbox runtime for agents and humans. pocketenv.io
sandbox openclaw agent claude-code vercel-sandbox deno-sandbox cloudflare-sandbox atproto sprites daytona
7
fork

Configure Feed

Select the types of activity you want to include in your feed.

cli: fix terminal rendering issue

+14 -5
+14 -5
apps/cli/src/theme.ts
··· 23 23 if (process.stdout.isTTY) { 24 24 try { 25 25 const savedState = execSync("stty -g </dev/tty 2>/dev/null", { encoding: "utf8" }).trim(); 26 + // If we couldn't save the state, skip to avoid leaving the terminal in raw mode. 27 + if (!savedState) return false; 28 + const tty = fs.openSync("/dev/tty", "r+"); 26 29 try { 27 - const tty = fs.openSync("/dev/tty", "r+"); 28 - execSync("stty raw -echo min 0 time 5 </dev/tty 2>/dev/null"); 30 + execSync("stty raw -echo min 0 time 2 </dev/tty 2>/dev/null"); 29 31 fs.writeSync(tty, "\x1b]11;?\x07"); 32 + // Read in a loop until we see the response terminator (BEL or ST), 33 + // so leftover bytes don't leak into the terminal input buffer. 34 + let resp = ""; 30 35 const buf = Buffer.alloc(64); 31 - const n = fs.readSync(tty, buf, 0, 64, null); 32 - fs.closeSync(tty); 33 - const resp = buf.slice(0, n).toString(); 36 + for (let i = 0; i < 16; i++) { 37 + const n = fs.readSync(tty, buf, 0, 64, null); 38 + if (n === 0) break; 39 + resp += buf.slice(0, n).toString(); 40 + if (resp.includes("\x07") || resp.includes("\x1b\\")) break; 41 + } 34 42 const m = resp.match(/rgb:([0-9a-f]+)\/([0-9a-f]+)\/([0-9a-f]+)/i); 35 43 if (m?.[1] && m[2] && m[3]) { 36 44 // Components can be 2 or 4 hex digits; normalize to 0-255 ··· 39 47 return 0.299 * r + 0.587 * g + 0.114 * b > 127; 40 48 } 41 49 } finally { 50 + fs.closeSync(tty); 42 51 execSync(`stty ${savedState} </dev/tty 2>/dev/null`); 43 52 } 44 53 } catch {}