Skip to content

fix(claude): explain CLI login when only the desktop app is signed in#828

Merged
robinebers merged 3 commits into
mainfrom
fix/claude-desktop-only-login-hint
Jul 2, 2026
Merged

fix(claude): explain CLI login when only the desktop app is signed in#828
robinebers merged 3 commits into
mainfrom
fix/claude-desktop-only-login-hint

Conversation

@robinebers

Copy link
Copy Markdown
Owner

TL;DR

When someone is signed in only through the Claude desktop app, OpenUsage now explains that a one-time claude CLI login is needed, instead of showing a misleading "Not logged in". Fixes #825.

What was happening

  • The Claude provider reads credentials from the places the Claude Code CLI writes them: the keychain item and ~/.claude/.credentials.json.
  • A login done only in the Claude desktop app is stored in an Electron-encrypted blob (safeStorage) OpenUsage can't read, so neither source exists.
  • The user then saw "Not logged in. Run claude to authenticate." while being visibly signed in — which reads as a bug (claude broken #825).

What this changes

  • ClaudeAuthStore gains a hasDesktopAppData() check for the desktop app's data folders (~/Library/Application Support/Claude Code and ~/Library/Application Support/Claude/claude-code), plus a new desktopAppOnly error case.
  • When no CLI credentials exist anywhere but desktop-app data is present, the provider shows: "Signed in to the Claude desktop app? OpenUsage needs a CLI login — run claude in a terminal and sign in once." Both logins coexist, so one CLI sign-in fixes it for good.
  • The new case is bucketed as not_logged_in for telemetry (same expected-noise category).
  • docs/providers/claude.md gets a troubleshooting entry.

Heads-up

  • The credential fallback order and token refresh are untouched; the new path only triggers when there are no CLI credentials at all.
  • The thread's larger proposal (OpenUsage running its own OAuth login flow) is out of scope here and would be its own feature.

Tests

  • New regression test covering both branches: desktop data present → CLI-login guidance; nothing at all → the plain "Not logged in".
  • Full suite passes (748 tests, 0 failures).
  • Built and relaunched the dev app locally; on a machine with a CLI login Claude refreshes normally. End-to-end confirmation of the desktop-only state would come from the issue reporter, who offered to test a beta.

Made with Cursor

A login done only in the Claude desktop app lives in an Electron-encrypted
blob OpenUsage can't read, so users saw a misleading "Not logged in" while
clearly signed in. When no CLI credentials exist but the desktop app's data
folder does, point at the one-time `claude` CLI login instead.

Fixes #825

Co-authored-by: Cursor <cursoragent@cursor.com>

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

robinebers has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit be66c05. Configure here.

Comment thread Sources/OpenUsage/Providers/Claude/ClaudeProvider.swift
robinebers and others added 2 commits July 2, 2026 19:42
…tored

A stored-but-blank CLI token passes the auth store's isEmpty check but is
dropped by the provider's trim filter; the desktop-app hint must not fire
in that case since the CLI did write credentials (Bugbot).

Co-authored-by: Cursor <cursoragent@cursor.com>

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

robinebers has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@robinebers robinebers merged commit 89b0af0 into main Jul 2, 2026
3 checks passed
@robinebers robinebers deleted the fix/claude-desktop-only-login-hint branch July 2, 2026 15:50
robinebers added a commit that referenced this pull request Jul 2, 2026
… main

PRs #827 (drops ccusage) and #828 (adds this test using the old
ccusage-based ClaudeProvider initializer) merged past each other, so
main's CI is red: the test still passed the removed ccusageRunner:
argument. Construct the provider with the current initializer instead.

Co-authored-by: Cursor <cursoragent@cursor.com>
robinebers added a commit that referenced this pull request Jul 3, 2026
fix(tests): port #828's desktop-app test off the removed CcusageRunner
rohithgoud30 pushed a commit to rohithgoud30/openusage that referenced this pull request Jul 3, 2026
…usageRunner

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

claude broken

1 participant