-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Fix Claude source mode fallback on successful CLI login (#2403) #2414
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 5 commits
987f6d6
eaf2a3e
b681186
0a152d9
c526a05
d0d9b6d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,6 +33,9 @@ extension StatusItemController { | |
| if case .success = result.outcome { | ||
| let metadata = self.store.metadata(for: .claude) | ||
| self.settings.setProviderEnabled(provider: .claude, metadata: metadata, enabled: true) | ||
| if self.settings.claudeUsageDataSource == .web { | ||
| self.settings.claudeUsageDataSource = .oauth | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When “Disable Keychain access” or the no-prompt OAuth policy is enabled, Useful? React with 👍 / 👎. |
||
| } | ||
| self.postLoginNotification(for: .claude) | ||
| return true | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,23 +25,30 @@ struct ClaudeLoginFlowTests { | |
| browserDetection: BrowserDetection(cacheTTL: 0), | ||
| settings: settings) | ||
|
|
||
| await withStatusItemControllerForTesting(store: store, settings: settings, fetcher: fetcher) { controller in | ||
| let didLogin = await controller.runClaudeLoginFlow { _, onPhaseChange in | ||
| onPhaseChange(.requesting) | ||
| await Task.yield() | ||
| onPhaseChange(.waitingBrowser) | ||
| await Task.yield() | ||
| return ClaudeLoginRunner.Result( | ||
| outcome: .success, | ||
| output: "Successfully logged in", | ||
| authLink: nil) | ||
| } | ||
| let controller = StatusItemController( | ||
| store: store, | ||
| settings: settings, | ||
| account: fetcher.loadAccountInfo(), | ||
| updater: DisabledUpdaterController(), | ||
| preferencesSelection: PreferencesSelection(), | ||
| statusBar: .system) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
On macOS test runs, this now constructs a controller against AGENTS.md reference: AGENTS.md:L27-L27 Useful? React with 👍 / 👎. |
||
|
|
||
| #expect(didLogin) | ||
| #expect(controller.loginPhase == .idle) | ||
| let didLogin = await controller.runClaudeLoginFlow { _, onPhaseChange in | ||
| onPhaseChange(.requesting) | ||
| await Task.yield() | ||
| onPhaseChange(.waitingBrowser) | ||
| await Task.yield() | ||
| return ClaudeLoginRunner.Result( | ||
| outcome: .success, | ||
| output: "Successfully logged in", | ||
| authLink: nil) | ||
| } | ||
|
|
||
| #expect(settings.claudeUsageDataSource == source) | ||
| #expect(didLogin) | ||
| #expect(controller.loginPhase == .idle) | ||
|
|
||
| let expectedSource: ClaudeUsageDataSource = (source == .web) ? .oauth : source | ||
| #expect(settings.claudeUsageDataSource == expectedSource) | ||
| #expect(settings.isProviderEnabledCached(provider: .claude, metadataByProvider: registry.metadata)) | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When Claude is disabled—the setup used by both login-flow tests and a normal sign-in onboarding path—replacing the unconditional
setProviderEnabled(..., enabled: true)call with this source-only update leavesProviderConfig.enabledfalse. ChangingclaudeUsageDataSourcedoes not alter enablement, so the flow reports success and posts a notification while Claude remains hidden and is not refreshed; the newisProviderEnabledCachedassertions consequently fail. Restore provider enablement independently of the selected source.Useful? React with 👍 / 👎.