From 4f10b9a60faa94ccb9de440e65a0310192496b29 Mon Sep 17 00:00:00 2001 From: Yidadaa Date: Sat, 11 Mar 2023 16:24:17 +0800 Subject: [PATCH] fix: new session should insert at top --- app/components/home.tsx | 7 +++++-- app/store.ts | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/components/home.tsx b/app/components/home.tsx index c09de3d62..2602df540 100644 --- a/app/components/home.tsx +++ b/app/components/home.tsx @@ -130,11 +130,14 @@ export function Chat() { ); useEffect(() => { - latestMessageRef.current?.scrollIntoView(false); + latestMessageRef.current?.scrollIntoView({ + behavior: "smooth", + block: "end", + }); }); return ( -
+
{session.topic}
diff --git a/app/store.ts b/app/store.ts index e49c0f9c5..f230df23a 100644 --- a/app/store.ts +++ b/app/store.ts @@ -106,8 +106,8 @@ export const useChatStore = create()( newSession() { set((state) => ({ - currentSessionIndex: state.sessions.length, - sessions: state.sessions.concat([createEmptySession()]), + currentSessionIndex: 0, + sessions: [createEmptySession()].concat(state.sessions), })); },