mirror of
https://github.com/garrytan/gstack.git
synced 2026-09-15 01:15:29 +02:00
fix(browse): windowsHide sweep — flag every residual child_process site + full-census tripwire (#2160, #2415)
Add windowsHide:true at every remaining direct child_process call in browse/src that could flash a console window on Windows: - project-slug.ts (execSync gstack-slug) - browser-skills.ts (cp.spawnSync git rev-parse) - security-sidecar-client.ts (spawn — the LONG-LIVED Node sidecar, whose missing flag parked a console window on the taskbar for the daemon's whole lifetime) - find-security-sidecar.ts (execFileSync node --version) - meta-commands.ts (execSync git rev-parse in inbox + the osascript activate call) - browse-client.ts (cp.spawnSync git rev-parse) - file-permissions.ts (execFileSync whoami.exe — Windows-only, ran bare) - cli.ts (nodeSpawn osascript) windows-spawn-hide.test.ts gains a SWEEP test on top of the existing needles: it censuses EVERY child_process binding in src/ (static imports incl. aliases, `await import()` / require destructures, and `import * as cp` namespaces — 15 call sites across 10 files today) and fails CI on any call without windowsHide within its options window. Exemptions carry reasons — the one today is domain-skill-commands' interactive $EDITOR spawn (stdio:'inherit'; CREATE_NO_WINDOW would detach a console editor into an invisible console). Tests: windows-spawn-hide 5 pass; file-permissions 19 pass; browse-client 28 pass; browser-skill-commands 29 pass (81/81 combined). Fixes the app-side half of #2160; closes out #2415's residuals. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
7171f10364
commit
7686eb212d
@@ -103,7 +103,7 @@ export function resolveBrowseAuth(opts: BrowseClientOptions = {}): ResolvedAuth
|
||||
|
||||
function defaultStateFile(): string | null {
|
||||
try {
|
||||
const proc = cp.spawnSync('git', ['rev-parse', '--show-toplevel'], { encoding: 'utf-8', timeout: 2000 });
|
||||
const proc = cp.spawnSync('git', ['rev-parse', '--show-toplevel'], { encoding: 'utf-8', timeout: 2000, windowsHide: true });
|
||||
const root = proc.status === 0 ? proc.stdout.trim() : null;
|
||||
const base = root || process.cwd();
|
||||
return path.join(base, '.gstack', 'browse.json');
|
||||
|
||||
@@ -98,7 +98,7 @@ export function defaultTierPaths(opts: { projectRoot?: string; home?: string; bu
|
||||
|
||||
function detectProjectRoot(): string | null {
|
||||
try {
|
||||
const proc = cp.spawnSync('git', ['rev-parse', '--show-toplevel'], { encoding: 'utf-8', timeout: 2000 });
|
||||
const proc = cp.spawnSync('git', ['rev-parse', '--show-toplevel'], { encoding: 'utf-8', timeout: 2000, windowsHide: true });
|
||||
if (proc.status === 0) {
|
||||
const out = proc.stdout.trim();
|
||||
return out || null;
|
||||
|
||||
@@ -310,6 +310,7 @@ function raiseHeadedWindowMacOS(): void {
|
||||
nodeSpawn('osascript', ['-e', 'tell application "Google Chrome for Testing" to activate'], {
|
||||
stdio: 'ignore',
|
||||
detached: true,
|
||||
windowsHide: true,
|
||||
}).unref();
|
||||
} catch {
|
||||
// osascript missing or app not present — non-fatal
|
||||
|
||||
@@ -60,6 +60,7 @@ function currentUserSid(): string | null {
|
||||
const systemRoot = process.env.SystemRoot || process.env.windir || 'C:\\Windows';
|
||||
const out = execFileSync(`${systemRoot}\\System32\\whoami.exe`, ['/user', '/fo', 'csv', '/nh'], {
|
||||
encoding: 'utf8',
|
||||
windowsHide: true,
|
||||
});
|
||||
const match = out.match(/S-1-[\d-]+/);
|
||||
cachedSid = match ? match[0] : null;
|
||||
|
||||
@@ -30,7 +30,7 @@ export interface SidecarLocation {
|
||||
|
||||
function nodeOnPath(): string | null {
|
||||
try {
|
||||
execFileSync("node", ["--version"], { stdio: "ignore", timeout: 2000 });
|
||||
execFileSync("node", ["--version"], { stdio: "ignore", timeout: 2000, windowsHide: true });
|
||||
return "node";
|
||||
} catch {
|
||||
return null;
|
||||
|
||||
@@ -777,7 +777,7 @@ export async function handleMetaCommand(
|
||||
let activated = false;
|
||||
for (const appName of appNames) {
|
||||
try {
|
||||
execSync(`osascript -e 'tell application "${appName}" to activate'`, { stdio: 'pipe', timeout: 3000 });
|
||||
execSync(`osascript -e 'tell application "${appName}" to activate'`, { stdio: 'pipe', timeout: 3000, windowsHide: true });
|
||||
activated = true;
|
||||
break;
|
||||
} catch (err: any) {
|
||||
@@ -841,7 +841,7 @@ export async function handleMetaCommand(
|
||||
const { execSync } = await import('child_process');
|
||||
let gitRoot: string;
|
||||
try {
|
||||
gitRoot = execSync('git rev-parse --show-toplevel', { encoding: 'utf-8', stdio: ['pipe', 'pipe', 'pipe'] }).trim();
|
||||
gitRoot = execSync('git rev-parse --show-toplevel', { encoding: 'utf-8', stdio: ['pipe', 'pipe', 'pipe'], windowsHide: true }).trim();
|
||||
} catch (err: any) {
|
||||
// execSync throws with exit status on non-git directories
|
||||
if (err?.status === undefined && !err?.message?.includes('Command failed')) throw err;
|
||||
|
||||
@@ -21,7 +21,7 @@ export function getCurrentProjectSlug(): string {
|
||||
}
|
||||
try {
|
||||
const slugBin = path.join(os.homedir(), '.claude/skills/gstack/bin/gstack-slug');
|
||||
const out = execSync(slugBin, { encoding: 'utf8', timeout: 2000 }).trim();
|
||||
const out = execSync(slugBin, { encoding: 'utf8', timeout: 2000, windowsHide: true }).trim();
|
||||
const m = out.match(/SLUG="?([^"\n]+)"?/);
|
||||
cachedSlug = m ? m[1]! : (out || 'unknown');
|
||||
} catch {
|
||||
|
||||
@@ -138,6 +138,9 @@ function spawnSidecar(): boolean {
|
||||
const child = spawn(location.node, [location.entry], {
|
||||
stdio: ["pipe", "pipe", "pipe"],
|
||||
detached: false,
|
||||
// Long-lived Node sidecar — without this, Windows gives it a console
|
||||
// window that sits on the taskbar for the daemon's whole lifetime.
|
||||
windowsHide: true,
|
||||
});
|
||||
child.stdout.on("data", (chunk: Buffer) => {
|
||||
s.buffer += chunk.toString("utf-8");
|
||||
|
||||
Reference in New Issue
Block a user