Use the chat organization for Claude Web
Summary
Claude.ai (Web) fails with s.map is not a function for accounts linked to the Anthropic Console. /api/organizations lists the API-only organization first (capabilities ["api", "customer_terms:standard"]), and Claude.init() always took organizations[0]. claude.ai answers chat_conversations for that organization with a permission_error object instead of a list:
Claude.init()
getOrganizations()
- organizationId = organizations[0].uuid
+ organizationId = first organization whose capabilities include "chat"
+ ?? organizations[0]
getConversations()
- json.map(...) // json = { type: "error", error: { type: "permission_error" } } → TypeError
+ if json is not an array → throw Error(json.error.message)
+ json.map(...)
The client's fetch-sse import also gets its .mjs extension so the module loads under the Node test runner. Webpack resolves both forms the same way.
Evidence
-
Before: the new tests run against the old
init():✖ Claude init prefers the organization with chat capability Error: unexpected request /api/organizations/api-org/chat_conversations ✖ Claude init reports the claude.ai error when conversations are denied actual: TypeError: json.map is not a functionIn the extension, every Claude.ai (Web) question ends with the error
s.map is not a function.After:
✔ Claude init prefers the organization with chat capability ✔ Claude init falls back to the first organization without chat capability ✔ Claude init reports the claude.ai error when conversations are deniedClaude.ai (Web) answers normally again in Firefox for the affected account.
Validation: npm test (1110 pass), npm run lint, npm run pretty:check and npm run build are clean. Manually tested in Firefox with an affected account, using a build that also carried #996; the Claude client code is identical to this PR. Not manually tested in Chromium.
Merge Danger
Door: two-way
Blast Radius: Claude Web only
Accounts with a single organization, or whose first organization already has chat, keep the organization they used before. If claude.ai stops reporting chat in capabilities, the client falls back to the old organizations[0] behavior.
🤖 Generated with Claude Code
Summary by CodeRabbit
- Bug Fixes
- Claude now selects an organization with chat access when available, helping ensure chat features work with the appropriate account.
- Conversation-loading failures now show the error message provided by the service, or a fallback message when none is available.