Skip to content

Commit

Permalink
fix: new thread isn't automatically created on factory reset
Browse files Browse the repository at this point in the history
  • Loading branch information
louis-jan committed Dec 19, 2024
1 parent 643c727 commit 4324773
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions web/helpers/atoms/Assistant.atom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@ import { atomWithStorage } from 'jotai/utils'

export const assistantsAtom = atom<Assistant[]>([])

export const cachedAssistantAtom = atomWithStorage<
ThreadAssistantInfo | undefined
>('activeAssistant', undefined, undefined, { getOnInit: true })
/**
* Get the current active assistant
*/
export const activeAssistantAtom = atomWithStorage<
ThreadAssistantInfo | undefined
>('activeAssistant', undefined, undefined, { getOnInit: true })
export const activeAssistantAtom = atom(
(get) => get(cachedAssistantAtom) ?? get(assistantsAtom)[0],
(_get, set, newAssistant: ThreadAssistantInfo) => {
set(cachedAssistantAtom, newAssistant)
}
)

0 comments on commit 4324773

Please sign in to comment.