跪拜 Guibai
← All articles
Frontend · Vue.js · GitHub

Vue 3 Rebuild of DeepSeek's Chat Demo Cuts Source by 27% and Adds MCP and Skills

By OpenTiny社区 ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

A Vue 3 component library can now absorb the intricate state management of a production AI chat app, so a small team can replicate an 18,000-line reference implementation and still extend it with MCP and Skills. That puts a lot of infrastructure work behind a single dependency, making complex AI frontends significantly cheaper to build and maintain.

Summary

DeepSeek open-sourced a browser-direct chat application with streaming conversation, thinking, web search, link reading, multimodal uploads, voice, message branch trees, and ZIP archive import/export. The official React 18 + Zustand implementation runs 18,412 lines of production source. A Vue 3 rebuild using the TinyRobot component library and runtime suite replicated every feature, then added MCP tool connections and Skills management, and reduced the source to 13,368 lines, a 27.40% decrease.

The reduction came from three architecture iterations. Replacing hand-written UI components with TinyRobot's atomic components saved 4,347 lines, but adopting the higher-level ChatUI suite without also delegating the runtime actually increased code by 331 lines. The third iteration handed session state, streaming, cancellation, and persistence to TinyRobot's headless runtime and chat suite, removing an extra adapter layer and custom logic. The final structure separates atomic components, a UI-agnostic runtime layer, and a pre-built chat UI, while still allowing custom providers for DeepSeek's domain protocol.

The project also fixed deep concurrency issues, such as a ghost-write race where a stale engine save could overwrite a newly imported ZIP archive with the same session ID, solved with a historyEpoch marker. It passed 38 Playwright regression tests with no failures or flaky runs, plus static checks and real API tests covering streaming, search, OCR, ASR, and TTS.

Takeaways
— DeepSeek released chat-demo on GitHub on November 13, 2024, an open-source browser-direct chat application with advanced features like message branch trees, web search, multimodal uploads, voice, and ZIP archive import/export.
— The official React 18 + Zustand version contains 18,412 lines of production source (excluding icons and static payload).
— A Vue 3 + TinyRobot rebuild achieved 100% feature parity and added MCP tool connections and Skills management (local Markdown, folders, GitHub repo import).
— Production source dropped to 13,368 lines, a 27.40% reduction (5,044 fewer lines), including the new MCP and Skill logic.
— The second architecture stage, using the ChatUI suite without handing over the runtime, increased code by 331 lines, showing that UI adoption alone doesn't reduce code.
— The final architecture uses three layers: atomic components, a headless runtime (kit), and a chat suite, with custom ResponseProvider for DeepSeek protocol.
— A historyEpoch marker prevents stale engine saves from overwriting a newly imported ZIP archive with the same conversation ID.
— Playwright regular regression: 38 tests pass, 0 failures, 0 flaky; vue-tsc passes and oxlint reports 0 warnings/errors.
— Real API tests passed covering streaming, independent thinking, web search, URL reading, OCR, ASR, and TTS.
— The online demo stores the DeepSeek API key only in localStorage and never includes it in exported archives.
Conclusions

The 331-line increase when adding the ChatUI suite without transferring runtime is a cautionary tale: component library value depends on delegating state and lifecycle, not just rendering.

The complexity that makes a production AI chat app hard to replicate is not the chat UI itself but the message tree, ZIP interoperability, file re-upload, audio pipeline, and concurrency races.

TinyRobot's layered design, with a headless runtime separate from UI components, resolves the usual trade-off between abstraction and customization by letting developers inject custom protocol logic while reusing the rest.

The historyEpoch pattern for rejecting stale async writes is a generalizable solution for any IndexedDB-backed application where session IDs can collide.

Concepts & terms
MCP (Model Context Protocol)
An open protocol for connecting AI models to external tools and data sources. In this project, the browser directly communicates with CORS-enabled HTTP MCP servers to discover and invoke tools, with explicit user confirmation.
Headless runtime
A UI-agnostic layer that manages conversation state, streaming, cancellation, and persistence without tying to specific components. TinyRobot's kit layer provides composables like useConversation and useMessage that handle these concerns.
ResponseProvider
A TinyRobot hook that lets developers inject a custom streaming response handler for a specific model provider. It encapsulates provider-specific logic (like DeepSeek's search/thinking events) while the runtime manages the request lifecycle.
Source: juejin.cn ↗ Google Translate ↗ Backup ↗