Skip to content

Commit

Permalink
fix: create new thread with default assistant
Browse files Browse the repository at this point in the history
  • Loading branch information
louis-jan committed Dec 19, 2024
1 parent bdcc3ef commit 4cd0e63
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 14 deletions.
12 changes: 3 additions & 9 deletions web/helpers/atoms/Assistant.atom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,9 @@ 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 = atom(
(get) => get(cachedAssistantAtom) ?? get(assistantsAtom)[0],
(_get, set, newAssistant: ThreadAssistantInfo) => {
set(cachedAssistantAtom, newAssistant)
}
)
export const activeAssistantAtom = atomWithStorage<
ThreadAssistantInfo | undefined
>('activeAssistant', undefined, undefined, { getOnInit: true })
4 changes: 1 addition & 3 deletions web/screens/Thread/ThreadCenterPanel/TextMessage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,7 @@ const MessageContainer: React.FC<
>
{isUser
? props.role
: 'assistant_name' in activeAssistant
? activeAssistant?.assistant_name
: props.role}
: (activeAssistant?.assistant_name ?? props.role)}
</div>
<p className="text-xs font-medium text-gray-400">
{props.created_at && displayDate(props.created_at ?? new Date())}
Expand Down
5 changes: 3 additions & 2 deletions web/screens/Thread/ThreadLeftPanel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ const ThreadLeftPanel = () => {
useEffect(() => {
if (
threadDataReady &&
activeAssistant &&
assistants.length > 0 &&
threads.length === 0 &&
downloadedModels.length > 0
Expand All @@ -81,7 +80,9 @@ const ThreadLeftPanel = () => {
)
const selectedModel = model[0] || recommendedModel
requestCreateNewThread(

Check warning on line 82 in web/screens/Thread/ThreadLeftPanel/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

81-82 lines are not covered with tests
{ ...assistants[0], ...activeAssistant },
activeAssistant
? { ...assistants[0], ...activeAssistant }
: assistants[0],
selectedModel
)
} else if (threadDataReady && !activeThreadId) {
Expand Down

0 comments on commit 4cd0e63

Please sign in to comment.