git-subtree-dir: vendor/ruvector git-subtree-split: b64c21726f2bb37286d9ee36a7869fef60cc6900
5.8 KiB
5.8 KiB
ADR-015: Chat UI Architecture
Status
Accepted
Date
2026-01-28
Context
RuvBot provides a powerful REST API for chat interactions, but lacks a user-facing web interface. When users visit the root URL of a deployed RuvBot instance (e.g., on Cloud Run), they receive a 404 error instead of a usable chat interface.
Requirements
- Provide a modern, responsive chat UI out of the box
- Support dark mode (default) and light mode themes
- Work with the existing REST API endpoints
- No build step required - serve static files directly
- Support streaming responses for real-time AI interaction
- Mobile-friendly design
- Model selection capability
- Integration with CLI and npm package
Alternatives Considered
| Option | Pros | Cons |
|---|---|---|
| assistant-ui | Industry leader, 200k+ downloads, Y Combinator backed | Requires React build, adds complexity |
| Vercel AI Elements | Official Vercel components, AI SDK integration | Requires Next.js |
| shadcn-chatbot-kit | Beautiful components, shadcn design system | Requires React build |
| Embedded HTML/CSS/JS | No build step, portable, fast deployment | Less features, custom implementation |
Decision
Implement a lightweight embedded chat UI using vanilla HTML, CSS, and JavaScript that:
- Is served directly from the existing HTTP server
- Requires no build step or additional dependencies
- Provides a modern, accessible interface
- Supports dark mode by default
- Includes basic markdown rendering
- Works seamlessly with the existing REST API
Architecture
┌─────────────────────────────────────────────────────────────────┐
│ RuvBot Server │
├─────────────────────────────────────────────────────────────────┤
│ GET / → Chat UI (index.html) │
│ GET /health → Health check │
│ GET /api/models → Available models │
│ POST /api/sessions → Create session │
│ POST /api/sessions/:id/chat → Chat endpoint │
└─────────────────────────────────────────────────────────────────┘
File Structure
src/
├── api/
│ └── public/
│ └── index.html # Chat UI (single file)
├── server.ts # Updated to serve static files
└── ...
Features
- Theme Support: Dark mode default, light mode toggle
- Model Selection: Dropdown for available models
- Responsive Design: Mobile-first approach
- Accessibility: ARIA labels, keyboard navigation
- Markdown Rendering: Code blocks, lists, links
- Error Handling: User-friendly error messages
- Session Management: Automatic session creation
- Real-time Updates: Typing indicators
CSS Design System
:root {
--bg-primary: #0a0a0f; /* Dark background */
--bg-secondary: #12121a; /* Card background */
--text-primary: #f0f0f5; /* Main text */
--accent: #6366f1; /* Indigo accent */
--radius: 12px; /* Border radius */
}
API Integration
The UI integrates with existing endpoints:
// Create session
POST /api/sessions { agentId: 'default-agent' }
// Send message
POST /api/sessions/:id/chat { message: '...', model: '...' }
Consequences
Positive
- Zero Configuration: Works out of the box
- Fast Deployment: No build step required
- Portable: Single HTML file, easy to customize
- Lightweight: ~25KB uncompressed
- Framework Agnostic: No React/Vue/Svelte dependency
- Cloud Run Compatible: Works with existing deployment
Negative
- Limited Features: No streaming UI (yet), basic markdown
- Manual Updates: No component library updates
- Custom Code: Maintenance responsibility
Neutral
- Future option to add assistant-ui or similar for advanced features
- Can be replaced with any frontend framework later
Implementation
Server Changes (server.ts)
// Serve static files
function getChatUIPath(): string {
const possiblePaths = [
join(__dirname, 'api', 'public', 'index.html'),
// ... fallback paths
];
// Find first existing path
}
// Add root route
{ method: 'GET', pattern: /^\/$/, handler: handleRoot }
CLI Integration
# View chat UI URL after deployment
ruvbot deploy-cloud cloudrun
# Output: URL: https://ruvbot-xxx.run.app
# Open chat UI
ruvbot open # Opens browser to chat UI
npm Package
The chat UI is bundled with the npm package:
{
"files": [
"dist",
"bin",
"scripts",
"src/api/public"
]
}
Future Enhancements
- Streaming Responses: SSE/WebSocket for real-time streaming
- File Uploads: Image and document support
- Voice Input: Speech-to-text integration
- assistant-ui Migration: Full-featured React UI option
- Themes: Additional theme presets
- Plugins: Extensible UI components
References
- assistant-ui - Industry-leading chat UI library
- Vercel AI SDK - AI SDK with streaming support
- shadcn/ui - Design system inspiration
- ADR-013: GCP Deployment - Cloud Run deployment
Changelog
| Date | Change |
|---|---|
| 2026-01-28 | Initial version - embedded chat UI |