fix: handle keychain hint and suppress pgrep spam

This commit is contained in:
Draculabo committed 2026-01-25 17:46:32 +08:00
1 parent d2945a6e8a
commit bd3d41aed1
5 files changed
+112 -7

No files matched your search

+22 -2
View File
@@ -1,6 +1,6 @@
import { exec, execSync } from 'child_process';
import { promisify } from 'util';
import findProcess from 'find-process';
import findProcess, { ProcessInfo } from 'find-process';
import { getAntigravityExecutablePath, isWsl } from '../../utils/paths';
import { logger } from '../../utils/logger';
@@ -51,6 +51,17 @@ function isHelperProcess(name: string, cmd: string): boolean {
return false;
}
function isPgrepNoMatchError(error: unknown): boolean {
if (!(error instanceof Error)) {
return false;
}
const message = error.message;
const hasPgrep = message.includes('pgrep -xi Antigravity');
const code = (error as { code?: number }).code;
return hasPgrep && code === 1;
}
/**
* Checks if the Antigravity process is running.
* Uses find-process package for robust cross-platform process detection.
@@ -63,7 +74,16 @@ export async function isProcessRunning(): Promise<boolean> {
// Use find-process to search for Antigravity processes
// 'name' search type matches process name
const processes = await findProcess('name', 'Antigravity', true);
let processes: ProcessInfo[] = [];
try {
processes = await findProcess('name', 'Antigravity', true);
} catch (error) {
if (isPgrepNoMatchError(error)) {
logger.debug('No Antigravity process found (pgrep returned 1)');
return false;
}
throw error;
}
logger.debug(`Found ${processes.length} processes matching 'Antigravity'`);