fix: new thread isn't automatically created on factory reset

This commit is contained in:
Louis 2024-12-19 10:32:35 +07:00
parent 643c7276b5
commit 432477341c
No known key found for this signature in database
GPG Key ID: 44FA9F4D33C37DE2

View File

@ -4,9 +4,15 @@ import { atomWithStorage } from 'jotai/utils'
export const assistantsAtom = atom<Assistant[]>([]) export const assistantsAtom = atom<Assistant[]>([])
export const cachedAssistantAtom = atomWithStorage<
ThreadAssistantInfo | undefined
>('activeAssistant', undefined, undefined, { getOnInit: true })
/** /**
* Get the current active assistant * Get the current active assistant
*/ */
export const activeAssistantAtom = atomWithStorage< export const activeAssistantAtom = atom(
ThreadAssistantInfo | undefined (get) => get(cachedAssistantAtom) ?? get(assistantsAtom)[0],
>('activeAssistant', undefined, undefined, { getOnInit: true }) (_get, set, newAssistant: ThreadAssistantInfo) => {
set(cachedAssistantAtom, newAssistant)
}
)