Skip to content

fix(auth): clearer import-brave error + add to README/skill docs#91

Merged
AmethystLiang merged 2 commits into
stablyai:mainfrom
jprichardson:fix/import-brave-applescript-error
May 30, 2026
Merged

fix(auth): clearer import-brave error + add to README/skill docs#91
AmethystLiang merged 2 commits into
stablyai:mainfrom
jprichardson:fix/import-brave-applescript-error

Conversation

@jprichardson

Copy link
Copy Markdown
Contributor

Summary

  • import-brave silently failed on first run because extractFromBrave() wrapped its body in try { ... } catch { return null }, hiding the specific "Allow JavaScript from Apple Events is turned off" failure behind a generic "ensure you're logged in" message.
  • That toggle ships OFF in Brave (and every Chromium browser), so the very first agent-slack auth import-brave consistently looks like an auth problem instead of a one-time browser setting.
  • Adds import-brave to README + skill docs, where it was previously undocumented despite being wired into the auto-detection fallback chain (src/cli/context-client-resolver.ts:138).

What changed

  • src/auth/brave.ts: detect the AppleScript-disabled error in osascript() and throw a typed BraveAppleScriptDisabledError with an actionable message (menu path + re-run hint). Other failure modes keep the existing null-return behavior, so the generic "ensure you're logged in" message still applies when no Slack tab is open or cookie decryption fails.
  • src/cli/auth-command.ts: import-brave's description and fallback throw new Error message both reference the View → Developer → Allow JavaScript from Apple Events requirement.
  • README.md: list import-brave in the command tree and manual-imports block; add a NOTE block explaining the AppleScript-JS prereq applies to both import-brave and import-chrome.
  • skills/agent-slack/SKILL.md: add a Brave fallback section and update the intro to Brave/Chrome/Firefox (Brave is already in the auto-fallback chain).
  • skills/agent-slack/references/commands.md: add import-brave to the auth command list with the AppleScript prereq inline.

Notes

src/auth/chrome.ts has the same bug pattern (identical try { ... } catch { return null } wrapping + identical execute t javascript AppleScript path). Out of scope for this PR — happy to send a follow-up.

Test plan

  • bun run typecheck clean
  • bun run test — 198/198 pass
  • bun run format:check clean
  • agent-slack auth import-brave happy path: still imports tokens (2 workspaces in my case)
  • Manually reproduced AppleScript-disabled failure (View → Developer → Allow JavaScript from Apple Events OFF) and confirmed osascript() reports the exact marker string that the new detection relies on
  • CI

🤖 Generated with Claude Code

extractFromBrave() wrapped its body in `try { ... } catch { return null }`,
which swallowed the specific "Allow JavaScript from Apple Events is turned
off" failure behind a generic "ensure you're logged in" message. That toggle
is OFF by default in Brave, so first-run import-brave consistently looked
like an auth problem instead of a one-time browser setting.

- Detect the AppleScript-disabled error in osascript() and throw a typed
  BraveAppleScriptDisabledError with an actionable message (menu path +
  re-run hint). Other failure modes keep the existing null-return behavior.
- import-brave's command description and fallback error now both reference
  the View -> Developer -> Allow JavaScript from Apple Events requirement.
- README: list import-brave in the command tree and manual-imports block,
  plus a NOTE explaining the Chromium AppleScript-JS prereq for
  import-brave / import-chrome.
- Skill docs: add import-brave to SKILL.md (fallback section) and
  references/commands.md (auth command list). SKILL.md's fallback intro
  updated to "Brave/Chrome/Firefox" since Brave is in the auto-detection
  chain (context-client-resolver.ts).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@jprichardson

Copy link
Copy Markdown
Contributor Author

@AmethystLiang do you need to see any changes in this PR?

@AmethystLiang

Copy link
Copy Markdown
Contributor

@jprichardson sorry about the delay. reviewing it now

@AmethystLiang AmethystLiang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the clear fix and docs update. I pushed a small follow-up so Brave’s AppleScript setup error stays actionable for explicit import-brave, but does not block automatic fallback to Firefox. This looks good to merge.

@AmethystLiang AmethystLiang merged commit a7a4b1b into stablyai:main May 30, 2026
1 check passed
@AmethystLiang

Copy link
Copy Markdown
Contributor

Thanks JP. This was a useful fix, and the README/skill docs update was the right place to document the Brave setup requirement. I added one small follow-up before merging so automatic auth discovery still skips over Brave and continues to Firefox when that browser setting is disabled.

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.

2 participants