Uh oh!
There was an error while loading. Please reload this page.
feat(console): hide the AI surface at runtime when the server serves no AI (Community Edition) - #1987
Merged
Merged
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
✅ Console Performance Budget
📦 Bundle Size Report
Size Limits
|
…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>os-zhuangforce-pushed
the
feat/ce-ai-runtime-gating
branch
from
June 24, 2026 17:54
f67872f to
7f04ab5CompareCo-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
❌ Console Performance Budget
📦 Bundle Size Report
Size Limits
|
Contributor
✅ Console Performance Budget
📦 Bundle Size Report
Size Limits
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The in-UI AI Q&A
askagent moved out of the open-source framework into the closed cloud package (@objectstack/service-ai-studio). A self-host Community Edition runtime = framework + this MIT console, without the cloud AI package → it serves noask/buildagent.The console is supposed to hide its AI UI via runtime server-capability gating, but several entry points rendered unconditionally, and direct navigation to
/aicould dead-end on an agent-less echo chat.Founder decision honored: runtime, server-pushed gating only — no
VITE_EDITIONbuild flag, no tree-shake, no relicensing. The AI code stays MIT.Gate on the agent catalog, not discovery (the key correctness point)
The
ask/buildagent personas moved to cloudservice-ai-studio, but the open-source framework keeps a headless@objectstack/service-aithat stillregisterService('ai')s. So a CE runtime reportsservices.aias available in discovery while the agent catalog is empty.Verified live against a fresh framework backend:
Gating on
isAiEnabled(discovery) would leave the FAB / "Ask AI" affordances visible with nothing to talk to — a dead end. So every AI entry point now gates on a non-empty agent catalog (GET /api/v1/ai/agents) — the real "is there an agent to answer?" signal, and exactly what the Home CTAs already used.What changed
isAiEnabled(discovery), duplicated in 2 layoutsuseAiSurfaceEnabled()(agent catalog)/ai*routesRequireAiSurfaceguard → redirect to/homewhen no agentautoResponse)New shared primitives
useAiSurfaceEnabled()(+resolveAiApiBase()) — single source of truth, driven by the agent catalog; handles the "fetch not started yet" frame so the route guard doesn't flash a redirect. De-dupes the FAB checks and HomePage's API-base resolver.RequireAiSurface— route guard, exported from app-shell alongsideRequireOrganization/SystemRedirect.Verification
Live, against a real framework runtime (browser):
/ai/ask→ redirects to/home(no chat, no echo). This is the exact caseisAiEnabled-gating would have failed.showcase_assistant): FAB shown, top-bar AI link shown,/ai→ real chat (/ai/showcase_assistant/conv_…), not the unavailable state.Build & tests: app-shell
tscclean; console fulltsc && vite buildclean; full app-shell suite green (872 passing), incl. new tests:useAiSurface.test.ts— catalog → enabled/loading mapping, incl. the not-yet-fetched latch and resolved-empty → redirect.RequireAiSurface.test.tsx— renders when agents served, redirects to home when none, waits while the catalog resolves.ObjectFormCanvas.test.tsx— both "Ask AI" buttons hide when no agent; still work when present.🤖 Generated with Claude Code