awa-123-cw/dsh-webui-perf ↗★ 1
dsh-webui-perf
WebUI 性能优化开关:设置面板一键开/关长代码流式渲染、历史加载、高亮/KaTeX/渲染缓存等优化
安装
$
npx -p @deepseek-ai/dsh dsh plugin --profile web add github:awa-123-cw/dsh-webui-perf说明文档
阅读完整 README ↗dsh-webui-perf 🐳⚡
DeepSeek Harness Web GUI 性能优化开关插件:长代码流式渲染、历史加载、语法高亮/公式/渲染缓存的优化,全部收敛到一个设置面板开关,随时一键开启或回退原始实现。
✨ 优化内容(开关开启时生效)
| 场景 | 优化 |
|---|---|
| 流式输出长代码 | 未闭合代码块增量解析(每帧只处理新增字节,O(n²)→O(n)) |
| 长代码写完瞬间 | 大代码块(>3000 字符)改空闲回调懒高亮,不再同步阻塞主线程 |
| 载入长历史会话 | 增量可见性判断(去掉每 chunk 的全文本 trim/rope 展平);工具调用树深度检查去 BFS |
| 长思考(Think 块) | 展开正文 100ms 节流更新,折叠摘要保持实时 |
| 重复渲染 | shiki 高亮 / KaTeX / settled markdown 渲染三层 LRU 缓存 |
| 读大文件 | ReadBlock 折叠时只高亮可见窗口(head/tail 16 行) |
实测:打开长代码历史会话的主线程冻结从 8.3s → 0.3s(-96%)。
📦 结构
dsh-webui-perf/
├── package.json # 插件清单(host + client 双面)
├── cordis.patch.yml # bundle patch(挂载到 web profile)
├── lib/
│ ├── index.js # host half:注册 webui-perf 设置命名空间
│ └── client.js # 浏览器 half:设置开关行 + localStorage/事件广播
└── patches/
├── dsh-webui-perf.patch # 对 deepseek-harness 源码的补丁(git apply)
├── apply-patches.mjs # 源码补丁应用/回滚脚本
└── apply-runtime-patches.mjs # 已安装环境的运行时补丁(api-proxy allowlist)
为什么需要补丁:优化代码在官方包内部(
ui-primitives是 shell 平台模块、ui-conversation/ui-trajectory是官方 client bundle,插件无法替换),因此优化以带开关的源码补丁形式随插件发布;插件本体负责开关 UI 与状态广播(localStorage +dsh:webui-perf-change事件,cordis-free 通道)。关闭开关即回退官方原始实现。
🚀 安装
1. 应用官方包补丁
方式 A:源码构建(推荐,可长期维护)
# 在 deepseek-harness 源码 checkout 里
git clone --depth 1 https://github.com/deepseek-ai/deepseek-harness.git
cd dsh-webui-perf/patches
node apply-patches.mjs # git apply --check + apply(自动备份语义,可 --reverse 回滚)
# 重新构建
cd
npm run build:lib:client
pnpm --filter @deepseek-ai/dsh-web-frontend run build
# 部署 dist 到 dsh-web-frontend/dist,lib/client.js 到各 client 包 lib/
方式 B:已安装环境(免构建)
node patches/apply-runtime-patches.mjs # 打 api-proxy allowlist(自动备份)
# 再把构建好的 dist 与 client bundle 部署到 node_modules 对应包
2. 安装插件本体
把 dsh-webui-perf 加入 web profile:
// D:\dsh\profiles\web\package.json
{
"dependencies": { "dsh-webui-perf": "link:D:/dsh-plugins/dsh-webui-perf" },
"dsh": { "profile": { "bundles": [ /* ... */, "dsh-webui-perf" ] } }
}
(或使用 super-injector 的 热装配。)