Skip to content

fix: improve onboarding for macOS — bun PATH detection + provider auto-activation#240

Open
lairulan wants to merge 2 commits intoop7418:mainfrom
lairulan:fix/onboarding-bugs
Open

fix: improve onboarding for macOS — bun PATH detection + provider auto-activation#240
lairulan wants to merge 2 commits intoop7418:mainfrom
lairulan:fix/onboarding-bugs

Conversation

@lairulan
Copy link

Problem

Three related issues that silently break the initial setup experience on macOS, especially for users who install Claude CLI via bun:

1. Claude CLI not detected when installed via bun (macOS)

macOS GUI apps (Electron) do not inherit the user's shell PATH from .zshrc / .bash_profile. The PATH expansion helpers (getExpandedShellPath in electron/main.ts and getExtraPathDirs / getClaudeCandidatePaths in src/lib/platform.ts) did not include ~/.bun/bin, so users who install claude via bun install -g @anthropic-ai/claude-code would always get "Claude CLI not found", even though it was correctly installed.

2. New API provider created with is_active = 0

createProvider() in src/lib/db.ts hard-coded is_active = 0 for every INSERT. Users who complete the setup wizard and add their first provider end up with a silently inactive provider — all subsequent calls fail with a cryptic error despite a successful-looking configuration flow. Additionally, there was no logic to deactivate existing providers before inserting the new one, which could leave multiple active providers in an inconsistent state.

3. Unhelpful error message for "exited with code 1"

The error message shown when Claude CLI exits with code 1 listed several possible causes but omitted the inactive-provider scenario introduced by bug #2, making it hard for users to self-diagnose.


Changes

File Change
electron/main.ts Add ~/.bun/bin to getExpandedShellPath()
src/lib/platform.ts Add ~/.bun/bin to getExtraPathDirs(); add ~/.bun/bin/claude to getClaudeCandidatePaths()
src/lib/db.ts createProvider(): deactivate all existing providers before INSERT; set is_active = 1 for the new provider
src/lib/claude-client.ts Add provider-activation hint to the "exited with code 1" error message

Testing

  • Verified on macOS (Apple Silicon) with claude installed via bun install -g
  • Confirmed new provider is immediately active after creation without requiring a manual toggle
  • Error message now surfaces the inactive-provider cause alongside the existing hints

- electron/main.ts: add ~/.bun/bin to getExpandedShellPath() so Claude
  CLI installed via bun is detectable in the Electron GUI context (macOS
  GUI apps do not inherit shell PATH from .zshrc/.bash_profile)

- src/lib/platform.ts: add ~/.bun/bin to getExtraPathDirs() and
  ~/.bun/bin/claude to getClaudeCandidatePaths() for consistent PATH
  expansion on both renderer and main process sides

- src/lib/db.ts (createProvider): set is_active=1 when inserting a new
  provider and deactivate all existing providers first, so the newly
  created provider is immediately usable without a manual toggle

- src/lib/claude-client.ts: add provider-activation hint to the
  "exited with code 1" error message, helping users diagnose the silent
  failure caused by an inactive provider
@vercel
Copy link

vercel bot commented Mar 11, 2026

@lairulan is attempting to deploy a commit to the op7418's projects Team on Vercel.

A member of the Team first needs to authorize it.

Replace the blanket "deactivate all then activate new" logic in
createProvider() with a more conservative approach:

- If no active provider exists (e.g. first-time onboarding), the new
  provider is inserted with is_active = 1 so it works immediately
- If an active provider already exists, the new provider is inserted
  with is_active = 0, leaving the existing selection untouched

This avoids silently deactivating a provider the user is already using
when they add a second/backup provider via Settings.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant