fix:修复需求遗留问题:hasSubmitted变量。现在不需要通过第一次发出对话来切换欢迎页和对话页
This commit is contained in:
parent
cd4c33f3cd
commit
b7f2001914
|
|
@ -166,7 +166,6 @@ export default function AgentChatPage() {
|
||||||
threadId={threadId}
|
threadId={threadId}
|
||||||
autoFocus={isNewThread}
|
autoFocus={isNewThread}
|
||||||
showWelcomeStyle={isNewThread}
|
showWelcomeStyle={isNewThread}
|
||||||
hasSubmitted={!isNewThread}
|
|
||||||
status={
|
status={
|
||||||
thread.error
|
thread.error
|
||||||
? "error"
|
? "error"
|
||||||
|
|
|
||||||
|
|
@ -233,7 +233,6 @@ export default function ChatPage() {
|
||||||
[thread.values.artifacts],
|
[thread.values.artifacts],
|
||||||
);
|
);
|
||||||
|
|
||||||
const [hasSubmitted, setHasSubmitted] = useState(false);
|
|
||||||
const [historyCutoff, setHistoryCutoff] = useState<number | null>(null);
|
const [historyCutoff, setHistoryCutoff] = useState<number | null>(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
@ -241,7 +240,6 @@ export default function ChatPage() {
|
||||||
setHistoryCutoff(null);
|
setHistoryCutoff(null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (hasSubmitted) return;
|
|
||||||
// Welcome 态下、未提交前,把当前已有消息都当作“历史”切掉。
|
// Welcome 态下、未提交前,把当前已有消息都当作“历史”切掉。
|
||||||
// 这样即使历史消息是后续异步补齐,也不会重新露出。
|
// 这样即使历史消息是后续异步补齐,也不会重新露出。
|
||||||
setHistoryCutoff((prev) => {
|
setHistoryCutoff((prev) => {
|
||||||
|
|
@ -250,7 +248,6 @@ export default function ChatPage() {
|
||||||
return next > prev ? next : prev;
|
return next > prev ? next : prev;
|
||||||
});
|
});
|
||||||
}, [
|
}, [
|
||||||
hasSubmitted,
|
|
||||||
historyCutoff,
|
historyCutoff,
|
||||||
shouldRenderHistory,
|
shouldRenderHistory,
|
||||||
thread.isThreadLoading,
|
thread.isThreadLoading,
|
||||||
|
|
@ -322,7 +319,6 @@ export default function ChatPage() {
|
||||||
if (isNewThread && safeThreadId && !isThreadInitReady) {
|
if (isNewThread && safeThreadId && !isThreadInitReady) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setHasSubmitted(true);
|
|
||||||
if (safeThreadId && (isNewThread || showWelcomeStyle)) {
|
if (safeThreadId && (isNewThread || showWelcomeStyle)) {
|
||||||
router.replace(`/workspace/chats/${safeThreadId}?is_chatting=true`);
|
router.replace(`/workspace/chats/${safeThreadId}?is_chatting=true`);
|
||||||
}
|
}
|
||||||
|
|
@ -343,22 +339,6 @@ export default function ChatPage() {
|
||||||
await thread.stop();
|
await thread.stop();
|
||||||
}, [thread]);
|
}, [thread]);
|
||||||
|
|
||||||
const resetNewSessionState = useCallback(() => {
|
|
||||||
setIsNewThread(true);
|
|
||||||
setHasSubmitted(false);
|
|
||||||
setHistoryCutoff(null);
|
|
||||||
setArtifacts([]);
|
|
||||||
deselectArtifact();
|
|
||||||
setArtifactsOpen(false);
|
|
||||||
setArtifactsFullscreen(false);
|
|
||||||
}, [
|
|
||||||
deselectArtifact,
|
|
||||||
setArtifacts,
|
|
||||||
setArtifactsFullscreen,
|
|
||||||
setArtifactsOpen,
|
|
||||||
setIsNewThread,
|
|
||||||
]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ThreadContext.Provider value={{ threadId, thread }}>
|
<ThreadContext.Provider value={{ threadId, thread }}>
|
||||||
<div
|
<div
|
||||||
|
|
@ -379,7 +359,7 @@ export default function ChatPage() {
|
||||||
<header
|
<header
|
||||||
className={cn(
|
className={cn(
|
||||||
"bg-background absolute top-0 right-0 left-0 z-30 mx-4 grid h-[58px] shrink-0 grid-cols-3 items-center border-b transition-all duration-300 ease-in-out",
|
"bg-background absolute top-0 right-0 left-0 z-30 mx-4 grid h-[58px] shrink-0 grid-cols-3 items-center border-b transition-all duration-300 ease-in-out",
|
||||||
showWelcomeStyle && !hasSubmitted ? "hidden" : "",
|
showWelcomeStyle ? "hidden" : "",
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<div className="flex items-center justify-start overflow-hidden text-sm font-medium">
|
<div className="flex items-center justify-start overflow-hidden text-sm font-medium">
|
||||||
|
|
@ -466,16 +446,14 @@ export default function ChatPage() {
|
||||||
<main
|
<main
|
||||||
className={cn(
|
className={cn(
|
||||||
"flex min-h-0 max-w-full grow flex-col",
|
"flex min-h-0 max-w-full grow flex-col",
|
||||||
showWelcomeStyle && !hasSubmitted
|
showWelcomeStyle ? "bg-ws-surface-base" : "bg-background",
|
||||||
? "bg-ws-surface-base"
|
|
||||||
: "bg-background",
|
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<div className="flex size-full justify-center">
|
<div className="flex size-full justify-center">
|
||||||
<MessageList
|
<MessageList
|
||||||
className={cn(
|
className={cn(
|
||||||
"size-full",
|
"size-full",
|
||||||
(!showWelcomeStyle || hasSubmitted) && "pt-[58px]",
|
!showWelcomeStyle && "pt-[58px]",
|
||||||
)}
|
)}
|
||||||
threadId={threadId}
|
threadId={threadId}
|
||||||
thread={thread}
|
thread={thread}
|
||||||
|
|
@ -508,7 +486,7 @@ export default function ChatPage() {
|
||||||
<div
|
<div
|
||||||
className={cn(
|
className={cn(
|
||||||
"h-full w-full transition-transform duration-300 ease-in-out",
|
"h-full w-full transition-transform duration-300 ease-in-out",
|
||||||
showWelcomeStyle && !hasSubmitted ? "translate-x-0" : "",
|
showWelcomeStyle ? "translate-x-0" : "",
|
||||||
artifactPanelOpen ? "translate-x-0" : "translate-x-full",
|
artifactPanelOpen ? "translate-x-0" : "translate-x-full",
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
|
|
@ -570,9 +548,7 @@ export default function ChatPage() {
|
||||||
<div
|
<div
|
||||||
className={cn(
|
className={cn(
|
||||||
"pointer-events-auto relative w-full max-w-[720px]",
|
"pointer-events-auto relative w-full max-w-[720px]",
|
||||||
showWelcomeStyle &&
|
showWelcomeStyle && "-translate-y-[calc(50vh-96px)]",
|
||||||
!hasSubmitted &&
|
|
||||||
"-translate-y-[calc(50vh-96px)]",
|
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{!(showWelcomeStyle && thread.isThreadLoading) ? (
|
{!(showWelcomeStyle && thread.isThreadLoading) ? (
|
||||||
|
|
@ -581,7 +557,6 @@ export default function ChatPage() {
|
||||||
className={cn("w-full rounded-[20px] bg-ws-surface-elevated")}
|
className={cn("w-full rounded-[20px] bg-ws-surface-elevated")}
|
||||||
threadId={threadId}
|
threadId={threadId}
|
||||||
showWelcomeStyle={showWelcomeStyle}
|
showWelcomeStyle={showWelcomeStyle}
|
||||||
hasSubmitted={hasSubmitted}
|
|
||||||
autoFocus={showWelcomeStyle}
|
autoFocus={showWelcomeStyle}
|
||||||
status={
|
status={
|
||||||
thread.error
|
thread.error
|
||||||
|
|
@ -593,9 +568,7 @@ export default function ChatPage() {
|
||||||
context={settings.context}
|
context={settings.context}
|
||||||
extraHeader={
|
extraHeader={
|
||||||
<div className="flex flex-col gap-4">
|
<div className="flex flex-col gap-4">
|
||||||
{showWelcomeStyle && !hasSubmitted && (
|
{showWelcomeStyle && <Welcome mode={settings.context.mode} />}
|
||||||
<Welcome mode={settings.context.mode} />
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
disabled={
|
disabled={
|
||||||
|
|
|
||||||
|
|
@ -219,7 +219,6 @@ export function InputBox({
|
||||||
context,
|
context,
|
||||||
extraHeader,
|
extraHeader,
|
||||||
showWelcomeStyle,
|
showWelcomeStyle,
|
||||||
hasSubmitted,
|
|
||||||
initialValue,
|
initialValue,
|
||||||
onContextChange,
|
onContextChange,
|
||||||
onSubmit,
|
onSubmit,
|
||||||
|
|
@ -238,7 +237,6 @@ export function InputBox({
|
||||||
};
|
};
|
||||||
extraHeader?: React.ReactNode;
|
extraHeader?: React.ReactNode;
|
||||||
showWelcomeStyle: boolean;
|
showWelcomeStyle: boolean;
|
||||||
hasSubmitted?: boolean;
|
|
||||||
initialValue?: string;
|
initialValue?: string;
|
||||||
onContextChange?: (
|
onContextChange?: (
|
||||||
context: Omit<
|
context: Omit<
|
||||||
|
|
@ -294,14 +292,13 @@ export function InputBox({
|
||||||
const [isInputToolsTourReady, setIsInputToolsTourReady] = useState(false);
|
const [isInputToolsTourReady, setIsInputToolsTourReady] = useState(false);
|
||||||
const { data: referenceFilesData } = useReferenceFiles(threadIdFromProps);
|
const { data: referenceFilesData } = useReferenceFiles(threadIdFromProps);
|
||||||
|
|
||||||
// isNewThread 时禁用收缩,始终保持展开(除非已提交消息)
|
// Welcome 态下禁用收缩,始终保持展开
|
||||||
const effectiveIsFocused =
|
const effectiveIsFocused = (showWelcomeStyle ?? false) || isFocused;
|
||||||
((showWelcomeStyle ?? false) && !hasSubmitted) || isFocused;
|
|
||||||
const shouldShowSuggestionList =
|
const shouldShowSuggestionList =
|
||||||
showWelcomeStyle && !hasSubmitted && searchParams.get("mode") !== "skill";
|
showWelcomeStyle && searchParams.get("mode") !== "skill";
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!showWelcomeStyle || hasSubmitted) {
|
if (!showWelcomeStyle) {
|
||||||
setIsInputToolsTourReady(false);
|
setIsInputToolsTourReady(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -318,14 +315,13 @@ export function InputBox({
|
||||||
return () => window.cancelAnimationFrame(frameId);
|
return () => window.cancelAnimationFrame(frameId);
|
||||||
}, [
|
}, [
|
||||||
showWelcomeStyle,
|
showWelcomeStyle,
|
||||||
hasSubmitted,
|
|
||||||
shouldShowSuggestionList,
|
shouldShowSuggestionList,
|
||||||
iframeSkill.isBootstrapping,
|
iframeSkill.isBootstrapping,
|
||||||
iframeSkill.selectedSkills.length,
|
iframeSkill.selectedSkills.length,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!showWelcomeStyle || hasSubmitted || !isInputToolsTourReady) {
|
if (!showWelcomeStyle || !isInputToolsTourReady) {
|
||||||
setIsInputToolsTourOpen(false);
|
setIsInputToolsTourOpen(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -337,7 +333,7 @@ export function InputBox({
|
||||||
if (!hasSeenTourForCurrentThread) {
|
if (!hasSeenTourForCurrentThread) {
|
||||||
setIsInputToolsTourOpen(true);
|
setIsInputToolsTourOpen(true);
|
||||||
}
|
}
|
||||||
}, [showWelcomeStyle, hasSubmitted, isInputToolsTourReady, threadId]);
|
}, [showWelcomeStyle, isInputToolsTourReady, threadId]);
|
||||||
|
|
||||||
const finishInputToolsTour = useCallback(() => {
|
const finishInputToolsTour = useCallback(() => {
|
||||||
const seenState = parseInputToolsTourSeenState(
|
const seenState = parseInputToolsTourSeenState(
|
||||||
|
|
@ -817,7 +813,6 @@ export function InputBox({
|
||||||
"border-0 rounded-[20px] backdrop-blur-sm",
|
"border-0 rounded-[20px] backdrop-blur-sm",
|
||||||
"transition-[height] duration-300 ease-out shadow-none ",
|
"transition-[height] duration-300 ease-out shadow-none ",
|
||||||
!showWelcomeStyle && "h-[200px] shadow-[0_0_20px_0_rgba(0,0,0,0.10)]",
|
!showWelcomeStyle && "h-[200px] shadow-[0_0_20px_0_rgba(0,0,0,0.10)]",
|
||||||
hasSubmitted && "shadow-[0_0_20px_0_rgba(0,0,0,0.10)]!",
|
|
||||||
effectiveIsFocused ? "h-[200px]" : "h-[80px]",
|
effectiveIsFocused ? "h-[200px]" : "h-[80px]",
|
||||||
)}
|
)}
|
||||||
disabled={isInputDisabled}
|
disabled={isInputDisabled}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue