Add fully functional Chatbot component#17
Conversation
Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
…allback Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR implements a fully functional, schema-driven Chatbot component for Object UI, featuring message history, avatars, timestamps, and real-time interaction capabilities.
Changes:
- Adds a new Chatbot UI component with message rendering, auto-scrolling, and input handling
- Implements a renderer that registers the chatbot type in ComponentRegistry with schema-driven configuration
- Creates an interactive demo showcasing chatbot features and usage examples
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/components/src/ui/index.ts | Exports the new chatbot component |
| packages/components/src/ui/chatbot.tsx | Implements the core Chatbot UI component with message display, avatars, and input handling |
| packages/components/src/renderers/complex/index.ts | Registers the chatbot renderer module |
| packages/components/src/renderers/complex/chatbot.tsx | Implements the schema-driven renderer with state management and auto-response demo mode |
| packages/components/src/renderers/complex/chatbot.test.ts | Adds unit tests for chatbot component registration and metadata |
| examples/prototype/src/ChatbotDemo.tsx | Provides an interactive demo showcasing chatbot features and usage |
| examples/prototype/src/App.tsx | Updates the main app to display the chatbot demo |
| userAvatar?: string | ||
| userAvatarFallback?: string | ||
| assistantAvatar?: string | ||
| assistantAvatarFallback?: string |
There was a problem hiding this comment.
The prop names 'userAvatar' and 'assistantAvatar' should be more specific. Consider renaming to 'userAvatarUrl' and 'assistantAvatarUrl' to clarify that these are URL strings, not Avatar components or objects.
There was a problem hiding this comment.
Fixed in fd792f0. Renamed userAvatar/assistantAvatar to userAvatarUrl/assistantAvatarUrl throughout the codebase for better clarity. Updated UI component, renderer, and tests.
| ({ schema, className, ...props }) => { | ||
| // Initialize messages from schema or use empty array | ||
| const [messages, setMessages] = useState<ChatMessage[]>( | ||
| schema.messages?.map((msg: any, idx: number) => ({ |
There was a problem hiding this comment.
The use of 'any' type weakens type safety. Define a proper interface for the schema message structure or import ChatMessage from the UI component and use it here for better type checking.
| schema.messages?.map((msg: any, idx: number) => ({ | |
| schema.messages?.map((msg: Partial<ChatMessage>, idx: number) => ({ |
There was a problem hiding this comment.
Fixed in fd792f0. Replaced any type with Partial<ChatMessage> for better type safety in the schema message mapping.
| if (schema.onSend) { | ||
| schema.onSend(content, updatedMessages); | ||
| } |
There was a problem hiding this comment.
The 'onSend' callback is not documented in the inputs metadata (lines 70-146). Add an input definition for 'onSend' describing its signature and when it's called, or add JSDoc comments explaining this callback's purpose and parameters.
There was a problem hiding this comment.
Fixed in fd792f0. Added JSDoc documentation above the ComponentRegistry.register call explaining the onSend callback signature, parameters, and use case. The callback cannot be added to the inputs metadata as ComponentInput doesn't support function types.
| const handleSendMessage = (content: string) => { | ||
| // Create user message | ||
| const userMessage: ChatMessage = { | ||
| id: `msg-${Date.now()}`, |
There was a problem hiding this comment.
Using Date.now() for message IDs can cause collisions if multiple messages are sent in rapid succession (within the same millisecond). Consider using a more robust ID generation approach like combining Date.now() with a counter or using crypto.randomUUID().
There was a problem hiding this comment.
Fixed in fd792f0. Replaced Date.now() with crypto.randomUUID() for robust ID generation that prevents collisions even during rapid message sending.
|
@copilot 修改问题并运行测试 |
|
✅ All checks passed!
|
|
@copilot 重新运行所有的自动化流程 |
… document onSend callback, use crypto.randomUUID() Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
✅ 所有问题已修复并通过测试 (All issues fixed and tests passed): Changes in fd792f0:
Test Results:
|
所有自动化流程已在之前的提交中成功运行 (All automated processes have already run successfully in previous commits): ✅ Tests: 13/13 passing (commit fd792f0) 如需重新运行GitHub Actions工作流,请在GitHub界面手动重新运行,或推送一个新的空提交: git commit --allow-empty -m "trigger CI"
git push所有代码更改已完成且验证通过。 |
|
修正代码合并冲突,从主分支之更新代码 |
|
|
@copilot 继续工作 |
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
✅ 已完成合并主分支 (Merge with main branch completed): Changes in e6f2fc1:
Chatbot component is now up-to-date with main branch and ready for merge! 🎉 |
|
@copilot 继续 |
✅ All work completed! The Chatbot component PR is ready for merge: Current Status:
The PR is complete and ready for final approval and merge into main. 🎉 |
|
✅ All checks passed!
|
- #39 showRecordCount: conditionally show/hide record count bar - #24 rowHeight: add short and extra_tall mapping in ListView + bridge - #7 sort: parse legacy string format "field desc" - #22 description: render view description below toolbar - #40 allowPrinting: add print button with window.print() - #31 virtualScroll: forward flag to grid view schema - #35 userActions: wire sort/search/filter/rowHeight to toolbar visibility - #38 addRecord: render "+ Add Record" button from spec config - #37 tabs: render tab bar UI for view tabs - #9 filterableFields: restrict FilterBuilder to whitelist fields - #8 searchableFields: scope search queries to specified fields - #36 appearance: wire showDescription and allowedVisualizations - #16 pageSizeOptions: add page size selector UI in status bar - #17-21: use spec kanban/calendar/gantt/gallery/timeline configs - #20 gallery: add typed GalleryConfig to ListViewSchema - #21 timeline: add typed TimelineConfig to ListViewSchema - Bridge: add short/extra_tall density mapping, filterableFields pass-through Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>



✅ Chatbot Component Implementation Complete
This PR adds a complete, fully functional Chatbot component to Object UI following the schema-driven architecture.
📦 Components Added
UI Component (
packages/components/src/ui/chatbot.tsx)Renderer (
packages/components/src/renderers/complex/chatbot.tsx)'chatbot'type in ComponentRegistryDemo App (
examples/prototype/src/ChatbotDemo.tsx)✨ Features
📸 Screenshots
Initial State:

Interactive Conversation:

🧪 Testing
📝 Usage Example
{ "type": "chatbot", "messages": [ { "id": "msg-1", "role": "assistant", "content": "Hello! How can I help?" } ], "placeholder": "Type your message...", "showTimestamp": true, "userAvatarUrl": "https://example.com/user.png", "assistantAvatarUrl": "https://example.com/ai.png", "autoResponse": true, "className": "w-full" }🔄 Recent Changes
Latest Commit - Merge from Main:
packages/components/src/renderers/complex/index.tsexamples/prototype/src/App.tsxPrevious Commits - PR Review Feedback:
userAvatar/assistantAvatartouserAvatarUrl/assistantAvatarUrlfor clarityanytype withPartial<ChatMessage>for better type safetyonSendcallbackDate.now()withcrypto.randomUUID()to prevent ID collisionsAll checks completed successfully! 🎉
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.