- 抽屉和会话页渲染同一套 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
53 lines
2.1 KiB
TypeScript
53 lines
2.1 KiB
TypeScript
import { afterAll, beforeAll, describe, expect, it } from "vitest";
|
|
import { createAgentModule } from "../../src/modules/agent/index.ts";
|
|
import { createHarness, type Harness, pgAvailable } from "../auth-settings/harness.ts";
|
|
import { DEV_KEY, json } from "../helpers.ts";
|
|
|
|
// 会话列表筛选:group 按来源分(对话 / 自动巡检,子会话随父会话);roots 只列顶层会话
|
|
const hasPg = await pgAvailable();
|
|
|
|
describe.skipIf(!hasPg)("会话列表 group 筛选(真实 PG)", () => {
|
|
let h: Harness;
|
|
beforeAll(async () => {
|
|
h = await createHarness({ extraModules: [createAgentModule()] });
|
|
}, 120_000);
|
|
afterAll(async () => {
|
|
await h?.close();
|
|
});
|
|
|
|
it("auto = schedule / event 及其子会话;conversation = 其余", async () => {
|
|
const run = async (trigger: string, goal: string, parent?: string) =>
|
|
(
|
|
await h.db
|
|
.insertInto("agent_run")
|
|
.values({ trigger, goal, status: "succeeded", mode: "execute", parent_run_id: parent ?? null } as never)
|
|
.returning("id")
|
|
.executeTakeFirstOrThrow()
|
|
).id;
|
|
const patrol = await run("schedule", "巡检");
|
|
await run("subagent", "巡检子会话", patrol);
|
|
await run("event", "事件");
|
|
const chat = await run("user", "对话");
|
|
await run("subagent", "对话子会话", chat);
|
|
const goals = async (group: string) =>
|
|
(
|
|
await json(
|
|
await h.app.request(`/api/v1/agent/runs?group=${group}`, { headers: { authorization: `Bearer ${DEV_KEY}` } }),
|
|
)
|
|
).data.items
|
|
.map((r: { goal: string }) => r.goal)
|
|
.sort();
|
|
expect(await goals("auto")).toEqual(["事件", "巡检", "巡检子会话"].sort());
|
|
expect(await goals("conversation")).toEqual(["对话", "对话子会话"].sort());
|
|
// 会话列表只列顶层会话:子会话在父会话的会话流里看
|
|
const roots = (
|
|
await json(
|
|
await h.app.request("/api/v1/agent/runs?roots=true", { headers: { authorization: `Bearer ${DEV_KEY}` } }),
|
|
)
|
|
).data.items
|
|
.map((r: { goal: string }) => r.goal)
|
|
.sort();
|
|
expect(roots).toEqual(["事件", "巡检", "对话"].sort());
|
|
});
|
|
});
|