Skip to content

Allow completion providers for undefined shell types #253012

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jun 30, 2025

This PR enables completion providers to work with pseudoterminal-based terminals that don't have a defined shell type. Previously, these terminals were completely blocked from using custom completion providers due to an early return when shellType was undefined.

Problem

The issue was in terminalSuggestAddon.ts where completion requests would return early if shellType was undefined:

await this._shellTypeInit;
if (!this.shellType) {
    return; // This blocked pseudoterminal-based terminals
}

This prevented pseudoterminal-based terminals (like those created by extensions) from using any completion providers, even those that don't require a specific shell type.

Solution

1. Remove Early Return for Undefined Shell Type

  • Kept the await this._shellTypeInit to wait for shell type initialization when possible
  • Removed the early return that blocked completion providers when shellType is undefined
  • Updated comments to clarify that completion providers can work with undefined shell types

2. Update Completion Service to Handle Undefined Shell Types

  • Modified ITerminalCompletionService.provideCompletions() to accept TerminalShellType | undefined
  • Updated provider filtering logic to allow providers when shellType is undefined:
    // Before: Would fail with undefined shellType
    if (provider.shellTypes && !provider.shellTypes.includes(shellType)) {
        return undefined;
    }
    
    // After: Allows providers to work with undefined shellType
    if (provider.shellTypes && shellType && !provider.shellTypes.includes(shellType)) {
        return undefined;
    }

3. Fix Telemetry Reporting

  • Removed the requirement for shellType to be defined before reporting telemetry
  • Updated getFirstShown() and updateShown() methods to handle undefined shell types gracefully
  • Ensures completion latency is tracked regardless of shell type

Behavior Changes

Before: Pseudoterminal-based terminals (shellType = undefined) could not use any completion providers

After:

  • ✅ Providers without shellTypes restrictions work with all terminals (including pseudoterminals)
  • ✅ Providers with specific shellTypes work when shellType matches OR is undefined
  • ✅ Telemetry is reported for all completions regardless of shellType
  • ✅ All existing shell-specific filtering behavior is preserved

Testing

Added comprehensive tests to validate the provider filtering logic:

  • Providers with no shellTypes restriction work with undefined shellType
  • Providers with shellTypes restriction work with undefined shellType
  • Providers with shellTypes restriction work with matching shellType
  • Providers with shellTypes restriction are filtered out for non-matching shellType

This change enables extension-provided completion providers to work with pseudoterminal-based terminals while maintaining all existing functionality.

Fixes #253011.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • electronjs.org
    • Triggering command: node-gyp (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits June 30, 2025 14:58
Co-authored-by: Tyriar <2193314+Tyriar@users.noreply.github.com>
Co-authored-by: Tyriar <2193314+Tyriar@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] Allow completion providers for undefined shell types Allow completion providers for undefined shell types Jun 30, 2025
@Copilot Copilot AI requested a review from Tyriar June 30, 2025 15:04
Copilot finished work on behalf of Tyriar June 30, 2025 15:04
@Tyriar Tyriar added this to the July 2025 milestone Jul 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow completion providers for undefined shell types
2 participants