Repository navigation
feat(tui): re-check the gateway key at startup like the desktop app - #353
Merged
Merged
Conversation
Move the desktop controller's ensureKey logic into @codev/gateway as
ensureGatewayKey so both shells run the same pre-flight: validate the
stored gateway key, re-mint it silently through the SSO session when the
gateway rejects it, and only ask for a sign-in when that is impossible.
The result now says why a login is needed ("no-key" vs "rejected").
The TUI runs it once after sync completes. A refreshed key is merged into
the auth registry for every provider id the check names, then the
instance is disposed and re-bootstrapped; a rejected key that cannot be
renewed opens the configure dialog in a new dismissable mode. Machines
without a gateway key are left alone.
TUI tests boot the real app, so a new test preload sets CODEV_TEST_HOME to
an empty temp home; without it a developer's run would probe the real
gateway with their real key.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UtPnKQ9ATvc9kd1v74zC4Y
3 of 4 tasks
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UtPnKQ9ATvc9kd1v74zC4Y
quickbeard
force-pushed
the
feat/tui-key-preflight
branch
from
September 10, 2026 03:47
ec290f4 to
2a7b064
Compare
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.
Summary
Replaces #352, which GitHub closed when #351's branch was deleted on merge and will not reopen after the rebase. Same commits, rebased onto
main.The desktop app has run a startup key pre-flight since #296: it validates the stored gateway key, re-mints it silently through the SSO session when the gateway rejects it, and only asks for a sign-in when that is impossible. The TUI had nothing of the sort, so a key the gateway had since rejected left it "connected" and 401ing on every message, with
/configureas the only way back.ensureKeylogic moves into@codev/gatewayasensureGatewayKey(injectable fns for tests, hostfetchImpl, timeout cap). The desktop controller now delegates to it and adopts the refreshed session; its wire type and tests are unchanged. The result distinguishesneeds-loginreasons:no-keyvsrejected.app.tsxafter sync completes.refreshedmerges the key into the auth registry for every provider id (current + legacy spellings), then dispose + bootstrap like the configure flow.rejectedopensDialogConfigurein a newdismissablemode when no dialog is up.no-key(a machine set up with some other provider, or not at all) is ignored so non-gateway users are never nagged.~/.codev/~/.codev-hub. A newtest/preload.tssetsCODEV_TEST_HOMEto an empty temp home, same convention as core'sGlobalandpackages/opencode/test/preload.ts.bunfig.tomlis an upstream file, so it has aDIVERGENCES.mdrow; theapp.tsxrow is extended.Test plan
packages/codev-gateway:bun test(75 pass) — newensure-key.test.tsports the desktop cases plus timeout cap,no-keyvsrejected, andfetchImplplumbingpackages/desktop:bun test src/main/gateway-sso(22 pass),bun typecheckpackages/tui: fullbun test(269 pass, 0 fail) with the preload,bun typecheck🤖 Generated with Claude Code
https://claude.ai/code/session_01UtPnKQ9ATvc9kd1v74zC4Y