Skip to content

Commit c35dc38

Browse files
authored
Merge pull request #10 from link-assistant/issue-9-47417e527e82
feat: switchable chat UI providers with markdown support
2 parents d69597f + 5d27c35 commit c35dc38

20 files changed

+7442
-1600
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
### Added
2+
- Case study documentation for chat UI design research (issue #9)
3+
- Comprehensive comparison of React.js chat UI libraries including assistant-ui, reachat, chatscope, react-chat-elements
4+
- Research on Telegram-like React.js designs with TelegramUI and telegram-react
5+
- Markdown support integration guide with react-markdown and syntax highlighting examples
6+
- Implementation examples and migration guides for recommended libraries
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
### Added
2+
- Switchable chat UI providers with dropdown selector in header
3+
- Support for 4 chat UI libraries: Chatscope, Assistant UI, Reachat, React Chat Elements
4+
- Markdown rendering support for all providers with syntax highlighting
5+
- ChatProviderContext for managing provider selection state
6+
- MarkdownRenderer component using react-markdown with code highlighting
7+
- Provider abstraction with common ChatMessage interface
8+
- CSS styling for all chat provider themes (dark mode)
9+
- Dependencies: react-markdown, remark-gfm, react-syntax-highlighter, @assistant-ui/react, reachat, react-chat-elements
Lines changed: 379 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,379 @@
1+
# Case Study: Chat UI Design Research for Model-in-Browser
2+
3+
## Issue Reference
4+
- **Issue**: [#9 - Find alternative open-source chat design templates](https://github.com/link-assistant/model-in-browser/issues/9)
5+
- **Date**: 2026-01-08
6+
7+
## Executive Summary
8+
9+
This case study researches React.js chat UI libraries, Telegram-like designs, and markdown support options for improving the chat interface of the model-in-browser project. The goal is to find modern, minimalistic UI alternatives that can enhance user experience.
10+
11+
## Table of Contents
12+
13+
1. [Current Implementation Analysis](#current-implementation-analysis)
14+
2. [React Chat UI Libraries Research](#react-chat-ui-libraries-research)
15+
3. [Telegram-Like Design Options](#telegram-like-design-options)
16+
4. [Markdown Support Integration](#markdown-support-integration)
17+
5. [Recommendations](#recommendations)
18+
19+
---
20+
21+
## Current Implementation Analysis
22+
23+
### Technology Stack
24+
The project currently uses:
25+
- **@chatscope/chat-ui-kit-react** - Main chat UI component library
26+
- **React 18** with TypeScript
27+
- **Vite** as build tool
28+
- **Custom CSS** with dark theme overrides
29+
30+
### Current UI Features
31+
- Dark theme with custom CSS overrides for chatscope components
32+
- Status indicator (loading/ready/error)
33+
- Progress bar for model download
34+
- Typing indicator
35+
- Message input with send button
36+
- Streaming token display
37+
38+
### Areas for Improvement (as identified in the issue)
39+
- Need for more modern styling
40+
- More minimalistic design
41+
- Better mobile responsiveness
42+
- Markdown support for formatted messages
43+
44+
---
45+
46+
## React Chat UI Libraries Research
47+
48+
### Comparison Table
49+
50+
| Library | Stars | License | Last Updated | TypeScript | Best For |
51+
|---------|-------|---------|--------------|------------|----------|
52+
| **assistant-ui** | 7,933 | MIT | 2026-01-08 | Yes | AI Chat applications |
53+
| **react-markdown** | 15,354 | MIT | 2026-01-07 | Yes | Markdown rendering |
54+
| **telegram-react** | 2,527 | GPL-3.0 | 2026-01-07 | Yes | Telegram clone |
55+
| **@chatscope/chat-ui-kit-react** | 1,709 | MIT | 2026-01-07 | Yes | General chat (current) |
56+
| **react-chat-elements** | 1,386 | MIT | 2026-01-08 | Yes | Quick chat widgets |
57+
| **TelegramUI** | 726 | MIT | 2026-01-05 | Yes | Telegram Mini Apps |
58+
| **reachat** | 202 | MIT | 2026-01-07 | Yes | LLM/AI Chat UIs |
59+
| **MinChat react-chat-ui** | 99 | MIT | 2026-01-05 | Yes | Simple chat |
60+
61+
### Detailed Analysis
62+
63+
#### 1. assistant-ui (Recommended for AI Chat)
64+
- **GitHub**: https://github.com/assistant-ui/assistant-ui
65+
- **Stars**: 7,933 | **Forks**: 851
66+
- **Description**: TypeScript/React Library for AI Chat
67+
68+
**Key Features**:
69+
- Built specifically for AI chat applications
70+
- Streaming support out of the box
71+
- Markdown and code highlighting included
72+
- Auto-scroll and keyboard shortcuts
73+
- Radix-style composable primitives
74+
- Integrates with AI SDK, LangGraph, Mastra
75+
76+
**Pros**:
77+
- Purpose-built for LLM/AI interfaces
78+
- Production-ready UX patterns
79+
- Active development and large community
80+
- Built-in accessibility
81+
82+
**Cons**:
83+
- More complex setup than simple libraries
84+
- May be overkill for basic chat needs
85+
86+
#### 2. reachat (Modern LLM UI Blocks)
87+
- **GitHub**: https://github.com/reaviz/reachat
88+
- **Stars**: 202 | **Forks**: 22
89+
- **Description**: UI Building Blocks for LLM/Chat UIs
90+
91+
**Key Features**:
92+
- Tailwind CSS theming
93+
- Markdown rendering with code highlighting
94+
- Multiple layouts (console/companion)
95+
- File handling and previews
96+
- Light and dark themes
97+
- YouTube embeds, tables, links
98+
99+
**Pros**:
100+
- Purpose-built for LLM interfaces
101+
- Modern minimalist design
102+
- Easy Tailwind customization
103+
- Built-in markdown support
104+
105+
**Cons**:
106+
- Smaller community
107+
- Fewer third-party resources
108+
109+
#### 3. @chatscope/chat-ui-kit-react (Current)
110+
- **GitHub**: https://github.com/chatscope/chat-ui-kit-react
111+
- **Stars**: 1,709 | **Forks**: 148
112+
- **Description**: Open source UI toolkit for web chat applications
113+
114+
**Key Features**:
115+
- Comprehensive component library
116+
- CSS framework independent
117+
- Typing indicators, message groups
118+
- Conversation lists, sidebars
119+
120+
**Pros**:
121+
- Already integrated in project
122+
- Well-documented
123+
- Large component library
124+
- Mature and stable
125+
126+
**Cons**:
127+
- Generic chat design (not AI-specific)
128+
- Requires significant CSS overrides for modern look
129+
- No built-in markdown support
130+
131+
#### 4. react-chat-elements
132+
- **GitHub**: https://github.com/Detaysoft/react-chat-elements
133+
- **Stars**: 1,386 | **Forks**: 228
134+
- **Description**: React chat elements and UI components
135+
136+
**Key Features**:
137+
- Multiple message types (text, photo, video, audio, file)
138+
- Reply bar, system messages
139+
- Avatar support
140+
- Meeting links
141+
142+
**Pros**:
143+
- Simple to use
144+
- Multiple message formats
145+
- Lightweight
146+
147+
**Cons**:
148+
- Less active maintenance
149+
- Basic styling options
150+
151+
---
152+
153+
## Telegram-Like Design Options
154+
155+
### Top Telegram-Style Libraries
156+
157+
#### 1. TelegramUI (Official-Style Components)
158+
- **GitHub**: https://github.com/telegram-mini-apps-dev/TelegramUI
159+
- **Stars**: 726 | **License**: MIT
160+
- **Description**: React components library for Telegram Mini Apps
161+
162+
**Best For**: Projects wanting authentic Telegram aesthetics
163+
164+
**Features**:
165+
- Pre-designed UI components inspired by Telegram interface
166+
- Built for Telegram Mini Apps ecosystem
167+
- Modern and clean design
168+
169+
#### 2. evgeny-nadymov/telegram-react
170+
- **GitHub**: https://github.com/evgeny-nadymov/telegram-react
171+
- **Stars**: 2,527 | **License**: GPL-3.0
172+
- **Description**: Experimental Telegram web client
173+
174+
**Best For**: Reference implementation, studying Telegram UX patterns
175+
176+
**Note**: GPL-3.0 license may not be compatible with all projects
177+
178+
#### 3. zeeshan-akhter/telegram-ui-clone
179+
- **GitHub**: https://github.com/zeeshan-akhter/telegram-ui-clone
180+
- **Description**: Telegram replica with desktop and mobile views using ReactJS and MUI
181+
182+
**Best For**: Learning Telegram design patterns with MUI components
183+
184+
**Features**:
185+
- Responsive design (desktop + mobile)
186+
- Chat list with pagination
187+
- Message display for selected chats
188+
- Functional chat input UI
189+
190+
### Design Principles from Telegram
191+
192+
1. **Minimalism**: Clean interfaces with ample white space
193+
2. **Speed**: Instant message delivery feel
194+
3. **Bubbles**: Rounded message containers with tail indicators
195+
4. **Colors**: Blue for outgoing, white/gray for incoming
196+
5. **Typography**: Clear, readable fonts
197+
6. **Animations**: Subtle, fast transitions
198+
7. **Dark Mode**: Native dark theme support
199+
200+
---
201+
202+
## Markdown Support Integration
203+
204+
### Primary Solution: react-markdown
205+
- **GitHub**: https://github.com/remarkjs/react-markdown
206+
- **Stars**: 15,354 | **License**: MIT
207+
- **Description**: Markdown component for React
208+
209+
**Key Advantages**:
210+
- No `dangerouslySetInnerHTML` - secure by design
211+
- CommonMark compliant
212+
- Plugin ecosystem (remark/rehype)
213+
- GitHub Flavored Markdown support via remark-gfm
214+
215+
### Code Syntax Highlighting Options
216+
217+
#### Option A: react-syntax-highlighter
218+
```jsx
219+
import ReactMarkdown from 'react-markdown';
220+
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';
221+
import { vscDarkPlus } from 'react-syntax-highlighter/dist/esm/styles/prism';
222+
223+
<ReactMarkdown
224+
components={{
225+
code({ node, inline, className, children, ...props }) {
226+
const match = /language-(\w+)/.exec(className || '');
227+
return !inline && match ? (
228+
<SyntaxHighlighter style={vscDarkPlus} language={match[1]}>
229+
{String(children).replace(/\n$/, '')}
230+
</SyntaxHighlighter>
231+
) : (
232+
<code className={className} {...props}>{children}</code>
233+
);
234+
},
235+
}}
236+
>
237+
{markdown}
238+
</ReactMarkdown>
239+
```
240+
241+
#### Option B: Shiki (via Streamdown)
242+
- Better performance for streaming content
243+
- More accurate syntax highlighting
244+
- Used by VS Code
245+
246+
### Streaming Markdown Considerations
247+
248+
For AI chat with streaming responses, consider:
249+
250+
1. **Streamdown** - Specifically designed for streaming markdown
251+
- Handles incomplete blocks gracefully
252+
- Memoized rendering for performance
253+
- Shiki-based syntax highlighting
254+
255+
2. **Memoization Pattern** (from AI SDK cookbook)
256+
- Cache parsed markdown blocks
257+
- Prevent re-parsing on each token
258+
- Essential for long conversations
259+
260+
### Recommended Implementation
261+
262+
```jsx
263+
// Install dependencies
264+
// npm install react-markdown remark-gfm react-syntax-highlighter
265+
266+
import ReactMarkdown from 'react-markdown';
267+
import remarkGfm from 'remark-gfm';
268+
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';
269+
import { oneDark } from 'react-syntax-highlighter/dist/esm/styles/prism';
270+
271+
const MarkdownMessage = ({ content }) => (
272+
<ReactMarkdown
273+
remarkPlugins={[remarkGfm]}
274+
components={{
275+
code({ node, inline, className, children, ...props }) {
276+
const match = /language-(\w+)/.exec(className || '');
277+
return !inline && match ? (
278+
<SyntaxHighlighter
279+
style={oneDark}
280+
language={match[1]}
281+
PreTag="div"
282+
{...props}
283+
>
284+
{String(children).replace(/\n$/, '')}
285+
</SyntaxHighlighter>
286+
) : (
287+
<code className={className} {...props}>
288+
{children}
289+
</code>
290+
);
291+
},
292+
}}
293+
>
294+
{content}
295+
</ReactMarkdown>
296+
);
297+
```
298+
299+
---
300+
301+
## Recommendations
302+
303+
### Recommended Approach: Phased Migration
304+
305+
#### Phase 1: Add Markdown Support (Low Risk)
306+
1. Install `react-markdown` and `remark-gfm`
307+
2. Create a `MarkdownMessage` component
308+
3. Integrate with existing chatscope `Message` component
309+
4. Add syntax highlighting for code blocks
310+
311+
**Effort**: Low | **Impact**: High
312+
313+
#### Phase 2: UI Modernization (Medium Risk)
314+
Two options:
315+
316+
**Option A: Migrate to assistant-ui** (Recommended for AI-focused apps)
317+
- Best-in-class AI chat experience
318+
- Built-in streaming, markdown, code highlighting
319+
- Requires more significant refactoring
320+
321+
**Option B: Migrate to reachat**
322+
- Modern, minimalistic design
323+
- Tailwind-based theming
324+
- Good LLM support, smaller community
325+
326+
**Option C: Keep chatscope with custom styling**
327+
- Update CSS for more modern look
328+
- Add Telegram-inspired styling
329+
- Lowest migration effort
330+
331+
#### Phase 3: Design Polish
332+
- Implement Telegram-style message bubbles
333+
- Add subtle animations
334+
- Optimize for mobile
335+
336+
### Quick Wins
337+
338+
1. **Immediate**: Add markdown support with react-markdown
339+
2. **Short-term**: Modernize CSS with Tailwind or custom styles
340+
3. **Medium-term**: Evaluate migration to assistant-ui or reachat
341+
342+
### Final Recommendation
343+
344+
For the **model-in-browser** project, which is an AI chat application:
345+
346+
**Primary Recommendation**: Consider migrating to **assistant-ui**
347+
- It's purpose-built for AI chat applications
348+
- Has the largest community among AI-specific chat libraries
349+
- Includes streaming, markdown, and code highlighting out of the box
350+
- MIT licensed and actively maintained
351+
352+
**Alternative**: If migration is too disruptive, add **react-markdown** to the current chatscope implementation for immediate markdown support, then gradually adopt Telegram-inspired styling.
353+
354+
---
355+
356+
## References
357+
358+
### React Chat Libraries
359+
- [assistant-ui](https://github.com/assistant-ui/assistant-ui) - Typescript/React Library for AI Chat
360+
- [@chatscope/chat-ui-kit-react](https://github.com/chatscope/chat-ui-kit-react) - Chat UI Kit
361+
- [reachat](https://github.com/reaviz/reachat) - UI Building Blocks for LLM/Chat UIs
362+
- [react-chat-elements](https://github.com/Detaysoft/react-chat-elements) - React chat components
363+
- [MinChat react-chat-ui](https://github.com/MinChatHQ/react-chat-ui) - React Chat UI Kit
364+
365+
### Telegram-Style
366+
- [TelegramUI](https://github.com/telegram-mini-apps-dev/TelegramUI) - Telegram Mini Apps components
367+
- [telegram-react](https://github.com/evgeny-nadymov/telegram-react) - Telegram web client
368+
- [telegram-ui-clone](https://github.com/zeeshan-akhter/telegram-ui-clone) - Telegram replica with MUI
369+
370+
### Markdown Support
371+
- [react-markdown](https://github.com/remarkjs/react-markdown) - Markdown component for React
372+
- [Streamdown](https://www.kdjingpai.com/en/streamdown/) - Streaming markdown renderer
373+
- [AI SDK Markdown Cookbook](https://ai-sdk.dev/cookbook/next/markdown-chatbot-with-memoization) - Memoization patterns
374+
- [React Markdown Complete Guide](https://strapi.io/blog/react-markdown-complete-guide-security-styling) - Security and styling
375+
376+
### Articles
377+
- [LogRocket: Safely render Markdown](https://blog.logrocket.com/how-to-safely-render-markdown-using-react-markdown/)
378+
- [Good Code: Reachat Announcement](https://www.goodcode.us/blog/reachat-open-source-ui-building-blocks-for-llm-chat-uis)
379+
- [Athrael: Markdown in Streaming Chat](https://athrael.net/blog/building-an-ai-chat-assistant/add-markdown-to-streaming-chat)

0 commit comments

Comments
 (0)