Repository navigation
feat(desktop): add Get a new API Key and refresh stale keys at startup - #296
Merged
Merged
Conversation
DialogConfigure had one caller, the configure gate, which fires only when no provider is connected — so a gateway key the backend had since rejected left the sign-in flow unreachable while every message 401'd. Add ensureKey() to the gateway SSO controller, the desktop twin of codev-hub's ensureFreshGatewayKey: validate against /key/info bounded by a 2.5s race, silently re-mint via silentSso when rejected, and ask for a login only when that is impossible. Add a Get a new API Key... menu item (macOS app menu / Windows File menu, beside Settings) dispatching a new gateway.apiKey.new command, which also lands in the command palette. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
DialogConfigure renders hideClose and marks itself persistent, which is right for the configure gate but traps anyone who opens it from the new menu command or the startup key check — a backdrop click no longer closes anything since the dialog rework. Gate dismissability on a prop. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
quickbeard
force-pushed
the
feat/gateway-key-refresh
branch
from
August 22, 2026 09:16
c0b41c1 to
3cef4b7
Compare
This was referenced Sep 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The app fetches a gateway API key once, at first sign-in, and has no way to ever fetch another.
DialogConfigure— which owns the whole SSO flow — has exactly one caller:GatewayConfigureGate, which opens only when no provider is connected. An expired key is still a connected provider, so the gate stays shut: every message 401s while the app considers itself signed in, and the sign-in flow is unreachable.Meanwhile
@codev/gatewayalready exported a testedvalidateApiKey(the same/key/infocheckcodevhubuses) with zero production callers — the desktop only ever checked that a key exists, never that it works.What this adds
1. A startup key check that heals itself. New
ensureKey()on the gateway SSO controller, modelled oncodevhub'sensureFreshGatewayKey:/key/info, raced against a 2.5s timeout so a slow gateway never delays startup;trueand "couldn't tell" both leave the key alone, so an unreachable gateway never signs anyone out;silentSso+fetchApiKeyand re-save the record with every other field intact (model, provider identity — dropping them would silently re-label a manually named provider);The renderer runs it once per window after sync settles, opening
DialogConfigureonneeds-login.2. A manual way in. A "Get a new API Key..." item dispatching a new
gateway.apiKey.newcommand:platforms: ["windows"])That split is what Settings itself already does — Windows/Linux render no app menu, so app-level items get rehomed to File. Because menu items dispatch through the command registry, registering the command gets the palette entry for free.
Verification
bun typecheckclean inpackages/app,packages/desktop,packages/codev-gateway; fullbun turbo typecheckgreen via the pre-push hook.ensureKeybranch: valid key untouched; unreachable gateway untouched (and no refresh attempted); rejected key re-minted with the rest of the record preserved; no-session and no-key both asking for login; and the saved gateway URL used when an SSO-minted key records nobase_url.bun testinpackages/desktop: 14 pass in that file.bun run test:unitinpackages/app: 690 pass.bun testinpackages/codev-gateway: 39 pass.CoDev > Get a new API Key...on macOS andFile > Get a new API Key...on Windows/Linux.ensureKey, confirming the whole chain fires end to end — renderer → IPC → controller → a live/key/inforound-trip →true→ silent no-op:Not verified in the GUI: the menu item and the
needs-logindialog. Screen capture is blocked in my environment and the app's CDP endpoint is unreachable, and forcing the rejected-key path would have meant tampering with your real credentials. The branch logic is unit-tested and the wiring is confirmed live, but the two visual surfaces are worth a manual click before merging.DIVERGENCES row added; CHANGELOG entry under Desktop / Web UI.
🤖 Generated with Claude Code