代码提交

This commit is contained in:
董宏凯 committed 2026-07-24 10:33:28 +08:00
1 parent f49def09ea
commit 45df500a9c
55 files changed
+3390 -461

No files matched your search

@@ -11,7 +11,7 @@
* **不要**在这里再 fetch / 建 thread / 跑 SSE —— 这些逻辑都在 `useStep1Intent`,
* 本组件保持纯展示 + 透传事件。
*/
import { useRef, useState } from "react";
import { useCallback, useEffect, useRef, useState } from "react";
import {
CheckCircle,
FileText,
@@ -128,6 +128,10 @@ export interface Step1PanelProps {
* 统一管理,因此岗位会商定制样式时不会分叉或复制 Step 1 的业务逻辑。
*/
inputArea?: (props: Step1InputAreaProps) => React.ReactNode;
/** Optional database-backed composer state used by the position workspace. */
inputDraftKey?: string;
initialInputText?: string;
onInputTextChange?: (value: string) => void;
onManualSave: () => void;
onTriggerToast: (msg: string) => void;
submitIntentClarifications: (
@@ -157,14 +161,20 @@ export function Step1Panel(props: Step1PanelProps) {
footerAction,
hideEnterRoundtable = false,
inputArea,
inputDraftKey,
initialInputText = "",
onInputTextChange,
onManualSave,
onTriggerToast,
submitIntentClarifications,
} = props;
const step1ScrollRef = useRef<HTMLDivElement>(null);
const step1ContentRef = useRef<HTMLDivElement>(null);
const { atBottom: step1AtBottom, scrollToBottom: scrollStep1ToBottom } =
useAutoScroll(step1ScrollRef, [interactiveMessages]);
useAutoScroll(step1ScrollRef, [interactiveMessages], {
contentRef: step1ContentRef,
});
// 「回答速度指示器」—— 与主页面共用全局开关 streamSpeedMeterEnabled。
const [localSettings] = useLocalSettings();
@@ -173,6 +183,16 @@ export function Step1Panel(props: Step1PanelProps) {
// 输入框完全是本地状态 —— 提到 Page 层会导致每次打字都重渲整页。
const [inputText, setInputText] = useState<string>("");
useEffect(() => {
setInputText(initialInputText);
}, [inputDraftKey, initialInputText]);
const handleInputTextChange = useCallback(
(value: string) => {
setInputText(value);
onInputTextChange?.(value);
},
[onInputTextChange],
);
// 待发送的本地附件(点发送时连同文本一起上传)。
const [attachedFiles, setAttachedFiles] = useState<File[]>([]);
const fileInputRef = useRef<HTMLInputElement>(null);
@@ -202,7 +222,7 @@ export function Step1Panel(props: Step1PanelProps) {
const handleSend = () => {
if (!inputText.trim() && attachedFiles.length === 0) return;
onSendMessage(inputText, attachedFiles.length > 0 ? attachedFiles : undefined);
setInputText("");
handleInputTextChange("");
setAttachedFiles([]);
};
@@ -234,21 +254,23 @@ export function Step1Panel(props: Step1PanelProps) {
<div
ref={step1ScrollRef}
// overflow-x-hidden:消息列表只竖向滚(见 Step2Panel 同处注释),避免误触横向拖动抢滑块。
className="flex-1 min-h-0 overflow-y-auto overflow-x-hidden p-6 space-y-4 bg-white"
className="flex-1 min-h-0 overflow-y-auto overflow-x-hidden bg-white"
>
{interactiveMessages.map((msg) => (
<Step1Message
key={msg.id}
msg={msg}
metric={speedMeterEnabled ? messageMetrics.get(msg.id) : undefined}
intentReady={intentReady}
pendingIntentClarificationMsgId={pendingIntentClarificationMsgId}
intentClarificationSelections={intentClarificationSelections}
setIntentClarificationSelections={setIntentClarificationSelections}
isIntentSending={isIntentSending}
submitIntentClarifications={submitIntentClarifications}
/>
))}
<div ref={step1ContentRef} className="space-y-4 p-6">
{interactiveMessages.map((msg) => (
<Step1Message
key={msg.id}
msg={msg}
metric={speedMeterEnabled ? messageMetrics.get(msg.id) : undefined}
intentReady={intentReady}
pendingIntentClarificationMsgId={pendingIntentClarificationMsgId}
intentClarificationSelections={intentClarificationSelections}
setIntentClarificationSelections={setIntentClarificationSelections}
isIntentSending={isIntentSending}
submitIntentClarifications={submitIntentClarifications}
/>
))}
</div>
</div>
{!step1AtBottom && <ScrollToBottomButton onClick={scrollStep1ToBottom} />}
</div>
@@ -257,7 +279,7 @@ export function Step1Panel(props: Step1PanelProps) {
{inputArea ? (
inputArea({
value: inputText,
onValueChange: setInputText,
onValueChange: handleInputTextChange,
attachedFiles,
onAddFiles: addAttachedFiles,
onRemoveFile: removeAttachedFile,