Skip to content

feat: gate console chatbot FAB on discovery.services.ai availability#1173

Merged
hotlong merged 3 commits intomainfrom
copilot/console-chatbot-render-when-ai-available
Apr 2, 2026
Merged

feat: gate console chatbot FAB on discovery.services.ai availability#1173
hotlong merged 3 commits intomainfrom
copilot/console-chatbot-render-when-ai-available

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 2, 2026

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.enabled and services.ai.route.

Changes

  • DiscoveryInfo interface — added ai to services with enabled, status, route fields
  • useDiscovery() hook — added isAiEnabled derived property, true only when ai.enabled === true && ai.status === 'available', defaults false
  • ConsoleLayout — chatbot FAB now conditionally renders on isAiEnabled
  • Tests — 5 new cases covering all isAiEnabled edge cases (enabled+available, enabled+unavailable, disabled, no status, no discovery)

Usage

const { isAiEnabled, discovery } = useDiscovery();

// Render AI-dependent UI only when service is live
{isAiEnabled && <FloatingChatbot />}

// Access route for API calls
const aiRoute = discovery?.services?.ai?.route; // e.g. '/api/v1/ai'

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 2, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
objectui-demo Ready Ready Preview, Comment Apr 2, 2026 3:31am
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
objectui Ignored Ignored Apr 2, 2026 3:31am

Request Review

…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>
Copilot AI changed the title [WIP] Render chatbot only when AI service is available feat: gate console chatbot FAB on discovery.services.ai availability Apr 2, 2026
Copilot AI requested a review from xuyushun441-sys April 2, 2026 03:32
@hotlong hotlong marked this pull request as ready for review April 2, 2026 03:42
Copilot AI review requested due to automatic review settings April 2, 2026 03:42
@hotlong hotlong merged commit 8d603e9 into main Apr 2, 2026
3 checks passed
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.services to include an optional ai service (enabled, status, route).
  • Add isAiEnabled convenience boolean to useDiscovery() (true only when enabled === true and status === 'available').
  • Gate ConsoleLayout FAB rendering on isAiEnabled, 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.

Comment on lines 99 to 101
const appLabel = resolveI18nLabel(activeApp?.label) || activeAppName;
const { isAiEnabled } = useDiscovery();

Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
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.

Console Chatbot 仅在检测到 AI 服务可用时渲染:基于 discovery.services.ai 动态控制

4 participants