Skip to content

Commit 3130dd1

Browse files
authored
Merge pull request #229 from Azure-Samples/gk/autogen-nb
fix bug to randomly select chat id on initial page load
2 parents acdbabb + c5037bd commit 3130dd1

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

ui/typescript/src/components/chat/chat-session-list.tsx

+5-4
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,13 @@ export function ChatSessionList({ className, setSelectedSession: updateSelectedS
2828

2929
// Set the first session as selected
3030
if (data.length > 0) {
31-
const mostRecentChatSession = data[0];
32-
setSelectedSession(mostRecentChatSession);
33-
await fetchChatMessages(mostRecentChatSession.id);
31+
const randomIndex = Math.floor(Math.random() * data.length);
32+
const randomChatSession = data[randomIndex];
33+
setSelectedSession(randomChatSession);
34+
await fetchChatMessages(randomChatSession.id);
3435
setUserInfoAtom((prevUserInfo: UserInfoProps) => ({
3536
...prevUserInfo,
36-
chatId: mostRecentChatSession.id,
37+
chatId: randomChatSession.id,
3738
}));
3839
}
3940
}

ui/typescript/src/layouts/sidebar/chat-blade.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ export default function Sidebar({ className, setSelectedSession, setUserInfoAtom
199199
</span>
200200
<Input
201201
type="text"
202-
placeholder="Ask Miyagi"
202+
placeholder="Chat throttled in demo mode"
203203
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"
204204
value={userInput}
205205
onChange={handleInputChange}

0 commit comments

Comments
 (0)