Skip to content

Add GitHub Copilot provider with OAuth device flow#594

Open
RajPabnani03 wants to merge 1 commit intoathasdev:masterfrom
RajPabnani03:feat/copilot-provider
Open

Add GitHub Copilot provider with OAuth device flow#594
RajPabnani03 wants to merge 1 commit intoathasdev:masterfrom
RajPabnani03:feat/copilot-provider

Conversation

@RajPabnani03
Copy link
Copy Markdown

Implements GitHub Copilot as an AI provider using OAuth device flow authentication (closes #573).

  • OAuth device flow in Rust backend with 5 Tauri commands for start/poll/status/token/logout
  • Two-step token chain: GitHub OAuth token (keychain) → Copilot API token (in-memory cache with 5-min expiry buffer)
  • CopilotProvider with async header building and dynamic model fetching from the Copilot API
  • CopilotAuthModal UI for device code flow with copy-to-clipboard, countdown timer, and polling
  • Settings page replaces 'Coming Soon' badge with real Sign In/Connected as UI
  • Provider model selector shows Authenticate/Sign Out buttons for Copilot
  • CopilotIcon added to provider icon set
  • Optional buildHeadersAsync() method on AIProvider interface for providers needing async token refresh
  • Copilot uses tauriFetch to avoid CORS restrictions

Implements GitHub Copilot as an AI provider (Issue athasdev#573) using OAuth device
flow for authentication instead of static API keys. The Copilot chat API is
OpenAI-compatible, with a two-step token chain: GitHub OAuth token (stored
in keychain) exchanged for a short-lived Copilot API token (cached in Rust
memory with 5-min expiry buffer).

Rust backend (5 Tauri commands):
- copilot_start_device_flow: initiates GitHub OAuth device flow
- copilot_poll_device_token: polls for user authorization
- copilot_get_auth_status: checks if authenticated
- copilot_get_api_token: gets/refreshes Copilot API token with caching
- copilot_logout: removes OAuth token and clears cache

TypeScript provider:
- CopilotProvider with buildHeadersAsync() for dynamic OAuth headers
- Dynamic model fetching via Copilot API /models endpoint
- OpenAI-compatible payload format

UI:
- CopilotAuthModal for device code OAuth flow (copy, countdown, polling)
- Settings page replaces 'Coming Soon' with Sign In/Connected as UI
- Provider model selector shows Authenticate/Sign Out for Copilot
- CopilotIcon added to provider icons

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
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.

GitHub Copilot support

1 participant