feat: gate console chatbot FAB on discovery.services.ai availability#1173
feat: gate console chatbot FAB on discovery.services.ai availability#1173
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…s.ai availability - Add `ai` service type to `DiscoveryInfo.services` interface with enabled, status, route fields - Add `isAiEnabled` convenience property to `useDiscovery()` hook (true only when ai.enabled && ai.status === 'available') - Conditionally render `ConsoleFloatingChatbot` in `ConsoleLayout` based on `isAiEnabled` - Add 5 new tests for isAiEnabled covering all edge cases - Update CHANGELOG.md and README.md Agent-Logs-Url: https://github.com/objectstack-ai/objectui/sessions/14bca4e2-4027-410b-bc6a-5ef0dc86a4fa Co-authored-by: xuyushun441-sys <255036401+xuyushun441-sys@users.noreply.github.com>
Agent-Logs-Url: https://github.com/objectstack-ai/objectui/sessions/14bca4e2-4027-410b-bc6a-5ef0dc86a4fa Co-authored-by: xuyushun441-sys <255036401+xuyushun441-sys@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR updates the console to only show the floating chatbot FAB when the backend’s discovery endpoint reports the AI service as enabled and available, aligning console behavior with the new discovery.services.ai contract from the spec.
Changes:
- Extend
DiscoveryInfo.servicesto include an optionalaiservice (enabled,status,route). - Add
isAiEnabledconvenience boolean touseDiscovery()(true only whenenabled === trueandstatus === 'available'). - Gate
ConsoleLayoutFAB rendering onisAiEnabled, plus add unit tests and update docs/changelog.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/react/src/hooks/useDiscovery.ts | Adds services.ai typing and derives isAiEnabled from discovery data. |
| packages/react/src/hooks/tests/useDiscovery.test.tsx | Adds test cases for isAiEnabled edge conditions. |
| packages/react/README.md | Documents isAiEnabled and mentions services.ai in discovery. |
| CHANGELOG.md | Records the addition of AI discovery fields and conditional FAB rendering. |
| apps/console/src/components/ConsoleLayout.tsx | Conditionally renders the global floating chatbot based on discovery AI availability. |
| const appLabel = resolveI18nLabel(activeApp?.label) || activeAppName; | ||
| const { isAiEnabled } = useDiscovery(); | ||
|
|
There was a problem hiding this comment.
useDiscovery() reads from SchemaRendererContext, but ConsoleLayout is rendered outside the SchemaRendererProvider in App.tsx (the provider is nested inside ConsoleLayout). As a result, useDiscovery() will always see dataSource as undefined here, so isAiEnabled will always be false and the chatbot FAB will never render even when AI is available. Consider moving SchemaRendererProvider to wrap ConsoleLayout, or pass the console dataSource into ConsoleLayout (and/or add a useDiscovery(dataSource) overload) so discovery can be fetched in this component.
The console floating chatbot rendered unconditionally, even when the server has no AI plugin installed. Per objectstack-ai/spec#1029, the discovery endpoint now exposes
services.ai.enabledandservices.ai.route.Changes
DiscoveryInfointerface — addedaitoserviceswithenabled,status,routefieldsuseDiscovery()hook — addedisAiEnabledderived property,trueonly whenai.enabled === true && ai.status === 'available', defaultsfalseConsoleLayout— chatbot FAB now conditionally renders onisAiEnabledisAiEnablededge cases (enabled+available, enabled+unavailable, disabled, no status, no discovery)Usage