diff --git a/src/components/chat-view/Chat.tsx b/src/components/chat-view/Chat.tsx index 8d78ab7..13c83d5 100644 --- a/src/components/chat-view/Chat.tsx +++ b/src/components/chat-view/Chat.tsx @@ -545,6 +545,7 @@ const Chat = forwardRef((props, ref) => { { if (conversationId === currentConversationId) return await handleLoadConversation(conversationId) diff --git a/src/components/chat-view/ChatListDropdown.tsx b/src/components/chat-view/ChatListDropdown.tsx index b8be2d0..2628c80 100644 --- a/src/components/chat-view/ChatListDropdown.tsx +++ b/src/components/chat-view/ChatListDropdown.tsx @@ -108,6 +108,7 @@ function ChatListItem({ export function ChatListDropdown({ chatList, + currentConversationId, onSelect, onDelete, onUpdateTitle, @@ -115,6 +116,7 @@ export function ChatListDropdown({ children, }: { chatList: ChatConversationMeta[] + currentConversationId: string onSelect: (conversationId: string) => Promise onDelete: (conversationId: string) => Promise onUpdateTitle: (conversationId: string, newTitle: string) => Promise @@ -127,7 +129,10 @@ export function ChatListDropdown({ useEffect(() => { if (open) { - setFocusedIndex(0) + const currentIndex = chatList.findIndex( + (chat) => chat.id === currentConversationId, + ) + setFocusedIndex(currentIndex === -1 ? 0 : currentIndex) setEditingId(null) } }, [open]) @@ -171,8 +176,8 @@ export function ChatListDropdown({ setFocusedIndex(index) }} onSelect={async () => { - setEditingId(null) await onSelect(chat.id) + setOpen(false) }} onDelete={async () => { await onDelete(chat.id)