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
@@ -50,6 +50,7 @@ import { formatTokens } from "~/lib/tokens.ts";
|
||||
import { cn, formatDateTime } from "~/lib/utils.ts";
|
||||
import { InlineApproval, OptionsCard } from "./agent-interaction.tsx";
|
||||
import { splitContextGoal } from "./agent-store.ts";
|
||||
import { SubagentCard } from "./agent-subagents.tsx";
|
||||
import {
|
||||
type ActivityItem,
|
||||
activitySpan,
|
||||
@@ -458,6 +459,7 @@ export function AgentConversation({
|
||||
audit,
|
||||
after,
|
||||
knownNames,
|
||||
nested = false,
|
||||
}: {
|
||||
run: AgentRunView;
|
||||
live: AgentStreamState;
|
||||
@@ -467,6 +469,8 @@ export function AgentConversation({
|
||||
after?: ReactNode;
|
||||
/** 工具结果之外已知的「ID → 名字」(子会话),汇报兜底换名用 */
|
||||
knownNames?: [string, string][];
|
||||
/** 嵌在子会话卡片里:不重复目标(卡片上有),间距收一档 */
|
||||
nested?: boolean;
|
||||
}) {
|
||||
const active = isRunActive(run.status) && !live.finished;
|
||||
const waiting = run.status === "waiting" || run.status === "running" || run.status === "queued";
|
||||
@@ -519,8 +523,8 @@ export function AgentConversation({
|
||||
) : null;
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-5 px-1 py-2">
|
||||
<UserMessage text={run.goal} tag={isProposeFirst(run) ? "先给方案" : undefined} />
|
||||
<div className={cn("flex flex-col px-1", nested ? "gap-3 py-1.5 text-caption" : "gap-5 py-2")}>
|
||||
{nested ? null : <UserMessage text={run.goal} tag={isProposeFirst(run) ? "先给方案" : undefined} />}
|
||||
{blocks.map((b, bi) =>
|
||||
b.kind === "user" ? (
|
||||
<UserMessage key={b.key} text={b.text} note={b.pending ? "已发送,等智能体读取" : undefined} animateIn />
|
||||
@@ -544,6 +548,14 @@ export function AgentConversation({
|
||||
until={p.body[0]?.at ?? null}
|
||||
/>
|
||||
) : null}
|
||||
{p.subagents.map((v) => (
|
||||
<div
|
||||
key={v.childRunId}
|
||||
className={cn("w-full min-w-0 py-1", freshKeys.has(`sa${v.childRunId}`) && anim)}
|
||||
>
|
||||
<SubagentCard view={v} />
|
||||
</div>
|
||||
))}
|
||||
{p.activity
|
||||
.flatMap((a) => (a.kind === "tool" ? draftCheckOf(a.call) : []))
|
||||
.map((d) => (
|
||||
@@ -711,14 +723,11 @@ export function ResultLine({
|
||||
run,
|
||||
report,
|
||||
live,
|
||||
subagents = 0,
|
||||
showCost = true,
|
||||
}: {
|
||||
run: AgentRunView;
|
||||
report: GoalReport | null;
|
||||
live: AgentStreamState;
|
||||
/** 实际派出的子会话数(会话树里的直接子会话,不含被拒绝的派发) */
|
||||
subagents?: number;
|
||||
/** 上方统计行已显示费用时传 false,不重复 */
|
||||
showCost?: boolean;
|
||||
}) {
|
||||
@@ -756,7 +765,6 @@ export function ResultLine({
|
||||
</span>
|
||||
))}
|
||||
</span>
|
||||
{subagents ? <span className="tabular-nums">· 派出 {subagents} 个子会话</span> : null}
|
||||
{durationMs ? <span className="tabular-nums">· {durationLabel(durationMs)}</span> : null}
|
||||
{showCost && u.costUsd ? <span className="tabular-nums">· 约 {formatUsd(u.costUsd)}</span> : null}
|
||||
{mismatch.length ? (
|
||||
|
||||
Reference in new issue
Block a user