fix: accept lowercase antigravity in process detection

This commit is contained in:
Draculabo committed 2026-01-26 01:37:58 +08:00
1 parent f15bb48fdd
commit 0d4e2ab21f
1 file changed
+28 -11
+28 -11
View File
@@ -56,8 +56,8 @@ function isPgrepNoMatchError(error: unknown): boolean {
return false; return false;
} }
const message = error.message; const message = error.message.toLowerCase();
const hasPgrep = message.includes('pgrep -xi Antigravity'); const hasPgrep = message.includes('pgrep') && message.includes('antigravity');
const code = (error as { code?: number }).code; const code = (error as { code?: number }).code;
return hasPgrep && code === 1; return hasPgrep && code === 1;
} }
@@ -74,18 +74,35 @@ export async function isProcessRunning(): Promise<boolean> {
// Use find-process to search for Antigravity processes // Use find-process to search for Antigravity processes
// 'name' search type matches process name // 'name' search type matches process name
let processes: ProcessInfo[] = []; const processMap = new Map<number, ProcessInfo>();
try { const searchNames = ['Antigravity', 'antigravity'];
processes = await findProcess('name', 'Antigravity', true); let sawNoMatch = false;
} catch (error) {
if (isPgrepNoMatchError(error)) { for (const searchName of searchNames) {
logger.debug('No Antigravity process found (pgrep returned 1)'); try {
return false; const matches = await findProcess('name', searchName, true);
for (const proc of matches) {
if (typeof proc.pid === 'number') {
processMap.set(proc.pid, proc);
}
}
} catch (error) {
if (isPgrepNoMatchError(error)) {
sawNoMatch = true;
continue;
}
throw error;
} }
throw error;
} }
logger.debug(`Found ${processes.length} processes matching 'Antigravity'`); const processes = Array.from(processMap.values());
if (processes.length === 0 && sawNoMatch) {
logger.debug('No Antigravity process found (pgrep returned 1)');
}
logger.debug(
`Found ${processes.length} processes matching 'Antigravity/antigravity'`,
);
for (const proc of processes) { for (const proc of processes) {
// Skip self // Skip self