Repository navigation
fix(poller): fall back to the desktop token when the CLI token is expired - #194
Open
wuhaotian2026-svg wants to merge 1 commit into
Open
wuhaotian2026-svg wants to merge 1 commit into
wuhaotian2026-svg wants to merge 1 commit into
Conversation
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
~/.claude/.credentials.jsonexists but holds an expired access token and the CLI refresh cannot run, the default Claude profile currently ends inTokenExpired, even though the Claude desktop app is signed in and keeps its own token cache fresh.read_credentials_from_sourcereturnsNone). A stale but present token never reaches it.poll_accounttry the desktop token cache after a failed refresh. A refresh that succeeds is still used first.desktop_credentials_for_default_path), is skipped whenCLAUDE_CONFIG_DIRis set, never replaces a desktop source with itself, and only accepts a desktop token that is not expired. Custom or multi-account profiles stay pinned to their own source.How I hit it: Windows 11, Microsoft Store build of the Claude desktop app (data under
%LOCALAPPDATA%\Claude-Data\claude_*), Claude CLI installed via WinGet. The CLI had been signed in once, so.credentials.jsonheld a token that later expired. The log showed "Skipping Claude token refresh: unable to determine the CLI version", and the widget showed the red!until I signed in to the CLI again, which only lasted until that token expired.Related: #183 (desktop credentials not found in the migrated data folder). That path discovery is already handled on
main; this PR covers the separate case where a stale CLI token hides a working desktop token.Testing
cargo fmt --all -- --check: clean.cargo test --locked --release: 602 passed, 0 failed, 6 ignored.cargo build --locked --release: succeeded.Manual, on the setup described above, with
--diagnose(log lines redacted):Before the change, the same setup logged
usage poll failed: TokenExpired.Not covered: no new unit test for the new branch. It needs a decryptable desktop token cache (DPAPI + AES-GCM), which I did not want to fake with fixtures. Happy to add a test if you can suggest a seam for it.
Checklist