Personal Case.dev key takes priority over shared demo key

The CaseMark fork's demo mode previously gave the shared demo key unconditional priority, making it impossible for users to save their own Case.dev key within Demo Mode. kveton inverted that logic so the personal key wins when present, with the shared demo key as fallback.

multi-tenantinfrastructure

The fix is a two-line swap in getEffectiveCaseApiKey(). The old resolution order was: check for demo key, return early if found, check user key if not. The new order checks the user key first. Because the demo key check was also happening before the user key lookup in getCaseCredentialStatus(), that logic was reorganized to match.

Two error guards were removed from saveCaseApiKey() and clearCaseApiKey(). Both previously threw "Demo mode uses the shared Case.dev demo key" when called in demo mode. Removing these guards lets users save or clear a personal key normally in demo mode, with clear reverting to the shared demo key as expected.

The Account > Models page was updated to reflect the new model: a banner explains the demo key is the default, and a standard ApiKeyField is now rendered alongside the banner rather than replacing it when demo mode is active. Anthropic and Gemini direct-provider BYOK fields remain disabled in the hosted demo UI - this PR is narrowly about the Case.dev path.

kveton verified against the production API endpoint: a fresh user shows source: "demo" and the live Case model catalog, confirming the change works end-to-end before merging.

So what Relevant if you're running a hosted demo with a shared API key and want users to be able to opt into their own credentials without disabling demo mode for everyone. The two-line resolution order change is the portable piece; the UI changes are opinionated to this fork's Account > Models layout.

View this fork on GitHub →

Spotted something wrong? Or know the PR text has fresher detail than the writeup above?

Commits in this thread

1 commit from CaseMark/mikeoss-casedotdev, oldest first. Source extracted verbatim from the harvested git log.

SHA Subject Author Date
4a979679 Allow Case key override in demo mode kveton 2026-05-04 ↗ GitHub

Capture this thread into my fork

Download a single Markdown prompt that tells Claude how to port every commit above into your working tree — adapting paths and structure to match your repo. Run it via claude -p < capture-thread-286.md from inside the repo you want the changes in.

⬇ Download capture-thread-286.md