diff --git a/api/config.py b/api/config.py index b474a822..d306d89d 100644 --- a/api/config.py +++ b/api/config.py @@ -1255,9 +1255,16 @@ def _is_ambient_gh_cli_entry(source: str, label: str, key_source: str) -> bool: """True when a credential-pool entry is a seeded gh-cli token rather than one the user added explicitly. Filter these so Copilot doesn't appear in the dropdown just because `gh` is installed on the system. + + Also filters GITHUB_TOKEN env var entries, which are auto-detected from + the environment and should not cause Copilot to appear in the picker + when the token is a classic PAT (ghp_*) that Copilot API doesn't support. """ + source_lower = source.strip().lower() return ( - source.strip().lower() in _AMBIENT_GH_CLI_MARKERS + source_lower in _AMBIENT_GH_CLI_MARKERS + # Filter GITHUB_TOKEN env var entries (source="env:GITHUB_TOKEN") + or source_lower == "env:github_token" or label.strip().lower() == "gh auth token" or key_source.strip().lower() == "gh auth token" )