fix(frontend): hide history reliably in welcome mode

This commit is contained in:
肖应宇 2026-04-09 13:12:08 +08:00
parent 883dd58275
commit 0a619f6603
1 changed files with 13 additions and 5 deletions

View File

@ -135,10 +135,16 @@ export default function ChatPage() {
setHistoryCutoff(null); setHistoryCutoff(null);
return; return;
} }
if (historyCutoff === null && !thread.isThreadLoading) { if (hasSubmitted) return;
setHistoryCutoff(thread.messages.length); // Welcome 态下、未提交前,把当前已有消息都当作“历史”切掉。
} // 这样即使历史消息是后续异步补齐,也不会重新露出。
setHistoryCutoff((prev) => {
const next = thread.messages.length;
if (prev === null) return next;
return next > prev ? next : prev;
});
}, [ }, [
hasSubmitted,
historyCutoff, historyCutoff,
shouldRenderHistory, shouldRenderHistory,
thread.isThreadLoading, thread.isThreadLoading,
@ -331,9 +337,11 @@ export default function ChatPage() {
threadId={threadId} threadId={threadId}
thread={thread} thread={thread}
messagesOverride={ messagesOverride={
shouldRenderHistory || historyCutoff === null shouldRenderHistory
? undefined ? undefined
: thread.messages.slice(historyCutoff) : historyCutoff === null
? []
: thread.messages.slice(historyCutoff)
} }
paddingBottom={todoListCollapsed ? 160 : 280} paddingBottom={todoListCollapsed ? 160 : 280}
showScrollToBottomButton={!showWelcomeStyle} showScrollToBottomButton={!showWelcomeStyle}