圆桌会商各步接入流式回答速度指示器,复用主聊天 SpeedPill 与全局开关。
新增 DialogueSpeedMeter 与 useDialogueSpeedMetrics,在 Step1/2/3 气泡底部展示 tok/s 与耗时。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
728a4b1170
commit
b58e731c19
7 files changed
+235
-2
No files matched your search
@@ -35,7 +35,10 @@ function formatFileSize(bytes: number): string {
|
||||
}
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { useLocalSettings } from "@/core/settings";
|
||||
import type { MessageMetric } from "@/components/workspace/messages/use-message-metrics";
|
||||
import { Man1Avatar, RobotAvatar } from "@/roundtable-planning/components/Avatars";
|
||||
import { DialogueSpeedMeter } from "@/roundtable-planning/components/DialogueSpeedMeter";
|
||||
import {
|
||||
clarificationKey,
|
||||
IntentClarificationCard,
|
||||
@@ -51,6 +54,7 @@ import {
|
||||
import { MessageStepsCard } from "@/roundtable-planning/components/MessageStepsCard";
|
||||
import { ScrollToBottomButton } from "@/roundtable-planning/components/ScrollToBottomButton";
|
||||
import { useAutoScroll } from "@/roundtable-planning/hooks/useAutoScroll";
|
||||
import { useDialogueSpeedMetrics } from "@/roundtable-planning/hooks/useDialogueSpeedMetrics";
|
||||
import type { InteractiveMessage } from "@/roundtable-planning/hooks/useStep1Intent";
|
||||
import { splitInlineReasoning } from "@/roundtable-planning/lib/reasoning";
|
||||
import { splitIntentReadyBlock } from "@/roundtable-planning/lib/roundtable-constants";
|
||||
@@ -108,6 +112,11 @@ export function Step1Panel(props: Step1PanelProps) {
|
||||
const { atBottom: step1AtBottom, scrollToBottom: scrollStep1ToBottom } =
|
||||
useAutoScroll(step1ScrollRef, [interactiveMessages]);
|
||||
|
||||
// 「回答速度指示器」—— 与主页面共用全局开关 streamSpeedMeterEnabled。
|
||||
const [localSettings] = useLocalSettings();
|
||||
const speedMeterEnabled = localSettings.display.streamSpeedMeterEnabled;
|
||||
const messageMetrics = useDialogueSpeedMetrics(interactiveMessages);
|
||||
|
||||
// 输入框完全是本地状态 —— 提到 Page 层会导致每次打字都重渲整页。
|
||||
const [inputText, setInputText] = useState<string>("");
|
||||
// 待发送的本地附件(点发送时连同文本一起上传)。
|
||||
@@ -165,6 +174,7 @@ export function Step1Panel(props: Step1PanelProps) {
|
||||
<Step1Message
|
||||
key={msg.id}
|
||||
msg={msg}
|
||||
metric={speedMeterEnabled ? messageMetrics.get(msg.id) : undefined}
|
||||
intentReady={intentReady}
|
||||
pendingIntentClarificationMsgId={pendingIntentClarificationMsgId}
|
||||
intentClarificationSelections={intentClarificationSelections}
|
||||
@@ -338,6 +348,11 @@ export function Step1Panel(props: Step1PanelProps) {
|
||||
*/
|
||||
interface Step1MessageProps {
|
||||
msg: InteractiveMessage;
|
||||
/**
|
||||
* 本条气泡的「回答速度」度量(tok/s + 时长)。仅对流式过的智能体发言有值;
|
||||
* 由调用方按全局开关 streamSpeedMeterEnabled 决定是否传入(关则传 undefined)。
|
||||
*/
|
||||
metric?: MessageMetric;
|
||||
intentReady: object | null;
|
||||
pendingIntentClarificationMsgId: number | null;
|
||||
intentClarificationSelections: Map<string, IntentClarificationSelection>;
|
||||
@@ -354,6 +369,7 @@ interface Step1MessageProps {
|
||||
|
||||
function Step1Message({
|
||||
msg,
|
||||
metric,
|
||||
intentReady,
|
||||
pendingIntentClarificationMsgId,
|
||||
intentClarificationSelections,
|
||||
@@ -520,6 +536,8 @@ function Step1Message({
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{metric && <DialogueSpeedMeter metric={metric} />}
|
||||
</MessageBubble>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user