feat: permit disabling claude cli fallback#162
Conversation
The claude cli callback sometimes creates issues along the lines of ssh key prompts and the like. Sometimes, folks would just prefer to see the failure message. This enables folks to turn off the cli fallback.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughAdds a user-facing toggle and backing settings to disable Claude's CLI fallback when probeMode == .api, updates provider logic to respect the setting during availability checks and fallback selection, and adds persistence and tests for the new preference. Changes
Sequence Diagram(s)sequenceDiagram
actor User
participant UI as ClaudeConfigCard
participant Repo as SettingsRepository
participant Provider as ClaudeProvider
participant API as API Probe
participant CLI as CLI Probe
User->>UI: Toggle "CLI fallback" off
UI->>Repo: setClaudeCliFallbackEnabled(false)
Repo->>Repo: Persist setting
Note over User,CLI: Later: Quota refresh attempt
Provider->>Repo: claudeCliFallbackEnabled()
Repo-->>Provider: false
Provider->>API: check availability
API-->>Provider: unavailable (auth error)
Provider->>Provider: fallback disabled -> do not consult CLI
Provider-->>UI: set lastError, snapshot stays nil
rect rgba(255,100,100,0.5)
Note over CLI: CLI probe NOT consulted
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #162 +/- ##
==========================================
+ Coverage 80.06% 80.29% +0.23%
==========================================
Files 102 104 +2
Lines 7741 7847 +106
==========================================
+ Hits 6198 6301 +103
- Misses 1543 1546 +3
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Adds a user-facing setting to disable Claude’s CLI fallback while in API probe mode, preventing claude /usage from being invoked when API probing fails (addressing the SSH key prompt/usability issues described in #139).
Changes:
- Introduces a persisted
claudeCliFallbackEnabledsetting (defaulting totrue) across settings repositories. - Updates
ClaudeProviderto respect the setting by skipping CLI fallback in API mode when disabled. - Adds UI toggle (shown in API probe mode) plus unit/integration/acceptance tests for default + persistence + behavior.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| Tests/InfrastructureTests/UserDefaultsProviderSettingsRepositoryTests.swift | Verifies default value and persistence for the new UserDefaults-backed setting. |
| Tests/InfrastructureTests/Settings/JSONSettingsRepositoryProviderTests.swift | Verifies default value and persistence for the new JSON-backed setting. |
| Tests/DomainTests/Provider/Claude/ClaudeProviderTests.swift | Adds behavior tests for API mode availability with fallback enabled/disabled. |
| Tests/AcceptanceTests/ClaudeConfigSpec.swift | Ensures refresh in API mode does not fall back to CLI when the toggle is disabled. |
| Sources/Infrastructure/Storage/UserDefaultsProviderSettingsRepository.swift | Implements claudeCliFallbackEnabled storage + key. |
| Sources/Infrastructure/Storage/JSONSettingsRepository.swift | Implements claudeCliFallbackEnabled storage in JSON settings. |
| Sources/Domain/Provider/ProviderSettingsRepository.swift | Extends ClaudeSettingsRepository with CLI fallback enablement APIs. |
| Sources/Domain/Provider/Claude/ClaudeProvider.swift | Gates CLI fallback behavior in API mode based on the new setting. |
| Sources/App/Views/Settings/ClaudeConfigCard.swift | Adds the “CLI fallback” toggle UI under API probe mode. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| .toggleStyle(.switch) | ||
| .tint(theme.accentPrimary) | ||
| .onChange(of: claudeCliFallbackEnabled) { _, newValue in | ||
| settings.claude.setClaudeCliFallbackEnabled(newValue) |
There was a problem hiding this comment.
The “CLI fallback” toggle persists the setting but doesn’t trigger a refresh, so the UI may continue showing a snapshot fetched via the previous behavior until the next scheduled/manual refresh. Consider mirroring the probe-mode picker by refreshing monitor (or clearing the snapshot) when this toggle changes so the effect is immediately visible.
| settings.claude.setClaudeCliFallbackEnabled(newValue) | |
| settings.claude.setClaudeCliFallbackEnabled(newValue) | |
| Task { | |
| await monitor.refresh(providerId: "claude") | |
| } |
| /// Whether to fall back to the CLI probe when the OAuth API probe is unavailable. | ||
| /// Defaults to true. Disable to prevent `claude /usage` from running in API mode. | ||
| func claudeCliFallbackEnabled() -> Bool | ||
|
|
||
| /// Sets whether CLI fallback is enabled in API mode |
There was a problem hiding this comment.
The new doc comment says CLI fallback is used when the OAuth API probe is “unavailable”, but in ClaudeProvider.refresh() fallback can occur for any API probe error (e.g., authenticationRequired, network errors) as long as the CLI is available. Consider rewording to reflect that this setting controls fallback when the API probe fails or is unavailable, so the documentation matches runtime behavior.
| /// Whether to fall back to the CLI probe when the OAuth API probe is unavailable. | |
| /// Defaults to true. Disable to prevent `claude /usage` from running in API mode. | |
| func claudeCliFallbackEnabled() -> Bool | |
| /// Sets whether CLI fallback is enabled in API mode | |
| /// Whether to fall back to the CLI probe when the OAuth API probe fails or is unavailable. | |
| /// Defaults to true. Disable to prevent `claude /usage` from running as a fallback in API mode. | |
| func claudeCliFallbackEnabled() -> Bool | |
| /// Sets whether CLI fallback is enabled when the OAuth API probe fails or is unavailable. |
The claude cli callback sometimes creates issues along the lines of ssh key prompts and the like. Sometimes, folks would just prefer to see the failure message. This enables folks to turn off the cli fallback if users would prefer it to not happen as a usability issue.
closes #139
Summary by CodeRabbit