mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-21 18:44:30 -07:00
feat(ide): add GEMINI_CLI_IDE_PID env var to override IDE process detection (#15842)
Co-authored-by: Adib234 <30782825+Adib234@users.noreply.github.com>
This commit is contained in:
@@ -208,6 +208,13 @@ async function getIdeProcessInfoForWindows(): Promise<{
|
||||
* to identify the main application process (e.g., the main VS Code window
|
||||
* process).
|
||||
*
|
||||
* This function can be overridden by setting the `GEMINI_CLI_IDE_PID`
|
||||
* environment variable. This is useful for launching Gemini CLI in a
|
||||
* standalone terminal while still connecting to an IDE instance.
|
||||
*
|
||||
* If `GEMINI_CLI_IDE_PID` is set, the function uses that PID and fetches
|
||||
* the command for it.
|
||||
*
|
||||
* If the IDE process cannot be reliably identified, it will return the
|
||||
* top-level ancestor process ID and command as a fallback.
|
||||
*
|
||||
@@ -219,6 +226,19 @@ export async function getIdeProcessInfo(): Promise<{
|
||||
}> {
|
||||
const platform = os.platform();
|
||||
|
||||
if (process.env['GEMINI_CLI_IDE_PID']) {
|
||||
const idePid = parseInt(process.env['GEMINI_CLI_IDE_PID'], 10);
|
||||
if (!isNaN(idePid) && idePid > 0) {
|
||||
if (platform === 'win32') {
|
||||
const processMap = await getProcessTableWindows();
|
||||
const proc = processMap.get(idePid);
|
||||
return { pid: idePid, command: proc?.command || '' };
|
||||
}
|
||||
const { command } = await getProcessInfo(idePid);
|
||||
return { pid: idePid, command };
|
||||
}
|
||||
}
|
||||
|
||||
if (platform === 'win32') {
|
||||
return getIdeProcessInfoForWindows();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user