mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-10 22:21:22 -07:00
fix(vscode): resolve unsafe type assertion lint errors (#19006)
This commit is contained in:
@@ -243,12 +243,10 @@ export class DiffManager {
|
||||
// Find and close the tab corresponding to the diff view
|
||||
for (const tabGroup of vscode.window.tabGroups.all) {
|
||||
for (const tab of tabGroup.tabs) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
||||
const input = tab.input as {
|
||||
modified?: vscode.Uri;
|
||||
original?: vscode.Uri;
|
||||
};
|
||||
if (input && input.modified?.toString() === rightDocUri.toString()) {
|
||||
if (
|
||||
tab.input instanceof vscode.TabInputTextDiff &&
|
||||
tab.input.modified.toString() === rightDocUri.toString()
|
||||
) {
|
||||
await vscode.window.tabGroups.close(tab);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -112,6 +112,11 @@ function sendIdeContextUpdateNotification(
|
||||
transport.send(notification);
|
||||
}
|
||||
|
||||
function getSessionId(req: Request): string | undefined {
|
||||
const header = req.headers[MCP_SESSION_ID_HEADER];
|
||||
return Array.isArray(header) ? header[0] : header;
|
||||
}
|
||||
|
||||
export class IDEServer {
|
||||
private server: HTTPServer | undefined;
|
||||
private context: vscode.ExtensionContext | undefined;
|
||||
@@ -206,10 +211,7 @@ export class IDEServer {
|
||||
context.subscriptions.push(onDidChangeDiffSubscription);
|
||||
|
||||
app.post('/mcp', async (req: Request, res: Response) => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
||||
const sessionId = req.headers[MCP_SESSION_ID_HEADER] as
|
||||
| string
|
||||
| undefined;
|
||||
const sessionId = getSessionId(req);
|
||||
let transport: StreamableHTTPServerTransport;
|
||||
|
||||
if (sessionId && this.transports[sessionId]) {
|
||||
@@ -291,10 +293,7 @@ export class IDEServer {
|
||||
});
|
||||
|
||||
const handleSessionRequest = async (req: Request, res: Response) => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
||||
const sessionId = req.headers[MCP_SESSION_ID_HEADER] as
|
||||
| string
|
||||
| undefined;
|
||||
const sessionId = getSessionId(req);
|
||||
if (!sessionId || !this.transports[sessionId]) {
|
||||
this.log('Invalid or missing session ID');
|
||||
res.status(400).send('Invalid or missing session ID');
|
||||
@@ -339,8 +338,7 @@ export class IDEServer {
|
||||
});
|
||||
|
||||
this.server = app.listen(0, '127.0.0.1', async () => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
||||
const address = (this.server as HTTPServer).address();
|
||||
const address = this.server?.address();
|
||||
if (address && typeof address !== 'string') {
|
||||
this.port = address.port;
|
||||
this.log(`IDE server listening on http://127.0.0.1:${this.port}`);
|
||||
|
||||
Reference in New Issue
Block a user