|
22 | 22 | - **Styling**: Tailwind CSS classes, responsive design patterns |
23 | 23 |
|
24 | 24 | ## Tech Stack |
25 | | -React 19, TypeScript, Vite, Tailwind CSS, Hono API, Cloudflare Workers, IndexedDB |
| 25 | +React 19, TypeScript, Vite, Tailwind CSS, Hono API, Cloudflare Workers, IndexedDB, React Router, use-mcp |
| 26 | + |
| 27 | +## Chat UI Specific Guidelines |
| 28 | + |
| 29 | +### Background Animation |
| 30 | +- Use CSS `hue-rotate` filter for color cycling (more performant than gradient animation) |
| 31 | +- Isolate animations to `::before` pseudo-elements with `z-index: -1` to prevent inheritance |
| 32 | +- Use `background-size: 100% 100vh` and `background-repeat: repeat-y` for repeating patterns |
| 33 | +- Initialize with random animation delay using CSS custom properties |
| 34 | + |
| 35 | +### Modal Patterns |
| 36 | +- Use `rgba(0,0,0,0.8)` for modal backdrops (avoid gradients that cause banding) |
| 37 | +- Implement click-outside-to-dismiss with `onClick` on backdrop and `stopPropagation` on content |
| 38 | +- Add `cursor-pointer` to all clickable elements including close buttons |
| 39 | +- Use `document.body.style.overflow = 'hidden'` to prevent background scrolling |
| 40 | + |
| 41 | +### MCP Server Management |
| 42 | +- Store multiple servers in localStorage as JSON array (`mcpServers`) |
| 43 | +- Track tool counts separately (`mcpServerToolCounts`) for disabled servers |
| 44 | +- Use server-specific IDs for state management |
| 45 | +- Each MCP server gets unique `useMcp` hook instance for proper isolation |
| 46 | +- OAuth state parameter automatically handles multiple server differentiation |
| 47 | + |
| 48 | +### State Persistence |
| 49 | +- Use localStorage for user preferences (model selection, server configurations) |
| 50 | +- Use sessionStorage for temporary state (single server URL in legacy components) |
| 51 | +- Clear related data when removing servers or models |
| 52 | + |
| 53 | +### UI Indicators |
| 54 | +- Use emoji-based indicators (🧠 for models, 🔌 for MCP servers) |
| 55 | +- Format counts as `enabled/total` (e.g., "1/2 servers, 3/5 tools") |
| 56 | +- Place model selector on left, MCP servers on right for balance |
| 57 | +- Show "none" instead of red symbols for cleaner unconfigured states |
| 58 | + |
| 59 | +### Component Organization |
| 60 | +- Keep disabled components in React tree but hidden with CSS (`{false && ...}`) |
| 61 | +- This prevents MCP connections from being destroyed when modals close |
| 62 | +- Use conditional rendering sparingly, prefer CSS visibility for stateful components |
| 63 | + |
| 64 | +### Routing and OAuth |
| 65 | +- Use React Router for OAuth callback routes (`/oauth/callback`) |
| 66 | +- OAuth callback should match main app styling with loading indicators |
| 67 | +- use-mcp library handles multiple server OAuth flows automatically via state parameters |
| 68 | + |
| 69 | +### Performance Considerations |
| 70 | +- Avoid animating gradients directly (causes repainting) |
| 71 | +- Use transform and filter animations (hardware accelerated) |
| 72 | +- Aggregate tools from multiple sources efficiently |
| 73 | +- Minimize localStorage reads in render loops |
0 commit comments