Skip to content

feat(desktop): make xAI Grok a first-class OAuth provider in the launcher - #37697

Merged
OutThisLife merged 7 commits into
mainfrom
bb/grok-provider-desktop
Jun 2, 2026
Merged

feat(desktop): make xAI Grok a first-class OAuth provider in the launcher#37697
OutThisLife merged 7 commits into
mainfrom
bb/grok-provider-desktop

Conversation

@OutThisLife

Copy link
Copy Markdown
Collaborator

Summary

xAI Grok was only reachable through the desktop's "I have an API key" form, even though a full xAI OAuth (SuperGrok / Premium+) flow already exists in the backend (hermes auth add xai-oauth). This promotes it to a first-class one-click provider card in the onboarding launcher, alongside Nous / Anthropic / OpenAI Codex / MiniMax.

It introduces a loopback PKCE flow: the desktop's local Python backend binds the 127.0.0.1 callback listener, the client opens the browser, and the redirect lands back automatically — nothing to copy or paste. The implementation reuses the existing xAI OAuth helpers (discovery, callback server, token exchange, persist) rather than duplicating them.

Backend (hermes_cli/web_server.py)

  • xai-oauth added to _OAUTH_PROVIDER_CATALOG with flow: "loopback" (now listed by /api/providers/oauth)
  • status dispatch → auth.get_xai_oauth_auth_status() so the card shows Connected
  • _start_xai_loopback_flow() + _xai_loopback_worker() (waits for callback, validates state, exchanges code, persists to auth store + credential pool — mirrors hermes auth add xai-oauth)
  • loopback branch wired into the start_oauth_login route; disconnect works via the generic clear_provider_auth

Desktop (apps/desktop)

  • types/hermes.ts: 'loopback' flow + LoopbackStart response shape
  • store/onboarding.ts: new awaiting_browser status; startProviderOAuth opens the auth URL and polls (generalized pollDevicepollSession)
  • desktop-onboarding-overlay.tsx: "xAI Grok" card title, loopback subtitle, and a waiting panel

Notes

  • The first-class card is the OAuth (SuperGrok / Premium+) path; the plain XAI_API_KEY path still lives in the API-key form (same split as Anthropic / OpenAI Codex).
  • This _OAUTH_PROVIDER_CATALOG + hardcoded API_KEY_OPTIONS split is the thing to collapse in the follow-up that feeds the selector dynamically from /providers.

Test plan

  • Desktop tsc -b typecheck clean; ESLint clean on edited files (repo-wide lint errors are pre-existing)
  • tests/hermes_cli/test_web_oauth_dispatch.py (12), test_web_server.py (211), test_auth_xai_oauth_provider.py (82), test_xai_oauth_pkce_token_exchange.py (14) all pass
  • New tests: catalog listing, start authorize-url, worker token persist, state-mismatch rejection
  • Live end-to-end OAuth from the desktop app against real xAI (not yet run — unit coverage is mocked)

…cher

xAI Grok was only reachable via the "I have an API key" form. xAI's
OAuth (SuperGrok / Premium+) flow already exists in the backend
(`hermes auth add xai-oauth`) but was never surfaced in the desktop
onboarding launcher.

Add a loopback PKCE flow: the local backend binds the 127.0.0.1
callback listener, the client opens the browser, and the redirect lands
back automatically — no code to copy/paste. Reuses the existing xAI
OAuth helpers (discovery, callback server, token exchange, persist)
rather than duplicating them.

- web_server: catalog entry (flow: loopback) + status dispatch +
  _start_xai_loopback_flow + background worker + route branch
- desktop: 'loopback' flow type, awaiting_browser status, xAI Grok card
  (PROVIDER_DISPLAY / FLOW_SUBTITLES / FlowPanel waiting render)
- tests: catalog listing, start authorize-url, worker persist, state
  mismatch rejection
@github-actions

github-actions Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

🔎 Lint report: bb/grok-provider-desktop vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 9683 on HEAD, 9682 on base (🆕 +1)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 5016 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

@OutThisLife
OutThisLife requested a review from Copilot June 2, 2026 22:42
@alt-glitch alt-glitch added type/feature New feature or request provider/xai xAI (Grok) comp/cli CLI entry point, hermes_cli/, setup wizard P3 Low — cosmetic, nice to have labels Jun 2, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Promotes xAI Grok OAuth to a first-class onboarding provider in the desktop launcher by adding a new loopback PKCE flow to the local FastAPI backend and wiring the desktop UI/store to open the browser and poll session status until completion.

Changes:

  • Backend: add xai-oauth to the OAuth provider catalog and implement loopback PKCE start + background worker to complete token exchange and persistence.
  • Desktop: extend OAuth flow typing/state machine with loopback + awaiting_browser, open the authorize URL, and poll the session until approved/error.
  • Tests: add coverage for provider catalog listing, loopback start response, successful persistence, and state-mismatch rejection.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/hermes_cli/test_web_oauth_dispatch.py Adds unit tests for xAI loopback flow listing/start/worker success + state mismatch.
hermes_cli/web_server.py Adds xai-oauth provider entry, status dispatch, loopback flow implementation, and start route wiring.
apps/desktop/src/types/hermes.ts Adds loopback flow and start-response typing.
apps/desktop/src/store/onboarding.ts Adds awaiting_browser state and generalizes polling to support loopback sessions.
apps/desktop/src/components/desktop-onboarding-overlay.tsx Adds xAI provider card ordering/title and a waiting panel for loopback flow.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread hermes_cli/web_server.py
Comment thread hermes_cli/web_server.py
Comment thread apps/desktop/src/store/onboarding.ts Outdated
- web_server: join the callback-server thread in the start error path so a
  failed discovery/URL build doesn't leave a daemon thread running
- web_server: loopback worker now bails if the session was cancelled while
  waiting for the callback or exchanging the code, instead of persisting
  tokens the user no longer wants (+ regression test)
- onboarding: fall back to window.open when the desktop bridge's
  openExternal is unavailable, so the flow never silently stalls

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Comment thread apps/desktop/src/store/onboarding.ts
Comment thread hermes_cli/web_server.py
Comment thread hermes_cli/web_server.py
- onboarding: openSignInUrl now falls back to window.open when the desktop
  bridge's openExternal throws/rejects (OS handler missing, user denied),
  not just when the bridge is absent
- web_server: cancelling a loopback session shuts down the 127.0.0.1
  callback server + joins its thread immediately, freeing the port instead
  of holding it until the wait times out (+ regression test)
- web_server: document the new "loopback" flow in the /api/providers/oauth
  enum, the poll-endpoint docstring, and the Phase 2 flow comment block

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Comment thread hermes_cli/web_server.py
source_label is meant to be a human-readable origin (file path / source),
not the internal auth_mode string ("oauth_pkce"). Surface the auth-store
path, then the source slug, then a generic label.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Comment thread hermes_cli/web_server.py
Shutting down the callback server stopped the serve thread but left the
worker spinning in _xai_wait_for_callback (which polls callback_result)
until the timeout. Flag callback_result as cancelled on DELETE so the
wait returns promptly and the daemon thread exits — avoids thread
buildup on repeated cancel/retry.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

@OutThisLife
OutThisLife enabled auto-merge June 2, 2026 23:38
@OutThisLife
OutThisLife disabled auto-merge June 2, 2026 23:43
@OutThisLife
OutThisLife merged commit 30a7a94 into main Jun 2, 2026
19 of 21 checks passed
@OutThisLife
OutThisLife deleted the bb/grok-provider-desktop branch June 2, 2026 23:43
davidgut1982 pushed a commit to davidgut1982/hermes-agent that referenced this pull request Jun 5, 2026
…der-desktop

feat(desktop): make xAI Grok a first-class OAuth provider in the launcher
alt-glitch pushed a commit that referenced this pull request Jun 14, 2026
feat(desktop): make xAI Grok a first-class OAuth provider in the launcher
T02200059 pushed a commit to T02200059/hermes-agent that referenced this pull request Jun 18, 2026
…der-desktop

feat(desktop): make xAI Grok a first-class OAuth provider in the launcher
waefrebeorn pushed a commit to waefrebeorn/slermes that referenced this pull request Jul 2, 2026
…der-desktop

feat(desktop): make xAI Grok a first-class OAuth provider in the launcher
santhreal pushed a commit to santhreal/hermes-agent that referenced this pull request Jul 13, 2026
…der-desktop

feat(desktop): make xAI Grok a first-class OAuth provider in the launcher
Gravezzz pushed a commit to Gravezzz/hermes-agent that referenced this pull request Jul 21, 2026
…der-desktop

feat(desktop): make xAI Grok a first-class OAuth provider in the launcher
leewenjie pushed a commit to leewenjie/hermes-agent that referenced this pull request Aug 7, 2026
…der-desktop

feat(desktop): make xAI Grok a first-class OAuth provider in the launcher
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard P3 Low — cosmetic, nice to have provider/xai xAI (Grok) type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants