圆桌 Step1:支持多澄清实时展示与合并提交
流式解析 ask_clarification 逐题渲染澄清卡;草稿恢复 selectedAgents 修复参与角色;Step3 隐藏左侧栏让报告区全宽。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
838cae0d2d
commit
23d6f9efc2
9 files changed
+376
-136
No files matched your search
@@ -25,8 +25,10 @@ import {
|
||||
X,
|
||||
} from "lucide-react";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Man1Avatar, RobotAvatar } from "@/roundtable-planning/components/Avatars";
|
||||
import {
|
||||
clarificationKey,
|
||||
IntentClarificationCard,
|
||||
type IntentClarificationSelection,
|
||||
} from "@/roundtable-planning/components/IntentClarificationCard";
|
||||
@@ -55,10 +57,10 @@ export interface Step1PanelProps {
|
||||
intentReady: object | null;
|
||||
isIntentSending: boolean;
|
||||
pendingIntentClarificationMsgId: number | null;
|
||||
intentClarificationSelections: Map<number, IntentClarificationSelection>;
|
||||
intentClarificationSelections: Map<string, IntentClarificationSelection>;
|
||||
// ─── Setters / Handlers ──────────────────────────────────────
|
||||
setIntentClarificationSelections: React.Dispatch<
|
||||
React.SetStateAction<Map<number, IntentClarificationSelection>>
|
||||
React.SetStateAction<Map<string, IntentClarificationSelection>>
|
||||
>;
|
||||
onSendMessage: (text: string) => void;
|
||||
onStopIntent: () => void;
|
||||
@@ -67,10 +69,10 @@ export interface Step1PanelProps {
|
||||
onEnterRoundtable: () => void;
|
||||
onManualSave: () => void;
|
||||
onTriggerToast: (msg: string) => void;
|
||||
submitIntentClarification: (
|
||||
submitIntentClarifications: (
|
||||
msgId: number,
|
||||
payload: ClarificationPayload,
|
||||
overrideSelection?: IntentClarificationSelection,
|
||||
clarifications: ClarificationPayload[],
|
||||
overrideByKey?: Record<string, IntentClarificationSelection>,
|
||||
) => void;
|
||||
}
|
||||
|
||||
@@ -90,7 +92,7 @@ export function Step1Panel(props: Step1PanelProps) {
|
||||
onEnterRoundtable,
|
||||
onManualSave,
|
||||
onTriggerToast,
|
||||
submitIntentClarification,
|
||||
submitIntentClarifications,
|
||||
} = props;
|
||||
|
||||
const step1ScrollRef = useRef<HTMLDivElement>(null);
|
||||
@@ -138,7 +140,7 @@ export function Step1Panel(props: Step1PanelProps) {
|
||||
intentClarificationSelections={intentClarificationSelections}
|
||||
setIntentClarificationSelections={setIntentClarificationSelections}
|
||||
isIntentSending={isIntentSending}
|
||||
submitIntentClarification={submitIntentClarification}
|
||||
submitIntentClarifications={submitIntentClarifications}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
@@ -266,15 +268,15 @@ interface Step1MessageProps {
|
||||
msg: InteractiveMessage;
|
||||
intentReady: object | null;
|
||||
pendingIntentClarificationMsgId: number | null;
|
||||
intentClarificationSelections: Map<number, IntentClarificationSelection>;
|
||||
intentClarificationSelections: Map<string, IntentClarificationSelection>;
|
||||
setIntentClarificationSelections: React.Dispatch<
|
||||
React.SetStateAction<Map<number, IntentClarificationSelection>>
|
||||
React.SetStateAction<Map<string, IntentClarificationSelection>>
|
||||
>;
|
||||
isIntentSending: boolean;
|
||||
submitIntentClarification: (
|
||||
submitIntentClarifications: (
|
||||
msgId: number,
|
||||
payload: ClarificationPayload,
|
||||
overrideSelection?: IntentClarificationSelection,
|
||||
clarifications: ClarificationPayload[],
|
||||
overrideByKey?: Record<string, IntentClarificationSelection>,
|
||||
) => void;
|
||||
}
|
||||
|
||||
@@ -285,7 +287,7 @@ function Step1Message({
|
||||
intentClarificationSelections,
|
||||
setIntentClarificationSelections,
|
||||
isIntentSending,
|
||||
submitIntentClarification,
|
||||
submitIntentClarifications,
|
||||
}: Step1MessageProps) {
|
||||
const isStreaming = msg.streaming === true;
|
||||
const isAgent = msg.sender !== "user";
|
||||
@@ -297,24 +299,23 @@ function Step1Message({
|
||||
? splitInlineReasoning(rawContent)
|
||||
: { content: rawContent, reasoning: null };
|
||||
const hasContent = thoughtFreeContent.length > 0;
|
||||
const clarification = msg.clarification;
|
||||
// 一轮可能有多条澄清问题(任务理解智能体一次问多个)。流式期就逐个灌进来,
|
||||
// 实时展示「协助过程」;终态再以权威集合覆盖。
|
||||
const clarifications = msg.clarifications ?? [];
|
||||
const parts = isAgent
|
||||
? splitIntentReadyBlock(thoughtFreeContent)
|
||||
: { before: thoughtFreeContent, summary: null as IntentSummary | null, after: "" };
|
||||
const isPendingClarification =
|
||||
isAgent &&
|
||||
clarification &&
|
||||
!intentReady &&
|
||||
!parts.summary &&
|
||||
pendingIntentClarificationMsgId === msg.id;
|
||||
const clarificationSelection =
|
||||
intentClarificationSelections.get(msg.id) ?? {
|
||||
selectedIds: [],
|
||||
custom: "",
|
||||
};
|
||||
// 是否展示澄清卡(还没出 summary / 还没整体就绪时)。流式中也展示(只读),
|
||||
// 终态且该消息为当前待澄清条目时才可交互。
|
||||
const showClarifications =
|
||||
isAgent && clarifications.length > 0 && !intentReady && !parts.summary;
|
||||
// 一轮多个问题才进入「逐题作答 + 合并发送」模式;单问题沿用「点击即发送」。
|
||||
const multiQuestion = clarifications.length > 1;
|
||||
const isPending = pendingIntentClarificationMsgId === msg.id;
|
||||
const clarificationsInteractive = isPending && !isStreaming;
|
||||
const introText =
|
||||
clarification &&
|
||||
parts.before.trim() === (clarification.question || "").trim()
|
||||
clarifications.length === 1 &&
|
||||
parts.before.trim() === (clarifications[0].question || "").trim()
|
||||
? ""
|
||||
: parts.before;
|
||||
|
||||
@@ -361,24 +362,63 @@ function Step1Message({
|
||||
把它丢弃,让用户看到的就是"复述 + 摘要卡",干净结束。
|
||||
*/}
|
||||
{isStreaming && <StreamingCursor />}
|
||||
{isPendingClarification && clarification && (
|
||||
<IntentClarificationCard
|
||||
payload={clarification}
|
||||
fallbackContent={parts.before || undefined}
|
||||
selection={clarificationSelection}
|
||||
onSelectionChange={(next) => {
|
||||
setIntentClarificationSelections((prev) => {
|
||||
const map = new Map(prev);
|
||||
map.set(msg.id, next);
|
||||
return map;
|
||||
});
|
||||
}}
|
||||
disabled={!isPendingClarification}
|
||||
submitting={isIntentSending && Boolean(isPendingClarification)}
|
||||
onSubmit={(override) =>
|
||||
submitIntentClarification(msg.id, clarification, override)
|
||||
}
|
||||
/>
|
||||
{showClarifications && (
|
||||
<div className="space-y-2">
|
||||
{clarifications.map((clar, index) => {
|
||||
const key = clarificationKey(msg.id, clar.id, index);
|
||||
const selection =
|
||||
intentClarificationSelections.get(key) ?? {
|
||||
selectedIds: [],
|
||||
custom: "",
|
||||
};
|
||||
return (
|
||||
<IntentClarificationCard
|
||||
key={key}
|
||||
payload={clar}
|
||||
fallbackContent={clar.question || parts.before || undefined}
|
||||
selection={selection}
|
||||
// 单问题:沿用原交互(单选点击即发送 / 多选 / 自定义走卡片自己的按钮)。
|
||||
// 多问题:才 defer —— 逐题只记录选择,由下方一个合并按钮统一发送。
|
||||
deferSubmit={multiQuestion}
|
||||
onSelectionChange={(next) => {
|
||||
setIntentClarificationSelections((prev) => {
|
||||
const map = new Map(prev);
|
||||
map.set(key, next);
|
||||
return map;
|
||||
});
|
||||
}}
|
||||
disabled={!clarificationsInteractive}
|
||||
submitting={isIntentSending && isPending}
|
||||
onSubmit={(override) =>
|
||||
submitIntentClarifications(
|
||||
msg.id,
|
||||
clarifications,
|
||||
// 单题单选「点击即发送」时选择还没进 state map,把即时值
|
||||
// 按 key 传进去直接用。
|
||||
override ? { [key]: override } : undefined,
|
||||
)
|
||||
}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
{/* 合并提交按钮仅多问题时出现;单问题点选项即发送,无需此按钮。 */}
|
||||
{multiQuestion && clarificationsInteractive && (
|
||||
<div className="flex items-center justify-between gap-2 pt-0.5">
|
||||
<span className="text-[10px] text-slate-400">
|
||||
共 {clarifications.length} 个问题,可逐个作答后一并发送
|
||||
</span>
|
||||
<Button
|
||||
type="button"
|
||||
size="sm"
|
||||
disabled={isIntentSending}
|
||||
onClick={() => submitIntentClarifications(msg.id, clarifications)}
|
||||
className="h-8 rounded-xl px-4 text-xs font-bold"
|
||||
>
|
||||
{isIntentSending ? "发送中…" : "发送全部回答"}
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
) : (
|
||||
|
||||
Reference in new issue
Block a user