Skip to content

[Extensibility 2/4] feat: keyless demo mode — a real first-run answer instead of a 401 (stacked on #259) - #260

Draft
amal66 wants to merge 2 commits into
Open-Legal-Products:mainfrom
amal66:olp-pr/demo-mode
Draft

[Extensibility 2/4] feat: keyless demo mode — a real first-run answer instead of a 401 (stacked on #259)#260
amal66 wants to merge 2 commits into
Open-Legal-Products:mainfrom
amal66:olp-pr/demo-mode

Conversation

@amal66

@amal66 amal66 commented Jul 26, 2026

Copy link
Copy Markdown
Collaborator

Stacked on #259 — merge that first; until it merges, this diff shows its commit too. This PR's own change is the single keyless demo mode commit.

Summary

A brand-new instance answers its first question with a canned, clearly-labelled, context-aware reply — plus a nudge toward Settings → API Keys — instead of a raw provider 401. First-run users and zero-setup demos work with no API keys at all, entirely offline.

Changes

Backend: providers/demo.ts (new, registered via the registry), DEMO_MODEL = "mike-demo", and resolveDemoFallback() in routes/chat.ts — a request for a keyless provider runs on the demo model instead of failing.

Frontend: "Demo (no key needed)" entry in the model picker; ChatInput falls back to demo instead of the blocking key popup; dismissible ApiKeyBanner shown while no provider key is configured.

Why

Today a fresh install hits a hard error on the very first message. This is the single highest-friction moment for new users and demos; after this PR the first message always answers, labelled as demo output, and documents never leave the workspace until a real key is added.

Testing

On this branch: backend npm test 279 passed; frontend npm test 38 passed, eslint 0 errors, next build clean.

Provenance

Mechanical port of the demo mode running in amal66/mike (main), including its keyless-fallback fixes. Full provenance in amal66#28.

🤖 Generated with Claude Code

amal66 and others added 2 commits July 26, 2026 07:20
Replace the per-provider if/else chains in lib/llm/index.ts and the
env-var switch in lib/userApiKeys.ts with a provider registry
(lib/llm/registry.ts) and an API-key provider table
(core/apiKeyProviders.ts). Adding a provider is now a
registerProvider()/registerApiKeyProvider() call — no edits to
index.ts, models.ts, or userApiKeys.ts required.

Ported from the amal66/mike monorepo fork (origin/main, b3166dd);
mechanical translation into the backend/ layout.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CEguyEgXa9JjCciXCcVemC
Add a built-in keyless "demo" provider (lib/llm/providers/demo.ts,
DEMO_MODEL = "mike-demo") that answers with a canned, context-aware
placeholder plus a nudge to configure a key. The chat stream route
falls back to it automatically when the chosen model's provider has
no env or per-user key (resolveDemoFallback in routes/chat.ts).

Frontend: "Demo (no key needed)" entry in the model dropdown, silent
demo fallback on send in ChatInput (replaces the blocking
ApiKeyMissingPopup), and a dismissible global ApiKeyBanner while no
provider key is configured.

Ported from the amal66/mike monorepo fork (origin/main, b3166dd);
mechanical translation into the backend/ + frontend/ layout.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CEguyEgXa9JjCciXCcVemC
@amal66
amal66 force-pushed the olp-pr/demo-mode branch from 2105f77 to 5935c89 Compare July 26, 2026 14:33
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