[ide-mode] Use active files and selected text in user prompt (#4614)

This commit is contained in:
christine betts
2025-07-21 20:52:02 +00:00
committed by GitHub
parent d7a57d85a3
commit 1969d805f2
9 changed files with 194 additions and 113 deletions

View File

@@ -22,7 +22,7 @@ import { DiscoveredMCPTool } from './mcp-tool.js';
import { FunctionDeclaration, mcpToTool } from '@google/genai';
import { ToolRegistry } from './tool-registry.js';
import {
ActiveFileNotificationSchema,
OpenFilesNotificationSchema,
IDE_SERVER_NAME,
ideContext,
} from '../services/ideContext.js';
@@ -217,15 +217,15 @@ export async function connectAndDiscover(
console.error(`MCP ERROR (${mcpServerName}):`, error.toString());
updateMCPServerStatus(mcpServerName, MCPServerStatus.DISCONNECTED);
if (mcpServerName === IDE_SERVER_NAME) {
ideContext.clearActiveFileContext();
ideContext.clearOpenFilesContext();
}
};
if (mcpServerName === IDE_SERVER_NAME) {
mcpClient.setNotificationHandler(
ActiveFileNotificationSchema,
OpenFilesNotificationSchema,
(notification) => {
ideContext.setActiveFileContext(notification.params);
ideContext.setOpenFilesContext(notification.params);
},
);
}