feat(agent): 抽屉与会话页统一成一个对话界面,子会话在父会话里实时可见
- 抽屉和会话页渲染同一套 GoalComposer / AgentRunPanel;抽屉标题即最近会话切换, 头部只有新对话、在页面打开、关闭;去掉右下角悬浮按钮和最小化小窗 - 会话列表合一:对话与巡检混排带类型小标签,搜索 + 一个状态下拉,只列顶层会话 (GET /agent/runs?roots=true,新增可选参数) - 子会话卡片:由镜像的 subagent_* 事件折成,显示任务、状态、当前步骤、用时、调用次数、费用, 可展开看过程、可打开;顶部「N 个子会话运行中」跳到卡片;subagent_completed 加可选 durationMs - 回答去内部字段:汇报规则禁止照抄键值与字段表;展示层 stripInternalFields 把字段行 / 字段表移进技术信息 - 开场建议按页面给 2 条完整问法、点了直接发;指令只留 /先给方案,/重跑 改成「重新运行」按钮 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Cxwgnn2pbzQ7rXv3rq7fei
This commit is contained in:
1 parent
dd0f6e2c09
commit
3692793dff
35 files changed
+1454
-1137
No files matched your search
@@ -2,16 +2,13 @@ import type { AgentRunEvent } from "@umt/contracts";
|
||||
import { createElement } from "react";
|
||||
import { renderToStaticMarkup } from "react-dom/server";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { runGroup } from "~/api/agent.ts";
|
||||
import { followBehavior } from "~/components/agentui/message-scroller.tsx";
|
||||
import {
|
||||
agentListHref,
|
||||
agentRunHref,
|
||||
DRAFT_DRAWER_GOAL,
|
||||
DRAFT_PAGE_GOAL,
|
||||
groupFromSearch,
|
||||
readDraft,
|
||||
resolveGroup,
|
||||
revealScrollTop,
|
||||
runDraftKey,
|
||||
writeDraft,
|
||||
@@ -32,7 +29,7 @@ import {
|
||||
} from "./agent-store.ts";
|
||||
import { cachedRunEvents, cacheRunEvents } from "./use-agent-stream.ts";
|
||||
|
||||
// 智能体页面切换的状态逻辑:整页重挂载 key、分栏与 URL、草稿、滚动策略、快捷键在智能体页面的行为。
|
||||
// 智能体页面切换的状态逻辑:整页重挂载 key、链接、草稿、滚动策略、快捷键在智能体页面的行为、路由上下文。
|
||||
|
||||
describe("主内容区重挂载 key", () => {
|
||||
it("列表页与各会话页共用一个 key,切换会话不重挂载", () => {
|
||||
@@ -47,35 +44,12 @@ describe("主内容区重挂载 key", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("分栏:对话 / 自动巡检", () => {
|
||||
it("会话所在分栏:巡检 / 事件在自动巡检,子会话随父会话,父会话未知归对话", () => {
|
||||
expect(runGroup({ trigger: "schedule" })).toBe("auto");
|
||||
expect(runGroup({ trigger: "event" })).toBe("auto");
|
||||
expect(runGroup({ trigger: "user" })).toBe("conversation");
|
||||
expect(runGroup({ trigger: "subagent" }, { trigger: "schedule" })).toBe("auto");
|
||||
expect(runGroup({ trigger: "subagent" }, { trigger: "user" })).toBe("conversation");
|
||||
expect(runGroup({ trigger: "subagent" })).toBe("conversation");
|
||||
});
|
||||
it("URL 的 tab 只认两个取值", () => {
|
||||
expect(groupFromSearch("?tab=auto&mock=1")).toBe("auto");
|
||||
expect(groupFromSearch("?tab=conversation")).toBe("conversation");
|
||||
expect(groupFromSearch("?tab=xx")).toBeNull();
|
||||
expect(groupFromSearch("")).toBeNull();
|
||||
});
|
||||
it("取值顺序:URL > 当前会话 > 上次 > 对话", () => {
|
||||
expect(resolveGroup({ fromUrl: "conversation", activeRun: "auto", remembered: "auto" })).toBe("conversation");
|
||||
expect(resolveGroup({ fromUrl: null, activeRun: "auto", remembered: "conversation" })).toBe("auto");
|
||||
// 打开巡检会话、快照还没到:沿用点它时所在的分栏,不先闪到「对话」
|
||||
expect(resolveGroup({ fromUrl: null, activeRun: null, remembered: "auto" })).toBe("auto");
|
||||
expect(resolveGroup({ fromUrl: null })).toBe("conversation");
|
||||
});
|
||||
it("链接:会话页不带 tab(由会话决定),列表页只在自动巡检时带,保留演示开关", () => {
|
||||
describe("链接", () => {
|
||||
it("会话页、列表页链接保留演示开关;列表不再分栏,不带 tab", () => {
|
||||
expect(agentRunHref("r1")).toBe("/console/agent/r1");
|
||||
expect(agentRunHref("r1", true)).toBe("/console/agent/r1?mock=1");
|
||||
expect(agentListHref()).toBe("/console/agent");
|
||||
expect(agentListHref("auto")).toBe("/console/agent?tab=auto");
|
||||
expect(agentListHref("auto", true)).toBe("/console/agent?tab=auto&mock=1");
|
||||
expect(agentListHref("conversation", true)).toBe("/console/agent?mock=1");
|
||||
expect(agentListHref(true)).toBe("/console/agent?mock=1");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -207,6 +181,23 @@ describe("抽屉开着时路由变化", () => {
|
||||
syncAgentContextToPath("/console/home");
|
||||
expect(snapshot().context).toBeNull();
|
||||
});
|
||||
it("下载详情页带上下载任务;下载计划页不算", () => {
|
||||
openAgentDrawer({ label: "作品 aaaa", entityId: "aaaa", fromPath: true });
|
||||
syncAgentContextToPath("/console/downloads/t1");
|
||||
expect(snapshot().context).toMatchObject({ downloadTaskId: "t1", fromPath: true });
|
||||
syncAgentContextToPath("/console/downloads/plans");
|
||||
expect(snapshot().context).toBeNull();
|
||||
setAgentDrawerOpen(false);
|
||||
});
|
||||
it("关上再打开:接着看同一个会话(没有最小化小窗)", () => {
|
||||
showAgentRunInDrawer("r9");
|
||||
setAgentDrawerOpen(false);
|
||||
expect(snapshot()).toMatchObject({ open: false, runId: "r9" });
|
||||
expect(toggleAction(snapshot(), "/console/library")).toBe("restore");
|
||||
setAgentDrawerOpen(true);
|
||||
expect(snapshot()).toMatchObject({ open: true, runId: "r9" });
|
||||
setAgentDrawerOpen(false);
|
||||
});
|
||||
it("页面按钮带的上下文、正在看的会话、抽屉关着时不动", () => {
|
||||
openAgentDrawer({ label: "作品:沙丘", entityId: "e1" });
|
||||
syncAgentContextToPath("/console/sites/hdh");
|
||||
|
||||
Reference in new issue
Block a user