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
@@ -127,6 +127,7 @@ export function registerAgentRoutes(
|
||||
if (query.status) q = q.where("status", "=", query.status);
|
||||
if (query.trigger) q = q.where("trigger", "=", query.trigger);
|
||||
if (query.parentRunId) q = q.where("parent_run_id", "=", query.parentRunId);
|
||||
if (query.roots === "true") q = q.where("parent_run_id", "is", null);
|
||||
if (query.group) {
|
||||
// 自动 = 定时 / 事件触发,子会话按父会话归类
|
||||
const auto = sql<boolean>`(trigger in ('schedule', 'event') or (trigger = 'subagent' and parent_run_id in
|
||||
|
||||
@@ -302,6 +302,9 @@ function completedBody(c: AgentRunRow): SubagentEventBody {
|
||||
summary: safe(c.summary, 1500),
|
||||
usage: usageOf(c),
|
||||
toolCalls: c.tool_call_count,
|
||||
...(c.started_at && c.finished_at
|
||||
? { durationMs: Math.max(0, new Date(c.finished_at).getTime() - new Date(c.started_at).getTime()) }
|
||||
: {}),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ 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)", () => {
|
||||
@@ -39,5 +39,14 @@ describe.skipIf(!hasPg)("会话列表 group 筛选(真实 PG)", () => {
|
||||
.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());
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user