fix(client): stop local dev from crashing on missing account record / failed billing queries
What
Two local-dev resilience fixes so the inspector boots and stays up even when the signed-in identity has no backing account record (the situation against an employee-locked non-prod backend, where ensureUser is rejected and no users/org row exists):
-
UserSetupError no longer blocks local dev.
#1979made the app require a backing account record before rendering, showing a full-screen "Could not finish setup" error whenevercurrentUser === null. That fired in local dev too. It's now gated behindHOSTED_MODEvia a small pure helper (shouldShowUserSetupError), mirroringresolveHostedShellGateState. Hosted/cloud still requires the record (it backs orgs/projects/billing); local dev renders regardless. DownstreamcurrentUserreads are already null-safe. -
Sidebar credit widget no longer crashes the app. The credit-usage strip sits in the always-rendered sidebar and calls
billing:getCreditBalance. ConvexuseQueryre-throws query errors during render, so a failed balance query (e.g. "organizationId is required for signed-in credit balance" when there's no org) bubbled to the route error boundary and took down the whole page. It's now wrapped in<ErrorBoundary fallback={null}>, matching the pattern already used around the billing-page credit widgets — a failed billing query now just hides the strip.
Why
Before #1979 the app started up regardless of the account record. The new gate, plus the credit query throwing on render, turned a missing/locked-out account into a full-app crash in local dev. These changes restore graceful startup without weakening hosted behavior.
Scope / non-goals
Purely crash-resilience. Making guest sessions / LLM / evals work locally is out of scope — that's gated by the backend lockdown, not the inspector.
Testing
client/src/lib/__tests__/user-setup-gate.test.ts— 5 tests (hosted vs local gating).client/src/components/sidebar/__tests__/sidebar-credit-usage.test.tsx— added a regression test that mounts the widget with a throwing balance query and asserts it renders nothing instead of crashing (9 tests total).npm run buildpasses.
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. Credits must be used to enable repository wide code reviews.
:white_check_mark: Snyk checks have passed. No issues have been found so far.
| Status | Scan Engine | Total (0) | ||||
|---|---|---|---|---|---|---|
| :white_check_mark: | Open Source Security | 0 | 0 | 0 | 0 | 0 issues |
:computer: Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 68e4a355-1851-4778-af50-24fa4c446344
📥 Commits
Reviewing files that changed from the base of the PR and between 05b9dad22c5e2843d3cc024e03dae79cf8eff3e3 and 10b70b92d35bb98207470d80d36b86f28adaf7a1.
📒 Files selected for processing (3)
mcpjam-inspector/client/src/App.tsxmcpjam-inspector/client/src/components/sidebar/__tests__/sidebar-credit-usage.test.tsxmcpjam-inspector/client/src/components/sidebar/sidebar-credit-usage.tsx
💤 Files with no reviewable changes (2)
- mcpjam-inspector/client/src/components/sidebar/tests/sidebar-credit-usage.test.tsx
- mcpjam-inspector/client/src/components/sidebar/sidebar-credit-usage.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
- mcpjam-inspector/client/src/App.tsx
Walkthrough
This PR extracts user-setup error gating logic into a reusable shouldShowUserSetupError helper and adds error boundary protection to the sidebar credit widget. The user-setup helper consolidates the condition for showing a full-screen setup error (hosted mode + authenticated user + missing record) into a testable function imported by App.tsx. In parallel, the sidebar credit usage component is wrapped in an ErrorBoundary to prevent balance-query failures from crashing the entire application; the widget simply renders nothing if the query throws.
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 @coderabbitai help to get the list of available commands and usage tips.