Skip to content

fix(vscode): resolve unsafe type assertion lint errors#19006

Merged
ehedlund merged 2 commits intogoogle-gemini:mainfrom
ehedlund:fix/vscode-unsafe-type-assertions
Feb 13, 2026
Merged

fix(vscode): resolve unsafe type assertion lint errors#19006
ehedlund merged 2 commits intogoogle-gemini:mainfrom
ehedlund:fix/vscode-unsafe-type-assertions

Conversation

@ehedlund
Copy link
Contributor

Summary

Resolves unsafe type assertion lint errors in the VS Code companion package.

Details

  • Safe Tab Input Handling: In diff-manager.ts, replaced an unsafe type assertion on tab.input with a robust instanceof vscode.TabInputTextDiff check.
  • Session ID Helper: Added getSessionId in ide-server.ts to safely extract the session ID from request headers, correctly handling both string and array-of-strings cases.
  • Optional Chaining: Replaced unsafe casting of this.server with optional chaining when accessing address().
  • Linter Cleanup: Removed now-unused eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion directives.

Related Issues

Resolves lint errors in packages/vscode-ide-companion.

How to Validate

Run the following commands in the package directory:

npm run lint -w packages/vscode-ide-companion
npm run check-types -w packages/vscode-ide-companion

Pre-Merge Checklist

  • Updated relevant documentation and README (if needed)
  • Added/updated tests (if needed)
  • Noted breaking changes (if any)
  • Validated on required platforms/methods:
    • MacOS
      • npm run

@ehedlund ehedlund requested a review from a team as a code owner February 13, 2026 16:58
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @ehedlund, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on enhancing type safety within the VS Code companion package by resolving several unsafe type assertion lint errors. The changes introduce more robust type checking mechanisms and helper functions to prevent potential runtime issues and improve code maintainability, aligning with stricter TypeScript practices.

Highlights

  • Safe Tab Input Handling: Replaced an unsafe type assertion on tab.input with a robust instanceof vscode.TabInputTextDiff check in diff-manager.ts.
  • Session ID Helper: Added getSessionId in ide-server.ts to safely extract the session ID from request headers, handling both string and array-of-strings cases.
  • Optional Chaining: Replaced unsafe casting of this.server with optional chaining when accessing address() in ide-server.ts.
  • Linter Cleanup: Removed now-unused eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion directives across the codebase.
Changelog
  • packages/vscode-ide-companion/src/diff-manager.ts
    • Replaced an unsafe type assertion on tab.input with an instanceof vscode.TabInputTextDiff check.
    • Removed an eslint-disable-next-line directive related to unsafe type assertions.
  • packages/vscode-ide-companion/src/ide-server.ts
    • Added a new helper function getSessionId to safely extract session IDs from request headers.
    • Updated the app.post('/mcp') handler to utilize the new getSessionId helper for safer session ID extraction.
    • Updated the handleSessionRequest function to utilize the new getSessionId helper for safer session ID extraction.
    • Replaced an unsafe type assertion on this.server with optional chaining (this.server?.address()) when retrieving the server address.
    • Removed multiple eslint-disable-next-line directives related to unsafe type assertions.
Activity
  • Updated relevant documentation and README (if needed) has been checked off.
  • Added/updated tests (if needed) has been checked off.
  • Validated on MacOS using npm run has been checked off.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The pull request successfully addresses unsafe type assertion lint errors in the VS Code companion package. The changes improve type safety by using instanceof checks for VS Code tabs and implementing a helper function to safely extract session IDs from request headers, which now correctly handles both string and array-of-strings cases. The replacement of unsafe casts with optional chaining and robust type checks enhances the overall maintainability and reliability of the codebase. No high or critical issues were identified during the review.

Copy link
Member

@gundermanc gundermanc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Love to see this sort of cleanup.

@gemini-cli gemini-cli bot added the status/need-issue Pull requests that need to have an associated issue. label Feb 13, 2026
@ehedlund ehedlund added this pull request to the merge queue Feb 13, 2026
Merged via the queue into google-gemini:main with commit b16c9a5 Feb 13, 2026
64 of 67 checks passed
@ehedlund ehedlund deleted the fix/vscode-unsafe-type-assertions branch February 13, 2026 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status/need-issue Pull requests that need to have an associated issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants