Skip to content

新增 V2 本地 Web UI:流式输出、Lab Trace、多主题 - #43

Merged
erik-mingyang merged 10 commits into
Runchuan-BU:mainfrom
IveGotMagicBean:main
Apr 27, 2026
Merged

新增 V2 本地 Web UI:流式输出、Lab Trace、多主题#43
erik-mingyang merged 10 commits into
Runchuan-BU:mainfrom
IveGotMagicBean:main

Conversation

@IveGotMagicBean

Copy link
Copy Markdown
Contributor

概述

local-web channel 新增一套 V2 UI,与原版完全并存:

  • / 默认指向 V2 UI
  • /v1 保留原版 UI(页面 / 数据完全不变)
  • /v2 作为别名指向 V2

数据库、会话、群组配置、其他 channel(WhatsApp / 微信 / 飞书等)均不受影响。

主要功能

  • 流式输出:回答一字一字渲染;思考过程进 Lab Trace 抽屉,最终答复进聊天框
  • Lab Trace 抽屉:实时查看 agent 的 thinking / tool_use 步骤,Compact / Full 两种选项
  • 自然语言步骤摘要:30+ 生物工具、35+ 数据库、25+ 文件类型的规则映射,便于用户理解
  • 多线程对话:左侧 Thread 列表可同时管理多个对话
  • 文件预览:聊天气泡里的文件链接点开后在右边栏预览
  • 可拖拽列宽:thread rail / chat / trace 三栏宽度可调
  • 9 套主题 + 暗色模式
  • 中英文自动检测 + 切换

改动文件

类型 文件 说明
新增 src/channels/local-web/assets/v2/{index.html,app.js,style.css} V2 前端
(~5500 行)
新增 UPGRADE-V2-UI.md V2-UI说明文档
新增 container/Dockerfile.viz 多阶段构建:从 python:3.11-slim-bookworm 引入
Python + SSL libs
修改 src/channels/local-web/channel.ts 路由://v2 → V2,/v1 → 原版
修改 container/agent-runner/src/index.ts OpenAI 兼容接口 SSE 流式;tool_call
JSON 校验;ECONNRESET 4 次指数退避重试
修改 src/index.ts streaming chunks 不推送到聊天
修改 src/container-runner.ts ContainerOutput.status'streaming' 类型

不影响的部分

  • 原版 UI 仅路由从 / 换成 /v1,页面、数据、行为完全不变
  • 所有聊天记录、会话、群组配置完全兼容
  • WhatsApp / 微信 / 飞书等其他 channel 行为不变
  • .env 不会被覆盖

升级 / 回退

详细步骤见 UPGRADE-V2-UI.md,简要:

git pull
./container/build.sh        # 1-2 分钟(缓存复用)
npm run stop:web && npm run web

回退:git reset --hard <旧 commit> + 重建容器,不影响数据存储。

测试

  • V2 UI:建线程 / 发消息 / 流式回答 / 切换主题 / 中英语言切换 / Compact-Full trace / 文件预览
  • V1 UI:访问 /v1 仍为原版页面,对话历史完整可见
  • 路由://v1/v2 均 200
  • 容器:DashScope SSE 流式输出正常

IveGotMagicBean and others added 10 commits April 26, 2026 12:19
New beautified web interface at /v2 with 9 themes, thread sidebar,
lab trace drawer, and streaming output. Original UI at / is untouched.
Includes SSE streaming for OpenAI-compatible providers and upgrade guide.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…nalize

The streaming bubble now shows real-time streaming response text (the answer
typed out token by token) when the model is generating, and a compact step
summary (thinking / tool use) when tools are running. Stop finalizing the
bubble on run_end before the chat message arrives so it no longer disappears
mid-response. Also derive workspace folder from chatJid as a fallback so
fresh threads still hit the right trace events.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add full upgrade flow for users who cloned the original repo: add fork
as a separate remote, merge, rebuild container, restart. Include both
quick-revert (via tagged backup image) and full-revert (rebuild) paths.
Clarify Docker vs npm responsibilities and why install location doesn't
matter (mounts are derived from cwd at runtime).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Remove the Docker/npm relationship section and install-location section.
Keep only: what changed, new features, new-user install, existing-user
upgrade (with fork remote), and rollback paths.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The right drawer now flips to a full-height file preview when the user
clicks a file link from a chat bubble or a "preview" button on a trace
event (agent_tool_use, ipc_send). Images, code/text, and PDFs render
inline; binary files fall back to download. A "← Lab Trace" button
returns to the trace timeline.

Add column resizers between thread rail / chat / trace. Drag to size
(160px to 80% viewport), double-click to reset, persisted in
localStorage. Default trace width bumped 420→560px so previews have
breathing room.

Add container/Dockerfile.viz: a multi-stage Dockerfile that copies
Python + matplotlib/numpy/seaborn/pandas from python:3.11-slim-bookworm
on top of the existing bioclaw-agent image, so agents can actually
generate the images this preview drawer is now built for. Bypasses
flaky Debian/Aliyun apt mirrors.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…l-call JSON guard

Streaming bubble:
- Split into a "Process" strip (collapsed details, italic thinking, accent
  tool name with mono command pill) and an "Answer" body styled like a real
  bubble. Easy at a glance to tell what the agent is doing vs saying.
- Process strip is preserved (auto-collapsed) when the run finalizes so the
  thinking history doesn't vanish.

Lab Trace drawer:
- Compact / Full segmented toggle. Compact (default) shows only step labels
  (Thinking, Bash, Read, ...); Full adds the bodies (thinking text, command
  args). Both modes always hide stream_output chunks.

Container fix (rebuild required):
- The OpenAI-compatible streaming SSE parser previously sent malformed
  function.arguments to the model on the next turn when the stream truncated
  mid-tool-call, getting rejected by DashScope/qwen with 400. Now we validate
  the assembled args are parseable JSON; otherwise normalize to '{}' and, if
  every tool call degraded, retry the same query non-streaming.

Dockerfile.viz now also rebuilds agent-runner so this fix lands in the image.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- humanizeStep rules cover 30+ bio tools, 35+ databases, 25+ file types
- Auto-detect user language (LLM replies in user's language)
- Visible Compact/Full trace mode toggle + clearer language switcher
- Drop thinking-text extraction (often negative); rely on rule-based summaries
- agent-runner: SSE tool_call JSON guard + 4-attempt exponential backoff for ECONNRESET
- Dockerfile.viz: multi-stage copy of Python + SSL libs from python:3.11-slim-bookworm

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- / and /v2 now both serve the new V2 UI
- /v1 serves the original UI (data unchanged)
- Update UPGRADE-V2-UI.md to reflect new routes

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@erik-mingyang
erik-mingyang merged commit dcc7644 into Runchuan-BU:main Apr 27, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants