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: Windows CMD windows flash and steal focus on every spawn

[._.]/ Adam Eivyae5a3ef31aff
diff --git a/.changelog/v1.4.3.md b/.changelog/v1.4.3.md
index 8ba01207ab..7586da933f 100644
--- a/.changelog/v1.4.3.md
+++ b/.changelog/v1.4.3.md
@@ -1,4 +1,4 @@
-# Release v1.4.3 - Changelog
+# Release v1.4.x - Changelog
Released: Unreleased
@@ -34,4 +34,3 @@ Cross-platform compatibility improvements for Windows and exFAT filesystems.
### Windows: Vite UI fails to start via PM2
- PM2 was running `node_modules/.bin/vite` which is a Unix shell script on Windows — Node.js tried to parse it as JS
- Changed to reference the actual JS entry point (`client/node_modules/vite/bin/vite.js`) directly
-
diff --git a/.changelog/v1.5.x.md b/.changelog/v1.5.x.md
index 50170497e9..c812e68d79 100644
--- a/.changelog/v1.5.x.md
+++ b/.changelog/v1.5.x.md
@@ -15,6 +15,10 @@ Fresh-install safety: all jobs, scripts, and scheduled tasks now default to disa
- Automation scheduler: new schedules default to disabled (was enabled)
- Task schedule: all 14 improvement task types now default to disabled
+### Windows: CMD windows flash and steal focus
+- Every `spawn()` / `exec()` / `execFile()` call was creating a visible CMD console window on Windows that repeatedly stole focus
+- Added `windowsHide: true` to all 23 child process spawn sites across 11 files (pm2, git, commands, runner, cos-runner, autofixer, browser, worktree manager, script runner)
+
### CoS collapsed panel overflow
- Removed StatusIndicator and StateLabel from the collapsed CoS desktop strip — they overflowed the 48px width
diff --git a/autofixer/server.js b/autofixer/server.js
index 354e64e271..8d4c9c574b 100644
--- a/autofixer/server.js
+++ b/autofixer/server.js
@@ -6,7 +6,7 @@ import { promisify } from 'util';
import { execFile as execFileCb } from 'child_process';
const IS_WIN = process.platform === 'win32';
-const execFileAsync = (cmd, args, opts = {}) => promisify(execFileCb)(cmd, args, { shell: IS_WIN, ...opts });
+const execFileAsync = (cmd, args, opts = {}) => promisify(execFileCb)(cmd, args, { shell: IS_WIN, windowsHide: true, ...opts });
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
@@ -174,7 +174,8 @@ Fix the issue and restart the process. Be systematic and thorough. Use the Bash
const child = spawn('claude', ['-p', prompt], {
cwd: app.repoPath,
stdio: ['ignore', 'pipe', 'pipe'],
- shell: false
+ shell: false,
+ windowsHide: true
});
child.stdout.on('data', (data) => {
diff --git a/autofixer/ui.js b/autofixer/ui.js
index a8c8780fba..107ea3f39e 100644
--- a/autofixer/ui.js
+++ b/autofixer/ui.js
@@ -5,7 +5,7 @@ import { join, dirname } from 'path';
import { fileURLToPath } from 'url';
import { promisify } from 'util';
-const exec = promisify(execCb);
+const exec = (cmd, opts) => promisify(execCb)(cmd, { windowsHide: true, ...opts });
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
@@ -868,7 +868,7 @@ app.get('/logs', async (req, res) => {
// Get initial logs
const initialLogsCmd = `pm2 logs ${processName} --lines 50 --nostream --raw`;
- exec(initialLogsCmd, (error, stdout) => {
+ execCb(initialLogsCmd, { windowsHide: true }, (error, stdout) => {
if (res.writableEnded) return;
if (!error && stdout) {
@@ -885,7 +885,7 @@ app.get('/logs', async (req, res) => {
}
// Stream new logs
- pm2Process = spawn('pm2', ['logs', processName, '--lines', '0', '--raw'], { shell: process.platform === 'win32' });
+ pm2Process = spawn('pm2', ['logs', processName, '--lines', '0', '--raw'], { shell: process.platform === 'win32', windowsHide: true });
pm2Process.stdout.on('data', (data) => {
if (res.writableEnded) {
diff --git a/browser/server.js b/browser/server.js
index e65156246e..4c9d9fadff 100644
--- a/browser/server.js
+++ b/browser/server.js
@@ -69,7 +69,7 @@ async function launchBrowser() {
console.log(`🌐 Launching Chrome (headless=${headlessMode}, profile=${profileDir}) CDP on ${CDP_HOST}:${CDP_PORT}`);
- chromeProcess = spawn(chromePath, args, { stdio: 'ignore' });
+ chromeProcess = spawn(chromePath, args, { stdio: 'ignore', windowsHide: true });
chromeProcess.on('exit', (code) => {
console.log(`⚠️ Chrome exited with code ${code}`);
diff --git a/package-lock.json b/package-lock.json
index 93fe005038..d060d8ef42 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "portos",
- "version": "1.5.0",
+ "version": "1.5.1",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "portos",
- "version": "1.5.0",
+ "version": "1.5.1",
"license": "MIT",
"dependencies": {
"express": "^4.21.2",
diff --git a/package.json b/package.json
index f4e4323934..fb89ffa2a7 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "portos",
- "version": "1.5.0",
+ "version": "1.5.1",
"private": true,
"description": "Local dev machine App OS portal",
"author": "Adam Eivy (@antic|@atomantic)",
diff --git a/server/cos-runner/index.js b/server/cos-runner/index.js
index 070170f378..cb72a819c4 100644
--- a/server/cos-runner/index.js
+++ b/server/cos-runner/index.js
@@ -306,7 +306,7 @@ async function getProcessStats(pid) {
const psCmd = process.platform === 'win32'
? `tasklist /FI "PID eq ${safePid}" /FO CSV /NH`
: `ps -p ${safePid} -o pid=,pcpu=,rss=,state=`;
- const result = await execAsync(psCmd).catch(() => ({ stdout: '' }));
+ const result = await execAsync(psCmd, { windowsHide: true }).catch(() => ({ stdout: '' }));
const line = result.stdout.trim();
if (!line) {
@@ -434,7 +434,8 @@ app.post('/spawn', async (req, res) => {
cwd,
shell: false,
stdio: ['pipe', 'pipe', 'pipe'],
- env: { ...process.env, ...envVars }
+ env: { ...process.env, ...envVars },
+ windowsHide: true
});
// Detect if stream-json format is active (Claude CLI with streaming)
@@ -711,7 +712,8 @@ app.post('/run', async (req, res) => {
cwd,
shell: false,
stdio: ['pipe', 'pipe', 'pipe'],
- env: { ...process.env, ...envVars }
+ env: { ...process.env, ...envVars },
+ windowsHide: true
});
const startTime = Date.now();
@@ -939,7 +941,7 @@ async function checkProcessRunning(pid) {
const { promisify } = await import('util');
const execAsync = promisify(exec);
- const result = await execAsync(`ps -p ${safePid} -o pid=`).catch(() => ({ stdout: '' }));
+ const result = await execAsync(`ps -p ${safePid} -o pid=`, { windowsHide: true }).catch(() => ({ stdout: '' }));
return result.stdout.trim() !== '';
}
diff --git a/server/services/commands.js b/server/services/commands.js
index 2a985b7a66..a4694af387 100644
--- a/server/services/commands.js
+++ b/server/services/commands.js
@@ -52,7 +52,8 @@ export function executeCommand(command, workspacePath, onData, onComplete) {
const child = spawn(baseCommand, parts.slice(1), {
cwd: workspacePath || process.cwd(),
env: { ...process.env, FORCE_COLOR: '1' },
- shell: false
+ shell: false,
+ windowsHide: true
});
activeCommands.set(commandId, child);
diff --git a/server/services/cos.js b/server/services/cos.js
index 1894578ea0..26f6693fc8 100644
--- a/server/services/cos.js
+++ b/server/services/cos.js
@@ -30,8 +30,10 @@ export const cosEvents = _cosEvents;
const PORTOS_UI_URL = process.env.PORTOS_UI_URL || `http://localhost:${process.env.PORT_UI || 5555}`;
-const execAsync = promisify(exec);
-const execFileAsync = promisify(execFile);
+const _execAsync = promisify(exec);
+const _execFileAsync = promisify(execFile);
+const execAsync = (cmd, opts) => _execAsync(cmd, { windowsHide: true, ...opts });
+const execFileAsync = (cmd, args, opts) => _execFileAsync(cmd, args, { windowsHide: true, ...opts });
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
diff --git a/server/services/git.js b/server/services/git.js
index 39c0fb095f..c3407f5915 100644
--- a/server/services/git.js
+++ b/server/services/git.js
@@ -15,7 +15,8 @@ function execGit(args, cwd, options = {}) {
const child = spawn('git', args, {
cwd,
shell: false,
- maxBuffer: options.maxBuffer || 10 * 1024 * 1024
+ maxBuffer: options.maxBuffer || 10 * 1024 * 1024,
+ windowsHide: true
});
let stdout = '';
@@ -341,7 +342,7 @@ export async function checkout(dir, branchName) {
export async function createPR(dir, { title, body, base, head }) {
return new Promise((resolve) => {
const args = ['pr', 'create', '--title', title, '--body', body || '', '--base', base, '--head', head];
- const child = spawn('gh', args, { cwd: dir, shell: false });
+ const child = spawn('gh', args, { cwd: dir, shell: false, windowsHide: true });
let stdout = '';
let stderr = '';
diff --git a/server/services/pm2.js b/server/services/pm2.js
index 6b1fe1adeb..f060f4a876 100644
--- a/server/services/pm2.js
+++ b/server/services/pm2.js
@@ -32,7 +32,8 @@ function spawnPm2Cli(action, name, pm2Home) {
return new Promise((resolve, reject) => {
const child = spawn('pm2', [action, name], {
shell: IS_WIN,
- env: buildEnv(pm2Home)
+ env: buildEnv(pm2Home),
+ windowsHide: true
});
let stderr = '';
child.stderr.on('data', (data) => { stderr += data.toString(); });
@@ -165,7 +166,8 @@ export async function getAppStatus(name, pm2Home = null) {
return new Promise((resolve) => {
const child = spawn('pm2', ['jlist'], {
shell: IS_WIN,
- env: buildEnv(pm2Home)
+ env: buildEnv(pm2Home),
+ windowsHide: true
});
let stdout = '';
@@ -212,7 +214,8 @@ export async function listProcesses(pm2Home = null) {
return new Promise((resolve) => {
const child = spawn('pm2', ['jlist'], {
shell: IS_WIN,
- env: buildEnv(pm2Home)
+ env: buildEnv(pm2Home),
+ windowsHide: true
});
let stdout = '';
@@ -252,7 +255,8 @@ export async function getLogs(name, lines = 100, pm2Home = null) {
const args = ['logs', name, '--lines', String(lines), '--nostream', '--raw'];
const child = spawn('pm2', args, {
shell: IS_WIN,
- env: buildEnv(pm2Home)
+ env: buildEnv(pm2Home),
+ windowsHide: true
});
let stdout = '';
@@ -328,7 +332,8 @@ export async function startFromEcosystem(cwd, processNames = [], pm2Home = null)
const child = spawn('pm2', args, {
cwd,
shell: IS_WIN,
- env: buildEnv(pm2Home)
+ env: buildEnv(pm2Home),
+ windowsHide: true
});
let stdout = '';
let stderr = '';
diff --git a/server/services/runner.js b/server/services/runner.js
index bfe4ec29f1..085c76be3a 100644
--- a/server/services/runner.js
+++ b/server/services/runner.js
@@ -70,7 +70,8 @@ export async function executeCliRun(runId, provider, prompt, workspacePath, onDa
const childProcess = spawn(provider.command, args, {
cwd: workspacePath,
- env: { ...process.env, ...provider.envVars }
+ env: { ...process.env, ...provider.envVars },
+ windowsHide: true
});
// Pass prompt via stdin to avoid OS argv limits
diff --git a/server/services/scriptRunner.js b/server/services/scriptRunner.js
index ca8b1f2bff..6c75afb310 100644
--- a/server/services/scriptRunner.js
+++ b/server/services/scriptRunner.js
@@ -339,7 +339,8 @@ export async function executeScript(scriptId) {
const child = spawn(validation.baseCommand, validation.args || [], {
cwd: join(__dirname, '../../'),
timeout: 60000, // 1 minute timeout
- shell: false
+ shell: false,
+ windowsHide: true
});
let output = '';
diff --git a/server/services/worktreeManager.js b/server/services/worktreeManager.js
index 59e0b4b646..aa4a341e01 100644
--- a/server/services/worktreeManager.js
+++ b/server/services/worktreeManager.js
@@ -24,7 +24,7 @@ const WORKTREES_DIR = join(__dirname, '../../data/cos/worktrees');
*/
function execGit(args, cwd) {
return new Promise((resolve, reject) => {
- const child = spawn('git', args, { cwd, shell: false });
+ const child = spawn('git', args, { cwd, shell: false, windowsHide: true });
let stdout = '';
let stderr = '';
child.stdout.on('data', d => { stdout += d.toString(); });