Skip to content

Commit

Permalink
fix bug to randomly select chat id on initial page load
Browse files Browse the repository at this point in the history
  • Loading branch information
thegovind committed May 27, 2024
1 parent 360f5de commit c5037bd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions ui/typescript/src/components/chat/chat-session-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ export function ChatSessionList({ className, setSelectedSession: updateSelectedS

// Set the first session as selected
if (data.length > 0) {
const mostRecentChatSession = data[0];
setSelectedSession(mostRecentChatSession);
await fetchChatMessages(mostRecentChatSession.id);
const randomIndex = Math.floor(Math.random() * data.length);
const randomChatSession = data[randomIndex];
setSelectedSession(randomChatSession);
await fetchChatMessages(randomChatSession.id);
setUserInfoAtom((prevUserInfo: UserInfoProps) => ({
...prevUserInfo,
chatId: mostRecentChatSession.id,
chatId: randomChatSession.id,
}));
}
}
Expand Down
2 changes: 1 addition & 1 deletion ui/typescript/src/layouts/sidebar/chat-blade.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ export default function Sidebar({ className, setSelectedSession, setUserInfoAtom
</span>
<Input
type="text"
placeholder="Ask Miyagi"
placeholder="Chat throttled in demo mode"
className="w-full dark:bg-dark/60 focus:outline-none focus:placeholder-gray-400 text-gray-600 placeholder-gray-600 pl-12 bg-gray-200 rounded-md py-3"
value={userInput}
onChange={handleInputChange}
Expand Down

0 comments on commit c5037bd

Please sign in to comment.