From c63320023fde821c78f9e2a4f0573b230298d1b3 Mon Sep 17 00:00:00 2001 From: Adam Badar Date: Sat, 29 Aug 2026 14:59:41 -0400 Subject: [PATCH] fix(browse): honour CHROMIUM_PROFILE in cli profile-lock cleanup cli.ts resolved the Chromium profile dir with a hardcoded $HOME/.gstack/chromium-profile, while browser-manager launches the profile returned by config.resolveChromiumProfile(), which honours CHROMIUM_PROFILE and GSTACK_HOME. killOrphanChromium() and cleanChromiumProfileLocks() are called with no argument, so whenever CHROMIUM_PROFILE was set they cleaned locks for, and killed Chromium on, the DEFAULT profile rather than the one being launched. Starting a browser with a custom profile therefore evicted an unrelated browser running on the default profile. Delegating to resolveChromiumProfile() also picks up GSTACK_HOME and os.homedir(), so the cleanup path now matches the launch path on Windows where HOME is frequently unset. --- browse/src/cli.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/browse/src/cli.ts b/browse/src/cli.ts index 55c69c670..1ba6c3afc 100644 --- a/browse/src/cli.ts +++ b/browse/src/cli.ts @@ -14,7 +14,7 @@ import * as path from 'path'; import { spawn as nodeSpawn } from 'child_process'; import { safeUnlink, safeUnlinkQuiet, safeKill, isProcessAlive } from './error-handling'; import { writeSecureFile, mkdirSecure } from './file-permissions'; -import { resolveConfig, ensureStateDir, readVersionHash, isPairAgentEnabled } from './config'; +import { resolveConfig, ensureStateDir, readVersionHash, isPairAgentEnabled, resolveChromiumProfile } from './config'; import { parseProxyConfig, computeConfigHash, ProxyConfigError } from './proxy-config'; import { redactProxyUrl } from './proxy-redact'; import { spawnTerminalAgent } from './terminal-agent-control'; @@ -257,9 +257,12 @@ function cleanupLegacyState(): void { } // ─── Chromium profile lock helpers (#1781) ───────────────────── -/** Profile dir used by headed/connect Chromium sessions. */ +/** Profile dir used by headed/connect Chromium sessions. Must resolve exactly + * as browser-manager does (config.resolveChromiumProfile), or the lock cleanup + * and orphan kill below target a different profile than the one being launched + * and evict an unrelated browser. */ function chromiumProfileDir(): string { - return path.join(process.env.HOME || '/tmp', '.gstack', 'chromium-profile'); + return resolveChromiumProfile(); } /** Remove Chromium SingletonLock/Socket/Cookie so a relaunch can acquire the