fix: update model id dropdown without refresh (#5144)

This commit is contained in:
Faisal Amir 2025-05-30 13:05:06 +07:00 committed by GitHub
parent 426dc2ab87
commit 3022fdebc2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -28,7 +28,7 @@ function ThreadDetail() {
const [isUserScrolling, setIsUserScrolling] = useState(false)
const [isAtBottom, setIsAtBottom] = useState(true)
const lastScrollTopRef = useRef(0)
const { currentThreadId, getThreadById, setCurrentThreadId } = useThreads()
const { currentThreadId, setCurrentThreadId } = useThreads()
const { setCurrentAssistant, assistants } = useAssistant()
const { setMessages } = useMessages()
const { streamingContent } = useAppState()
@ -39,10 +39,8 @@ function ThreadDetail() {
}))
)
const thread = useMemo(
() => getThreadById(threadId),
[threadId, getThreadById]
)
// Subscribe directly to the thread data to ensure updates when model changes
const thread = useThreads(useShallow((state) => state.threads[threadId]))
const scrollContainerRef = useRef<HTMLDivElement>(null)
const isFirstRender = useRef(true)
const messagesCount = useMemo(() => messages?.length ?? 0, [messages])