Repository navigation
feat(chat): Bash 工具卡实时显示命令输出 - #1122
Merged
Merged
Conversation
编译等长命令运行时,工具卡此前只显示"运行中",看不到进度。K-brain 以
tool.status{tool_call_id,status:"running",message} 推送输出尾部快照(有上限、
已节流),桌面端接入:
- turn.ts:带 tool_call_id 的 running 状态交给新的 onToolOutput 回调,不再当作
整轮状态文字覆盖运行进度;未知调用或已出结果的调用的快照忽略
- 实时轮次:ToolTraceItem 新增 liveOutput,setToolLiveOutputInRound 整体替换
快照;结果到达时丢弃,不进历史、持久化消息或 WebUI 转发
- ShellToolDisplay:无结果时显示实时输出,去掉终端控制序列、按 \r 只保留进度条
最后一次重绘,最多 200 行 / 8000 字符;贴底自动滚动,用户上翻时不抢位置
- ToolCallItem:收到输出时自动展开,成功结束后自动收起,失败保持展开;用户
手动开合后不再干预;memo 比较包含 liveOutput
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #975
功能
命令运行中,Bash 工具卡实时显示输出尾部(如编译进度),结果到达后由最终输出取代。
实现
后端部分在 K-brain:Stack-Cairn/K-brain#77(已合并,随 K-brain v0.107.7 发布)。桌面端
Bash运行中推送tool.status{tool_call_id,status:"running",message}输出快照,每个调用最多 500ms 一次、单次最多 4 KiB,协议不变。LiveAgent:
lib/kbrain/turn.ts:带tool_call_id的tool.status走新的onToolOutput,不再覆盖整轮状态;未知调用或已有结果的调用忽略。liveOutput(runKBrainConversationTurn.ts)。结果到达即丢弃,不写入历史、持久化消息或 WebUI relay。ShellToolDisplay渲染实时输出(liveShellOutput.ts):去 ANSI 颜色;\r进度重绘只保留最新一帧;上限 200 行 / 8000 字符;自动跟随底部,用户上翻时不抢滚动。ToolCallItem:有输出时自动展开,成功结束后收起,失败保持展开;用户手动开合后不再干预。scripts/release/kbrain.lock.json锁定 K-brain v0.107.7(hash 来自 release 的SHA256SUMS,8 个下载地址均返回 200)。已知限制:被折叠的工具组里卡片会展开但组不会;Gateway WebUI 暂未显示;
yield_time_ms后台命令不推送。旧版 K-brain 不发这类事件,行为与原来一致。验证
test/chat/kbrain-live-tool-output.test.mjs,以及tool-argument-display.test.mjs的两个渲染用例,共 22/22 通过。pnpm test:gui中启动真实 K-brain 的 6 个测试文件:用该分支构建的 K-brain 跑,30/30 通过。go test(backend/agent/tools/protocol)、go vet、-race通过。Screenshots / preview
在浏览器中渲染真实的
ToolCallItem(运行中的cargo build --release,输出含 ANSI 颜色和\r进度条):