From b2825ac1f61d5f7eb82a74a1be4cc06e2359c74e Mon Sep 17 00:00:00 2001 From: dinhlongviolin1 Date: Thu, 30 Oct 2025 23:26:25 +0700 Subject: [PATCH] fix test --- .../containers/ThreadScrollBehaviorSwitcher.tsx | 17 +++++++++++++---- web-app/src/hooks/useInterfaceSettings.ts | 15 ++++++++++----- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/web-app/src/containers/ThreadScrollBehaviorSwitcher.tsx b/web-app/src/containers/ThreadScrollBehaviorSwitcher.tsx index 41cf16dab..c0ba284fa 100644 --- a/web-app/src/containers/ThreadScrollBehaviorSwitcher.tsx +++ b/web-app/src/containers/ThreadScrollBehaviorSwitcher.tsx @@ -100,6 +100,9 @@ const FLOW_HISTORY_FRAMES = [ { id: 'history-3', widths: ['70%', '52%'] }, ] as const +const createFlowHistoryFrames = () => + Array.from(FLOW_HISTORY_FRAMES, (frame) => ({ ...frame })) + const FLOW_TYPING_TEXT = 'Jan, help me summarize this' // Mirror Flow's history reveal timing so the typing cadence stays aligned. const STICKY_USER_MESSAGE_DELAY = @@ -114,7 +117,7 @@ function FlowScrollPreview({ placeholder }: { placeholder: string }) { const [streamProgress, setStreamProgress] = useState(0) const [historyMessages, setHistoryMessages] = useState< Array<{ id: string; widths: readonly string[] }> - >(FLOW_HISTORY_FRAMES) + >(createFlowHistoryFrames) const [exitingHistoryIds, setExitingHistoryIds] = useState([]) const [userMessageVisible, setUserMessageVisible] = useState(false) const [streamStage, setStreamStage] = useState<'idle' | 'streaming' | 'complete'>('idle') @@ -138,7 +141,7 @@ function FlowScrollPreview({ placeholder }: { placeholder: string }) { timersRef.current = [] if (step === 0) { - setHistoryMessages(FLOW_HISTORY_FRAMES) + setHistoryMessages(createFlowHistoryFrames()) setExitingHistoryIds([]) setTypedText('') setSentMessage('') @@ -305,7 +308,13 @@ function StickyScrollPreview({ placeholder }: { placeholder: string }) { const [typedText, setTypedText] = useState('') const [messages, setMessages] = useState< Array<{ id: string; type: 'assistant' | 'user'; widths: readonly string[] }> - >(FLOW_HISTORY_FRAMES.map((frame) => ({ ...frame, type: 'assistant' }))) + >( + () => + createFlowHistoryFrames().map((frame) => ({ + ...frame, + type: 'assistant' as const, + })) + ) const [exitingIds, setExitingIds] = useState([]) const exitingIdsRef = useRef(exitingIds) const timersRef = useRef([]) @@ -321,7 +330,7 @@ function StickyScrollPreview({ placeholder }: { placeholder: string }) { if (step === 0) { setMessages( - FLOW_HISTORY_FRAMES.map((frame) => ({ + createFlowHistoryFrames().map((frame) => ({ ...frame, type: 'assistant' as const, })) diff --git a/web-app/src/hooks/useInterfaceSettings.ts b/web-app/src/hooks/useInterfaceSettings.ts index de5943812..ed765160d 100644 --- a/web-app/src/hooks/useInterfaceSettings.ts +++ b/web-app/src/hooks/useInterfaceSettings.ts @@ -224,16 +224,21 @@ const validatePersistedSnapshot = (value: string): string | null => { } if (parsed && typeof parsed === 'object' && parsed.state) { - const draft = { ...parsed } + const state = parsed.state + if ( !isThreadScrollBehavior( - draft.state.threadScrollBehavior as ThreadScrollBehavior + state.threadScrollBehavior as ThreadScrollBehavior ) ) { - draft.state = { - ...draft.state, - threadScrollBehavior: DEFAULT_THREAD_SCROLL_BEHAVIOR, + const draft = { + ...parsed, + state: { + ...state, + threadScrollBehavior: DEFAULT_THREAD_SCROLL_BEHAVIOR, + }, } + return JSON.stringify(draft) } return value