feat(remote-control): 优化 Web 展示、状态同步与桥接控制流程 (#288)

Co-authored-by: chengzifeng <chengzifeng@meituan.com>
This commit is contained in:
Cheng Zi Feng
2026-04-17 16:21:27 +08:00
committed by GitHub
parent b5c299f5d2
commit 72a2093cd6
64 changed files with 4138 additions and 312 deletions

View File

@@ -0,0 +1,103 @@
import { beforeEach, describe, expect, test } from "bun:test";
import {
applyTaskStateEvent,
getTaskState,
processAssistantEvent,
resetTaskState,
} from "./task-panel.js";
describe("task panel state", () => {
beforeEach(() => {
resetTaskState();
});
test("falls back to assistant tool_use parsing before an authoritative snapshot arrives", () => {
processAssistantEvent({
message: {
content: [
{
type: "tool_use",
name: "TaskUpdate",
input: { taskId: "1", subject: "Plan fix", status: "in_progress" },
},
],
},
});
expect(getTaskState()).toEqual({
tasks: [
{
id: "1",
subject: "Plan fix",
description: "",
activeForm: undefined,
status: "in_progress",
owner: undefined,
blocks: [],
blockedBy: [],
},
],
todos: [],
hasAuthoritativeTasks: false,
});
});
test("authoritative task_state snapshots replace tasks and stop transcript-derived task mutations", () => {
applyTaskStateEvent({
task_list_id: "team-alpha",
tasks: [
{
id: "7",
subject: "Real task",
description: "Pulled from task list",
status: "pending",
blocks: [],
blockedBy: [],
},
],
});
processAssistantEvent({
message: {
content: [
{
type: "tool_use",
name: "TaskUpdate",
input: { taskId: "99", subject: "Synthetic task", status: "completed" },
},
{
type: "tool_use",
name: "TodoWrite",
input: {
todos: [{ content: "Keep todo parsing", status: "pending", activeForm: "Keeping todo parsing" }],
},
},
],
},
});
expect(getTaskState()).toEqual({
tasks: [
{
id: "7",
subject: "Real task",
description: "Pulled from task list",
activeForm: undefined,
status: "pending",
owner: undefined,
blocks: [],
blockedBy: [],
},
],
todos: [
{
content: "Keep todo parsing",
status: "pending",
activeForm: "Keeping todo parsing",
},
],
hasAuthoritativeTasks: true,
});
});
});