You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(console): hide the AI surface at runtime when the server serves no AI (Community Edition) (#1987)
* feat(console): hide the AI surface at runtime when the server serves no AI agent (Community Edition)
A self-host Community Edition runtime (framework + this MIT console, WITHOUT
the closed `@objectstack/service-ai-studio` package) serves no `ask`/`build`
agent. The console must hide its AI UI via runtime, server-pushed gating — no
build-time edition flag, no tree-shake, no relicensing; the AI code stays MIT.
Several entry points rendered unconditionally and `/ai` could dead-end on an
agent-less echo chat. This completes the gating.
Key correctness point — gate on the AGENT CATALOG, not discovery:
the `ask`/`build` agent personas moved to the cloud-only service-ai-studio, but
the open-source framework keeps a HEADLESS `@objectstack/service-ai` that still
`registerService('ai')`s. So a CE runtime reports `services.ai` as available in
`/api/v1/discovery` (verified live: enabled=true, status=available) while the
agent catalog is empty. Gating on `isAiEnabled` would leave the FAB / "Ask AI"
visible with nothing to talk to. `GET /api/v1/ai/agents` (non-empty) is the real
"is there an agent to answer?" signal — and what the Home CTAs already use.
- Add `useAiSurfaceEnabled()` — one source of truth, driven by the agent
catalog (`useAgents`). Handles the "fetch not started yet" frame so route
guards don't flash a redirect. Replaces the duplicated FAB checks.
- Add `RequireAiSurface` route guard; wrap the `/ai*` routes in App.tsx. When no
agent is served it redirects to /home (waits for the catalog first). Cloud
installs pass straight through.
- Gate the top-bar AI link (AppHeader) and the two designer "Ask AI" buttons
(ObjectFormCanvas) on the same signal.
- AiChatPage: render a graceful "AI unavailable" state (Back-to-home + Retry on
error) when the catalog resolves empty, instead of the autoResponse echo chat.
- ConsoleLayout / HomeLayout FAB now use the shared signal; HomePage reuses the
shared `resolveAiApiBase`.
Verified live against a real framework runtime: with services.ai reporting
AVAILABLE but an empty agent catalog, the FAB, top-bar link and Home CTAs are
all hidden and /ai redirects to home; with an agent served, the FAB shows and
/ai loads the real chat. Plus unit tests for the catalog signal (incl. the
not-yet-fetched latch), the guard redirect, and the designer-button hiding.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* chore: add changeset for CE AI runtime gating
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
0 commit comments