Skip to content

Add fully functional Chatbot component#17

Merged
huangyiirene merged 8 commits intomainfrom
copilot/add-complete-chatbot-component
Jan 14, 2026
Merged

Add fully functional Chatbot component#17
huangyiirene merged 8 commits intomainfrom
copilot/add-complete-chatbot-component

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 13, 2026

✅ Chatbot Component Implementation Complete

This PR adds a complete, fully functional Chatbot component to Object UI following the schema-driven architecture.

📦 Components Added

  1. UI Component (packages/components/src/ui/chatbot.tsx)

    • Chatbot container with message list and input area
    • Message bubbles styled for user/assistant/system roles
    • Avatar support with customizable fallback
    • Auto-scrolling scroll area
    • Input field with keyboard support (Enter to send)
    • Optional timestamp display
    • Typing indicator component
  2. Renderer (packages/components/src/renderers/complex/chatbot.tsx)

    • Registered as 'chatbot' type in ComponentRegistry
    • Full schema configuration support
    • State management for dynamic messages
    • Event handling for message sending
    • Auto-response demo mode
  3. Demo App (examples/prototype/src/ChatbotDemo.tsx)

    • Interactive demonstration
    • Feature documentation
    • Usage examples

✨ Features

  • ✅ Message bubbles with user/assistant/system roles
  • ✅ Avatar support for participants
  • ✅ Scrollable message history with auto-scroll
  • ✅ Input field with send button
  • ✅ Enter key to send messages
  • ✅ Timestamp display (optional)
  • ✅ Auto-response for demos
  • ✅ Fully customizable via Tailwind CSS
  • ✅ Schema-driven configuration
  • ✅ TypeScript support

📸 Screenshots

Initial State:
Chatbot Demo

Interactive Conversation:
Chatbot Interaction

🧪 Testing

  • ✅ All component tests pass (14/14)
  • ✅ Build successful
  • ✅ Manually tested in prototype app
  • ✅ Interactive features verified
  • ✅ Code review completed
  • ✅ Security checks passed (0 vulnerabilities)
  • ✅ Merged with main branch - no conflicts

📝 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:

  • ✅ Merged latest changes from main branch
  • ✅ Resolved merge conflicts in packages/components/src/renderers/complex/index.ts
  • ✅ Resolved merge conflicts in examples/prototype/src/App.tsx
  • ✅ Integrated with new Calendar View and Filter Builder components
  • ✅ All tests passing after merge (14/14)

Previous Commits - PR Review Feedback:

  • ✅ Renamed userAvatar/assistantAvatar to userAvatarUrl/assistantAvatarUrl for clarity
  • ✅ Replaced any type with Partial<ChatMessage> for better type safety
  • ✅ Added JSDoc documentation for the onSend callback
  • ✅ Replaced Date.now() with crypto.randomUUID() to prevent ID collisions
  • ✅ Updated tests to reflect prop name changes

All checks completed successfully! 🎉

Original prompt

设一个功能完整的Chatbot组件


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits January 13, 2026 23:43
Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
@huangyiirene huangyiirene marked this pull request as ready for review January 13, 2026 23:50
Copilot AI and others added 2 commits January 13, 2026 23:52
Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
…allback

Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
Copilot AI changed the title [WIP] Add complete chatbot component Add fully functional Chatbot component Jan 13, 2026
Copilot AI requested a review from huangyiirene January 13, 2026 23:55
@huangyiirene huangyiirene requested review from Copilot and removed request for huangyiirene January 13, 2026 23:59
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 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

Comment on lines +26 to +29
userAvatar?: string
userAvatarFallback?: string
assistantAvatar?: string
assistantAvatarFallback?: string
Copy link

Copilot AI Jan 14, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in fd792f0. Renamed userAvatar/assistantAvatar to userAvatarUrl/assistantAvatarUrl throughout the codebase for better clarity. Updated UI component, renderer, and tests.

After refactoring

({ schema, className, ...props }) => {
// Initialize messages from schema or use empty array
const [messages, setMessages] = useState<ChatMessage[]>(
schema.messages?.map((msg: any, idx: number) => ({
Copy link

Copilot AI Jan 14, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
schema.messages?.map((msg: any, idx: number) => ({
schema.messages?.map((msg: Partial<ChatMessage>, idx: number) => ({

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in fd792f0. Replaced any type with Partial<ChatMessage> for better type safety in the schema message mapping.

Comment on lines +33 to +35
if (schema.onSend) {
schema.onSend(content, updatedMessages);
}
Copy link

Copilot AI Jan 14, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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()}`,
Copy link

Copilot AI Jan 14, 2026

Choose a reason for hiding this comment

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

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().

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in fd792f0. Replaced Date.now() with crypto.randomUUID() for robust ID generation that prevents collisions even during rapid message sending.

Interactive test showing unique IDs

@huangyiirene
Copy link
Copy Markdown
Contributor

@copilot 修改问题并运行测试

@github-actions
Copy link
Copy Markdown
Contributor

✅ All checks passed!

  • ✅ Type check passed
  • ✅ Tests passed
  • ✅ Lint check completed

@huangyiirene
Copy link
Copy Markdown
Contributor

@copilot 重新运行所有的自动化流程

… document onSend callback, use crypto.randomUUID()

Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jan 14, 2026

@copilot 修改问题并运行测试

✅ 所有问题已修复并通过测试 (All issues fixed and tests passed):

Changes in fd792f0:

  • ✅ Renamed avatar props for clarity (userAvatarUrl/assistantAvatarUrl)
  • ✅ Improved type safety (replaced any with Partial<ChatMessage>)
  • ✅ Documented onSend callback with JSDoc
  • ✅ Replaced Date.now() with crypto.randomUUID()

Test Results:

  • ✅ All 13 tests passing
  • ✅ Build successful
  • ✅ Manual testing verified

Working chatbot after refactoring

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jan 14, 2026

@copilot 重新运行所有的自动化流程

所有自动化流程已在之前的提交中成功运行 (All automated processes have already run successfully in previous commits):

✅ Tests: 13/13 passing (commit fd792f0)
✅ Build: Successful
✅ Code Review: Completed
✅ Security Scan: 0 vulnerabilities

如需重新运行GitHub Actions工作流,请在GitHub界面手动重新运行,或推送一个新的空提交:

git commit --allow-empty -m "trigger CI"
git push

所有代码更改已完成且验证通过。

@huangyiirene
Copy link
Copy Markdown
Contributor

修正代码合并冲突,从主分支之更新代码

@huangyiirene
Copy link
Copy Markdown
Contributor

修正代码合并冲突,从主分支之更新代码

@copilot

@hotlong
Copy link
Copy Markdown
Contributor

hotlong commented Jan 14, 2026

@copilot 继续工作

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jan 14, 2026

@copilot 继续工作

✅ 已完成合并主分支 (Merge with main branch completed):

Changes in e6f2fc1:

  • ✅ Merged latest changes from main branch
  • ✅ Resolved merge conflicts (packages/components/src/renderers/complex/index.ts)
  • ✅ Resolved merge conflicts (examples/prototype/src/App.tsx)
  • ✅ Integrated with Calendar View and Filter Builder components
  • ✅ All tests passing (14/14)
  • ✅ Build successful

Chatbot component is now up-to-date with main branch and ready for merge! 🎉

@hotlong
Copy link
Copy Markdown
Contributor

hotlong commented Jan 14, 2026

@copilot 继续

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jan 14, 2026

@copilot 继续

✅ All work completed! The Chatbot component PR is ready for merge:

Current Status:

  • ✅ Component fully implemented and tested
  • ✅ All PR review feedback addressed (commit fd792f0)
  • ✅ Merged with main branch (commit e6f2fc1)
  • ✅ All tests passing (14/14)
  • ✅ Build successful
  • ✅ No merge conflicts

The PR is complete and ready for final approval and merge into main. 🎉

@github-actions
Copy link
Copy Markdown
Contributor

✅ All checks passed!

  • ✅ Type check passed
  • ✅ Tests passed
  • ✅ Lint check completed

@huangyiirene huangyiirene merged commit 3b34d27 into main Jan 14, 2026
5 checks passed
Copilot AI added a commit that referenced this pull request Feb 23, 2026
- #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>
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.

4 participants