From 4ee09976eef9f509bba69c99631fe3bbea35d28a Mon Sep 17 00:00:00 2001 From: caoqianming Date: Mon, 8 Jun 2026 09:04:43 +0800 Subject: [PATCH] Show task progress above composer --- tests/frontend_task_progress.test.mjs | 51 ++++++++++++++++ web/static/dev.html | 11 ++++ web/static/js/chat.js | 84 ++++++++++----------------- web/static/js/progress.js | 73 +++++++++++++++++++++++ web/static/js/state.js | 1 + 5 files changed, 167 insertions(+), 53 deletions(-) create mode 100644 tests/frontend_task_progress.test.mjs create mode 100644 web/static/js/progress.js diff --git a/tests/frontend_task_progress.test.mjs b/tests/frontend_task_progress.test.mjs new file mode 100644 index 0000000..bd69082 --- /dev/null +++ b/tests/frontend_task_progress.test.mjs @@ -0,0 +1,51 @@ +import assert from "node:assert/strict"; +import test from "node:test"; + +import { + applyProgressAction, + progressActionsFromToolCalls, +} from "../web/static/js/progress.js"; + +test("update_step without title preserves title from the existing plan", () => { + const initial = applyProgressAction([], { + action: "set_plan", + steps: [ + { id: "s1", title: "理解需求", status: "in_progress" }, + { id: "s2", title: "实现功能", status: "pending" }, + ], + }); + + const updated = applyProgressAction(initial, { + action: "update_step", + step: { id: "s1", status: "completed" }, + }); + + assert.deepEqual(updated, [ + { id: "s1", title: "理解需求", status: "completed" }, + { id: "s2", title: "实现功能", status: "pending" }, + ]); +}); + +test("tool calls can apply progress updates on top of previous task progress", () => { + const previous = [ + { id: "s1", title: "理解需求", status: "in_progress" }, + { id: "s2", title: "实现功能", status: "pending" }, + ]; + const toolCalls = [{ + function: { + name: "task_progress", + arguments: JSON.stringify({ + action: "update_step", + step: { id: "s1", status: "completed" }, + }), + }, + }]; + + const result = progressActionsFromToolCalls(toolCalls, previous); + + assert.equal(result.sawProgress, true); + assert.deepEqual(result.steps, [ + { id: "s1", title: "理解需求", status: "completed" }, + { id: "s2", title: "实现功能", status: "pending" }, + ]); +}); diff --git a/web/static/dev.html b/web/static/dev.html index 3be0391..4402aaf 100644 --- a/web/static/dev.html +++ b/web/static/dev.html @@ -466,6 +466,16 @@ } .task-progress .tp-text { overflow-wrap: anywhere; line-height: 1.45; } .task-progress .tp-step.completed .tp-text { color: var(--muted); text-decoration: line-through; } + #task-progress-dock { + flex-shrink: 0; display: none; + padding: 8px 12px; border-top: 1px solid var(--border); + background: #fff; + } + #task-progress-dock.show { display: block; } + #task-progress-dock .task-progress { + margin-top: 0; border-color: rgba(192,57,43,0.22); + background: linear-gradient(180deg, #fff, #fffafa); + } /* media tool 摘要 banner(model / size / cost / elapsed,折叠态也可见) */ .tool-banner { display: inline-flex; flex-wrap: wrap; gap: 6px; @@ -1030,6 +1040,7 @@
(未选中任务)
请在左侧选一个任务
+