fix(ide): Update IDE extension to write auth token in env var (#14999)

This commit is contained in:
Shreya Keshive
2025-12-12 11:42:49 -05:00
committed by GitHub
parent 86134e9970
commit bb33e281c0
2 changed files with 16 additions and 1 deletions

View File

@@ -108,7 +108,7 @@ describe('IDEServer', () => {
await ideServer.start(mockContext);
const replaceMock = mockContext.environmentVariableCollection.replace;
expect(replaceMock).toHaveBeenCalledTimes(2);
expect(replaceMock).toHaveBeenCalledTimes(3);
expect(replaceMock).toHaveBeenNthCalledWith(
1,
@@ -127,6 +127,12 @@ describe('IDEServer', () => {
expectedWorkspacePaths,
);
expect(replaceMock).toHaveBeenNthCalledWith(
3,
'GEMINI_CLI_IDE_AUTH_TOKEN',
'test-auth-token',
);
const port = getPortFromMock(replaceMock);
const expectedPortFile = path.join(
'/tmp',
@@ -254,6 +260,10 @@ describe('IDEServer', () => {
'GEMINI_CLI_IDE_WORKSPACE_PATH',
expectedWorkspacePaths,
);
expect(replaceMock).toHaveBeenCalledWith(
'GEMINI_CLI_IDE_AUTH_TOKEN',
'test-auth-token',
);
const port = getPortFromMock(replaceMock);
const expectedPortFile = path.join(

View File

@@ -38,6 +38,7 @@ class CORSError extends Error {
const MCP_SESSION_ID_HEADER = 'mcp-session-id';
const IDE_SERVER_PORT_ENV_VAR = 'GEMINI_CLI_IDE_SERVER_PORT';
const IDE_WORKSPACE_PATH_ENV_VAR = 'GEMINI_CLI_IDE_WORKSPACE_PATH';
const IDE_AUTH_TOKEN_ENV_VAR = 'GEMINI_CLI_IDE_AUTH_TOKEN';
interface WritePortAndWorkspaceArgs {
context: vscode.ExtensionContext;
@@ -70,6 +71,10 @@ async function writePortAndWorkspace({
IDE_WORKSPACE_PATH_ENV_VAR,
workspacePath,
);
context.environmentVariableCollection.replace(
IDE_AUTH_TOKEN_ENV_VAR,
authToken,
);
const content = JSON.stringify({
port,