This repository was archived by the owner on Sep 30, 2026. It is now read-only.
Repository navigation
feat(auth): surface which Claude credential source is actually active - #10
Merged
Merged
Conversation
jcode's auth resolution silently prefers an imported external credential (Claude Code file/env, OpenCode) over its own auth.json accounts. When such an import is trusted, `/account switch` becomes a dead control: it only edits auth.json, which sits below the import in resolution order, so every switch appears to succeed while the live credential never changes. A bad imported token then 429s every session with no user signal. Make the active source observable and warn on the shadow condition: - Refactor `load_credentials` onto a single `resolve_active_credential` resolver so `load_credentials` and the new introspection can never drift on source priority. - Add `active_credential_source()` returning the resolved source, its location, a masked non-secret token prefix, the mapped jcode account label (for jcode accounts), and expiry state. - Add `external_import_shadowing_accounts()` detecting when a trusted external import wins while auth.json has configured accounts that are therefore never reached. - Surface the active source in `/auth` status, in the `/usage` card header, and log it once per process at the first session-start auth probe, each warning when an external import is shadowing configured accounts. - Warn right after `/account switch` when the switch cannot take effect because an import shadows auth.json, instead of silently reporting success. Verified against upstream v0.75.3 (load_credentials strict-priority order is unchanged there). cargo build+test+clippy clean for jcode-base and jcode-tui.
The bare /account account-center overlay listed each provider's Saved auth entry with only state, method, and validation. It did not surface which credential source jcode actually resolves for Claude, so an imported external source shadowing auth.json (which makes /account switch a silent no-op) was invisible in the overlay the ticket named. Enrich the Claude Saved auth entry detail with the active source and token identity prefix, and append the shadow warning when an external import is shadowing the numbered auth.json accounts, matching the wording already used in /auth status and the /usage card.
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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
jcode's Anthropic auth resolution (
load_credentials,crates/jcode-base/src/auth/claude.rs) returns the first non-expired source in strict priority: Claude Code file, thenCLAUDE_CODE_OAUTH_TOKENenv, then jcode's ownauth.jsonaccounts, then OpenCode. An imported external source therefore shadows jcode's own numbered accounts.Root cause of the 2026-08-11 work-box incident: a trusted Claude Code import (
~/.claude/.credentials.json) won resolution, so/account switch(which only editsauth.json, below the import) was a silent dead control. When the imported token went bad, every session 429'd and every switch did nothing, with no user-visible signal.Fix
Make the active credential source observable, and warn on the shadow condition:
load_credentialsonto oneresolve_active_credentialresolver, soload_credentialsand the new introspection cannot drift on source priority.active_credential_source()returns the resolved source, its location, a masked non-secret token prefix, the mapped jcode account label (for jcode accounts), and expiry state.external_import_shadowing_accounts()detects when a trusted external import wins whileauth.jsonhas configured accounts that are therefore never reached./authstatus, in the/usagecard header, and log it once per process at the first session-start auth probe. Each warns when an external import is shadowing configured accounts./account switchwhen the switch cannot take effect because an import shadowsauth.json, instead of silently reporting success.Verification
load_credentialsstrict-priority order is unchanged there, so this diagnosis and fix apply directly.claude_tests.rs: token masking, source classification, jcode-account resolution, and the external-import-shadows-accounts case.cargo build+cargo test -p jcode-base auth::claude(33 pass) +cargo clippyclean forjcode-base(0 warnings) andjcode-tui(only pre-existing warnings in untouched files).Token prefixes are capped at 12 chars; no full secret is ever printed or logged.