fix:修复需求遗留问题:hasSubmitted变量。现在不需要通过第一次发出对话来切换欢迎页和对话页

This commit is contained in:
肖应宇 2026-05-07 10:17:34 +08:00
parent cd4c33f3cd
commit b7f2001914
3 changed files with 12 additions and 45 deletions

View File

@ -166,7 +166,6 @@ export default function AgentChatPage() {
threadId={threadId}
autoFocus={isNewThread}
showWelcomeStyle={isNewThread}
hasSubmitted={!isNewThread}
status={
thread.error
? "error"

View File

@ -233,7 +233,6 @@ export default function ChatPage() {
[thread.values.artifacts],
);
const [hasSubmitted, setHasSubmitted] = useState(false);
const [historyCutoff, setHistoryCutoff] = useState<number | null>(null);
useEffect(() => {
@ -241,7 +240,6 @@ export default function ChatPage() {
setHistoryCutoff(null);
return;
}
if (hasSubmitted) return;
// Welcome 态下、未提交前,把当前已有消息都当作“历史”切掉。
// 这样即使历史消息是后续异步补齐,也不会重新露出。
setHistoryCutoff((prev) => {
@ -250,7 +248,6 @@ export default function ChatPage() {
return next > prev ? next : prev;
});
}, [
hasSubmitted,
historyCutoff,
shouldRenderHistory,
thread.isThreadLoading,
@ -322,7 +319,6 @@ export default function ChatPage() {
if (isNewThread && safeThreadId && !isThreadInitReady) {
return;
}
setHasSubmitted(true);
if (safeThreadId && (isNewThread || showWelcomeStyle)) {
router.replace(`/workspace/chats/${safeThreadId}?is_chatting=true`);
}
@ -343,22 +339,6 @@ export default function ChatPage() {
await thread.stop();
}, [thread]);
const resetNewSessionState = useCallback(() => {
setIsNewThread(true);
setHasSubmitted(false);
setHistoryCutoff(null);
setArtifacts([]);
deselectArtifact();
setArtifactsOpen(false);
setArtifactsFullscreen(false);
}, [
deselectArtifact,
setArtifacts,
setArtifactsFullscreen,
setArtifactsOpen,
setIsNewThread,
]);
return (
<ThreadContext.Provider value={{ threadId, thread }}>
<div
@ -379,7 +359,7 @@ export default function ChatPage() {
<header
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",
showWelcomeStyle && !hasSubmitted ? "hidden" : "",
showWelcomeStyle ? "hidden" : "",
)}
>
<div className="flex items-center justify-start overflow-hidden text-sm font-medium">
@ -466,16 +446,14 @@ export default function ChatPage() {
<main
className={cn(
"flex min-h-0 max-w-full grow flex-col",
showWelcomeStyle && !hasSubmitted
? "bg-ws-surface-base"
: "bg-background",
showWelcomeStyle ? "bg-ws-surface-base" : "bg-background",
)}
>
<div className="flex size-full justify-center">
<MessageList
className={cn(
"size-full",
(!showWelcomeStyle || hasSubmitted) && "pt-[58px]",
!showWelcomeStyle && "pt-[58px]",
)}
threadId={threadId}
thread={thread}
@ -508,7 +486,7 @@ export default function ChatPage() {
<div
className={cn(
"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",
)}
>
@ -570,9 +548,7 @@ export default function ChatPage() {
<div
className={cn(
"pointer-events-auto relative w-full max-w-[720px]",
showWelcomeStyle &&
!hasSubmitted &&
"-translate-y-[calc(50vh-96px)]",
showWelcomeStyle && "-translate-y-[calc(50vh-96px)]",
)}
>
{!(showWelcomeStyle && thread.isThreadLoading) ? (
@ -581,7 +557,6 @@ export default function ChatPage() {
className={cn("w-full rounded-[20px] bg-ws-surface-elevated")}
threadId={threadId}
showWelcomeStyle={showWelcomeStyle}
hasSubmitted={hasSubmitted}
autoFocus={showWelcomeStyle}
status={
thread.error
@ -593,9 +568,7 @@ export default function ChatPage() {
context={settings.context}
extraHeader={
<div className="flex flex-col gap-4">
{showWelcomeStyle && !hasSubmitted && (
<Welcome mode={settings.context.mode} />
)}
{showWelcomeStyle && <Welcome mode={settings.context.mode} />}
</div>
}
disabled={

View File

@ -219,7 +219,6 @@ export function InputBox({
context,
extraHeader,
showWelcomeStyle,
hasSubmitted,
initialValue,
onContextChange,
onSubmit,
@ -238,7 +237,6 @@ export function InputBox({
};
extraHeader?: React.ReactNode;
showWelcomeStyle: boolean;
hasSubmitted?: boolean;
initialValue?: string;
onContextChange?: (
context: Omit<
@ -294,14 +292,13 @@ export function InputBox({
const [isInputToolsTourReady, setIsInputToolsTourReady] = useState(false);
const { data: referenceFilesData } = useReferenceFiles(threadIdFromProps);
// isNewThread 时禁用收缩,始终保持展开(除非已提交消息)
const effectiveIsFocused =
((showWelcomeStyle ?? false) && !hasSubmitted) || isFocused;
// Welcome 态下禁用收缩,始终保持展开
const effectiveIsFocused = (showWelcomeStyle ?? false) || isFocused;
const shouldShowSuggestionList =
showWelcomeStyle && !hasSubmitted && searchParams.get("mode") !== "skill";
showWelcomeStyle && searchParams.get("mode") !== "skill";
useEffect(() => {
if (!showWelcomeStyle || hasSubmitted) {
if (!showWelcomeStyle) {
setIsInputToolsTourReady(false);
return;
}
@ -318,14 +315,13 @@ export function InputBox({
return () => window.cancelAnimationFrame(frameId);
}, [
showWelcomeStyle,
hasSubmitted,
shouldShowSuggestionList,
iframeSkill.isBootstrapping,
iframeSkill.selectedSkills.length,
]);
useEffect(() => {
if (!showWelcomeStyle || hasSubmitted || !isInputToolsTourReady) {
if (!showWelcomeStyle || !isInputToolsTourReady) {
setIsInputToolsTourOpen(false);
return;
}
@ -337,7 +333,7 @@ export function InputBox({
if (!hasSeenTourForCurrentThread) {
setIsInputToolsTourOpen(true);
}
}, [showWelcomeStyle, hasSubmitted, isInputToolsTourReady, threadId]);
}, [showWelcomeStyle, isInputToolsTourReady, threadId]);
const finishInputToolsTour = useCallback(() => {
const seenState = parseInputToolsTourSeenState(
@ -817,7 +813,6 @@ export function InputBox({
"border-0 rounded-[20px] backdrop-blur-sm",
"transition-[height] duration-300 ease-out shadow-none ",
!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]",
)}
disabled={isInputDisabled}