Skip to content

Commit 2fd36d6

Browse files
Copilothotlong
andcommitted
feat(console): integrate floating chatbot FAB into ConsoleLayout with metadata-aware context
Agent-Logs-Url: https://github.com/objectstack-ai/objectui/sessions/e0efdafc-aeb8-4dcc-859c-f5d6d07a2879 Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent b4fd455 commit 2fd36d6

File tree

2 files changed

+60
-1
lines changed

2 files changed

+60
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313

1414
- **New ChatbotSchema floating fields** (`@object-ui/types`): Extended `ChatbotSchema` with `displayMode` (`'inline' | 'floating'`) and `floatingConfig` (`FloatingChatbotConfig`) for schema-driven floating chatbot configuration. New `FloatingChatbotConfig` interface with `position`, `defaultOpen`, `panelWidth`, `panelHeight`, `title`, `triggerIcon`, and `triggerSize` options.
1515

16+
- **Console floating chatbot integration** (`@object-ui/console`): Added the floating chatbot FAB to `ConsoleLayout`, making it available on every authenticated page. Uses `useObjectChat` with metadata-aware context (app name, object list) for intelligent auto-responses. Wired with demo auto-response mode by default, switchable to API streaming when `api` endpoint is configured.
17+
1618
- **AI SDUI Chatbot integration** (`@object-ui/plugin-chatbot`): Refactored chatbot plugin to support full AI streaming via `service-ai` backend and `vercel/ai` SDK (`@ai-sdk/react`). New `useObjectChat` composable hook wraps `@ai-sdk/react`'s `useChat` for SSE streaming, tool-calling, and production-grade chat. Auto-detects API mode (when `api` schema field is set) vs legacy local auto-response mode. ChatbotEnhanced component now supports stop, reload, error display, and streaming state indicators. 44 unit tests (19 new hook tests, 10 new streaming tests).
1719

1820
- **New ChatbotSchema fields** (`@object-ui/types`): Extended `ChatbotSchema` with `api`, `conversationId`, `systemPrompt`, `model`, `streamingEnabled`, `headers`, `requestBody`, `maxToolRoundtrips`, and `onError` fields for service-ai integration. Extended `ChatMessage` with `streaming`, `toolInvocations` fields and added `ChatToolInvocation` interface for tool-calling flows.

apps/console/src/components/ConsoleLayout.tsx

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
*
44
* Root layout shell for the console application. Composes the AppShell
55
* with the sidebar, header, and main content area.
6+
* Includes the global floating chatbot (FAB) widget.
67
* @module
78
*/
89

910
import React from 'react';
1011
import { AppShell } from '@object-ui/layout';
12+
import { FloatingChatbot, useObjectChat } from '@object-ui/plugin-chatbot';
1113
import { AppSidebar } from './AppSidebar';
1214
import { AppHeader } from './AppHeader';
1315
import { useResponsiveSidebar } from '../hooks/useResponsiveSidebar';
@@ -29,6 +31,56 @@ function ConsoleLayoutInner({ children }: { children: React.ReactNode }) {
2931
return <>{children}</>;
3032
}
3133

34+
/** Floating chatbot wired with useObjectChat for demo auto-response */
35+
function ConsoleFloatingChatbot({ appLabel, objects }: { appLabel: string; objects: any[] }) {
36+
const objectNames = objects.map((o: any) => o.label || o.name).join(', ');
37+
38+
const {
39+
messages,
40+
isLoading,
41+
error,
42+
sendMessage,
43+
stop,
44+
reload,
45+
clear,
46+
} = useObjectChat({
47+
initialMessages: [
48+
{
49+
id: 'welcome',
50+
role: 'assistant' as const,
51+
content: `Hello! I'm your **${appLabel}** assistant. How can I help you today?`,
52+
},
53+
],
54+
autoResponse: true,
55+
autoResponseText: objectNames
56+
? `I can help you work with ${objectNames}. What would you like to do?`
57+
: 'Thanks for your message! I\'m here to help you navigate and manage your data.',
58+
autoResponseDelay: 800,
59+
});
60+
61+
return (
62+
<FloatingChatbot
63+
floatingConfig={{
64+
position: 'bottom-right',
65+
defaultOpen: false,
66+
panelWidth: 400,
67+
panelHeight: 520,
68+
title: `${appLabel} Assistant`,
69+
triggerSize: 56,
70+
}}
71+
messages={messages as any}
72+
placeholder="Ask anything..."
73+
onSendMessage={(content: string) => sendMessage(content)}
74+
onClear={clear}
75+
onStop={isLoading ? stop : undefined}
76+
onReload={reload}
77+
isLoading={isLoading}
78+
error={error}
79+
enableMarkdown
80+
/>
81+
);
82+
}
83+
3284
export function ConsoleLayout({
3385
children,
3486
activeAppName,
@@ -37,6 +89,8 @@ export function ConsoleLayout({
3789
objects,
3890
connectionState
3991
}: ConsoleLayoutProps) {
92+
const appLabel = resolveI18nLabel(activeApp?.label) || activeAppName;
93+
4094
return (
4195
<AppShell
4296
sidebar={
@@ -47,7 +101,7 @@ export function ConsoleLayout({
47101
}
48102
navbar={
49103
<AppHeader
50-
appName={resolveI18nLabel(activeApp?.label) || activeAppName}
104+
appName={appLabel}
51105
objects={objects}
52106
connectionState={connectionState}
53107
/>
@@ -70,6 +124,9 @@ export function ConsoleLayout({
70124
<ConsoleLayoutInner>
71125
{children}
72126
</ConsoleLayoutInner>
127+
128+
{/* Global floating chatbot — available on every page */}
129+
<ConsoleFloatingChatbot appLabel={appLabel} objects={objects} />
73130
</AppShell>
74131
);
75132
}

0 commit comments

Comments
 (0)