Commit b0a0a4a
committed
fix(desktop): split Claude Code import into OAuth / API-key / proxy branches
Users who logged into Claude Code via OAuth (Pro/Max subscription) hit a
silent death path: clicking "Import from Claude Code" would set
activeProvider to claude-code-imported but store no key, so toState()
returned hasKey:false — yet the UI was already past onboarding and
surfaced the generic "Onboarding is not complete" when the user tried
to generate.
Root causes:
1. parseClaudeCodeSettings only looked at settings.json env block,
never at process.env or OAuth-evidence filesystem hints.
2. runImportClaudeCode unconditionally flipped activeProvider to the
imported id even when no key was available.
3. No branching for the three practical Claude Code user types
(OAuth subscription / API key / local proxy) — one banner, one
import path, one outcome.
Changes:
- packages/shared/src/error-codes.ts
New codes: CLAUDE_CODE_OAUTH_ONLY, PROVIDER_ACTIVE_MISSING_KEY.
- apps/desktop/src/main/imports/claude-code-config.ts
Rewrite parser around a ClaudeCodeUserType classification:
has-api-key | oauth-only | local-proxy | remote-gateway | no-config
Falls back to process.env ANTHROPIC_{AUTH_TOKEN,API_KEY} when
settings.json env block is empty. Adds checkClaudeCodeOAuthEvidence()
(filesystem-only probe for ~/.claude/.credentials.json or
~/Library/Application Support/Claude/). Provider entry now always
carries envKey: 'ANTHROPIC_AUTH_TOKEN' for runtime fallback.
- apps/desktop/src/main/onboarding-ipc.ts
getApiKeyForProvider: if secret missing but entry.envKey is set,
resolve from process.env before throwing. Rescues shell-env users who
launch from terminal.
runImportClaudeCode: oauth-only → throw CLAUDE_CODE_OAUTH_ONLY without
touching config. no-key + non-oauth → create entry but preserve the
existing activeProvider. This kills the death path.
detect-external-configs: return richer meta (userType, baseUrl,
hasApiKey, apiKeySource) so the renderer can render three banners.
- apps/desktop/src/renderer/src/components/Settings.tsx
Branch the claudeCode banner on userType:
oauth-only → OAuthSubscriptionBanner with Console link + local
proxy CTA + dismiss
has-api-key → green import banner with source/baseUrl
local-proxy → neutral banner explaining proxy setup
remote-gateway → neutral banner, "Import (needs key)" action
handleImportClaudeCode catches CLAUDE_CODE_OAUTH_ONLY and shows the
info-tone toast instead of the generic "import failed" error.
- apps/desktop/src/renderer/src/store.ts
Replace the generic "Onboarding is not complete" with a specific
"provider X has no key, open Settings" message when config.provider
is set but hasKey:false.
- packages/i18n/src/locales/{en,zh-CN}.json
New strings for the three banner variants, the OAuth CTAs, and the
providerMissingKey error.
Tests:
- 12 new parseClaudeCodeSettings cases covering every userType.
- runImportClaudeCode tests for oauth-only throw, local-proxy no-activate,
has-api-key activate.
- getApiKeyForProvider envKey fallback tests.
- Full suite: 414 desktop tests, all passing.1 parent f9f78fd commit b0a0a4a
10 files changed
Lines changed: 741 additions & 58 deletions
File tree
- apps/desktop/src
- main
- imports
- preload
- renderer/src
- components
- packages
- i18n/src/locales
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
| 20 | + | |
19 | 21 | | |
20 | 22 | | |
21 | | - | |
| 23 | + | |
22 | 24 | | |
23 | | - | |
| 25 | + | |
24 | 26 | | |
| 27 | + | |
| 28 | + | |
25 | 29 | | |
26 | 30 | | |
27 | | - | |
| 31 | + | |
28 | 32 | | |
29 | | - | |
30 | | - | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
31 | 82 | | |
32 | | - | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
33 | 90 | | |
34 | 91 | | |
35 | 92 | | |
36 | | - | |
| 93 | + | |
37 | 94 | | |
38 | 95 | | |
39 | 96 | | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
40 | 102 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
10 | 32 | | |
11 | 33 | | |
12 | | - | |
13 | | - | |
14 | 34 | | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
15 | 38 | | |
16 | 39 | | |
17 | 40 | | |
18 | 41 | | |
19 | 42 | | |
20 | 43 | | |
| 44 | + | |
21 | 45 | | |
22 | 46 | | |
23 | | - | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
24 | 86 | | |
| 87 | + | |
25 | 88 | | |
26 | 89 | | |
27 | 90 | | |
| |||
30 | 93 | | |
31 | 94 | | |
32 | 95 | | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
33 | 99 | | |
34 | 100 | | |
35 | 101 | | |
| |||
38 | 104 | | |
39 | 105 | | |
40 | 106 | | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
41 | 110 | | |
42 | 111 | | |
43 | 112 | | |
44 | 113 | | |
45 | 114 | | |
46 | 115 | | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
51 | 173 | | |
52 | 174 | | |
53 | 175 | | |
| |||
56 | 178 | | |
57 | 179 | | |
58 | 180 | | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
59 | 186 | | |
60 | 187 | | |
61 | 188 | | |
62 | 189 | | |
63 | 190 | | |
64 | 191 | | |
65 | 192 | | |
66 | | - | |
| 193 | + | |
67 | 194 | | |
68 | | - | |
| 195 | + | |
| 196 | + | |
69 | 197 | | |
70 | 198 | | |
71 | 199 | | |
72 | | - | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
73 | 233 | | |
74 | 234 | | |
75 | 235 | | |
76 | 236 | | |
77 | 237 | | |
78 | 238 | | |
| 239 | + | |
| 240 | + | |
79 | 241 | | |
80 | 242 | | |
81 | 243 | | |
82 | 244 | | |
83 | | - | |
84 | | - | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
85 | 259 | | |
86 | | - | |
| 260 | + | |
87 | 261 | | |
0 commit comments