From 7d70b2ba0cb98d0c100d3506b91518289be575e7 Mon Sep 17 00:00:00 2001 From: amankumarsingh77 Date: Mon, 4 May 2026 21:14:30 +0530 Subject: docs: add speed-optimizations research; chore: improve browser detection in setup --- src/setup.ts | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'src/setup.ts') diff --git a/src/setup.ts b/src/setup.ts index 0d715ab..3909603 100644 --- a/src/setup.ts +++ b/src/setup.ts @@ -23,7 +23,7 @@ async function runSetup(ctx: ExtensionContext, client: BrowserClient): Promise out.includes(n), - ); + const lines = out.split("\n").map((l) => l.trim()).filter(Boolean); + const browserProcesses = ["google chrome", "chromium", "microsoft edge"]; + return lines.some((l) => { + if (l.includes("helper") || l.includes("renderer")) return false; + return browserProcesses.includes(l); + }); + } else if (process.platform === "linux") { + // Use args to distinguish the main browser process from sub-processes + // (GPU, renderer, utility, etc.) which carry --type= flags. + const out = execSync("ps -A -o comm=,args=", { timeout: 5000 }).toString().toLowerCase(); + const lines = out.split("\n").map((l) => l.trim()).filter(Boolean); + const browserComms = ["chrome", "chromium", "chromium-browser", "msedge", "microsoft-edge", "google-chrome"]; + return lines.some((line) => { + const parts = line.split(/\s+/); + const comm = parts[0] ?? ""; + if (!comm || !browserComms.includes(comm)) return false; + const isSubprocess = line.includes("--type=") && !line.includes("--type=browser"); + return !isSubprocess; + }); } else if (process.platform === "win32") { const out = execSync("tasklist", { timeout: 5000 }).toString().toLowerCase(); return ["chrome.exe", "msedge.exe"].some((n) => out.includes(n)); -- cgit v1.2.3