代码提交

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

@@ -1,8 +1,16 @@
import type { ComponentProps } from "react";
import { useEffect, useRef, type ComponentProps } from "react";
import { InputBox } from "@/components/workspace/input-box";
import { usePromptInputController } from "@/components/ai-elements/prompt-input";
import { cn } from "@/lib/utils";
type PositionAgentInputProps = ComponentProps<typeof InputBox> & {
/** Stable node/builtin key used to restore the matching SQL-backed draft. */
draftKey?: string;
draftValue?: string;
onDraftChange?: (value: string) => void;
};
/**
* 岗位会商的岗位智能体输入框。
*
@@ -11,8 +19,38 @@ import { cn } from "@/lib/utils";
*/
export function PositionAgentInput({
className,
draftKey = "",
draftValue = "",
onDraftChange,
...props
}: ComponentProps<typeof InputBox>) {
}: PositionAgentInputProps) {
const { textInput } = usePromptInputController();
const activeDraftKeyRef = useRef("");
const restoringValueRef = useRef<string | null>(null);
const textInputRef = useRef(textInput);
textInputRef.current = textInput;
useEffect(() => {
activeDraftKeyRef.current = draftKey;
if (textInputRef.current.value !== draftValue) {
restoringValueRef.current = draftValue;
textInputRef.current.setInput(draftValue);
} else {
restoringValueRef.current = null;
}
}, [draftKey, draftValue]);
useEffect(() => {
if (activeDraftKeyRef.current !== draftKey) return;
if (restoringValueRef.current !== null) {
if (textInput.value === restoringValueRef.current) {
restoringValueRef.current = null;
}
return;
}
onDraftChange?.(textInput.value);
}, [draftKey, onDraftChange, textInput.value]);
// Keep the page-specific class on the wrapper rather than adding a variant
// to InputBox. Node chat and built-in chat can evolve together while every
// other workspace keeps the global composer untouched.