Skip to content

Commit bfd0791

Browse files
NirajC-MicrosoftRoopan-MicrosoftAjitPadhi-MicrosoftPavan-Microsoftross-p-smith
authored
chore: Dev to main (#2024)
Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Roopan-Microsoft <168007406+Roopan-Microsoft@users.noreply.github.com> Co-authored-by: Ajit Padhi <v-padhiajit@microsoft.com> Co-authored-by: Roopan P M <v-roopanpm@microsoft.com> Co-authored-by: Pavan-Microsoft <v-kupavan@microsoft.com> Co-authored-by: Ross Smith <ross-p-smith@users.noreply.github.com> Co-authored-by: gpickett <122489228+gpickett@users.noreply.github.com> Co-authored-by: Francia Riesco <friesco@microsoft.com> Co-authored-by: Francia Riesco <Fr4nc3@users.noreply.github.com> Co-authored-by: Prajwal D C <v-dcprajwal@microsoft.com> Co-authored-by: Harmanpreet-Microsoft <v-harmanprka@microsoft.com> Co-authored-by: UtkarshMishra-Microsoft <v-utkamishra@microsoft.com> Co-authored-by: Priyanka-Microsoft <v-prisinghal@microsoft.com> Co-authored-by: Prasanjeet-Microsoft <v-singhprasa@microsoft.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Kiran-Siluveru-Microsoft <v-ksiluveru@microsoft.com> Co-authored-by: Prashant-Microsoft <v-pmalusare@microsoft.com> Co-authored-by: Rohini-Microsoft <v-rwalunj@microsoft.com> Co-authored-by: Avijit-Microsoft <v-aghorui@microsoft.com> Co-authored-by: RaviKiran-Microsoft <v-ravikirans@microsoft.com> Co-authored-by: Somesh Joshi <v-somejoshi@microsoft.com> Co-authored-by: Himanshi Agrawal <v-himagrawal@microsoft.com> Co-authored-by: pradeepjha-microsoft <v-pradeepjha@microsoft.com> Co-authored-by: Harmanpreet Kaur <v-harmanpkau@microsoft.com> Co-authored-by: Bangarraju-Microsoft <v-golib@microsoft.com> Co-authored-by: Harsh-Microsoft <v-hbangera@microsoft.com> Co-authored-by: Kanchan-Microsoft <v-knagshetti@microsoft.com> Co-authored-by: Cristopher Coronado <cristofima@hotmail.com> Co-authored-by: Cristopher Coronado Moreira <crcorona@pichincha.com> Co-authored-by: Vamshi-Microsoft <v-vamolla@microsoft.com> Co-authored-by: Thanusree-Microsoft <168087422+Thanusree-Microsoft@users.noreply.github.com> Co-authored-by: Rohini-Microsoft <168007985+Rohini-Microsoft@users.noreply.github.com> Co-authored-by: Kingshuk-Microsoft <v-kidatta@microsoft.com> Co-authored-by: Ayaz-Microsoft <v-ayazkhan@microsoft.com> Co-authored-by: Abdul-Microsoft <v-amujeebta@microsoft.com> Co-authored-by: Prekshith-Microsoft <v-pdj@microsoft.com> Co-authored-by: Rafi-Microsoft <v-rafmd@microsoft.com>
1 parent f5e7366 commit bfd0791

File tree

7 files changed

+191
-4
lines changed

7 files changed

+191
-4
lines changed

code/frontend/src/components/Answer/Answer.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,14 @@ export const Answer = ({
129129
}
130130
}, [isActive, synthesizer]);
131131

132+
useEffect(() => {
133+
return () => {
134+
if (isSpeaking) {
135+
resetSpeech();
136+
}
137+
};
138+
}, []);
139+
132140
useEffect(() => {
133141
setChevronIsExpanded(isRefAccordionOpen);
134142
// if (chevronIsExpanded && refContainer.current) {
@@ -221,7 +229,7 @@ export const Answer = ({
221229
const handleSpeakPauseResume = () => {
222230
if (isSpeaking) {
223231
if (isPaused) {
224-
onSpeak(index, "speak");
232+
onSpeak(index, "speak", resetSpeech);
225233
audioDestination?.resume();
226234
setIsPaused(false);
227235
setStartTime(Date.now());
@@ -238,7 +246,7 @@ export const Answer = ({
238246
}
239247
}
240248
} else {
241-
onSpeak(index, "speak");
249+
onSpeak(index, "speak", resetSpeech);
242250
startSpeech();
243251
}
244252
};

code/frontend/src/pages/chat/Chat.tsx

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ const [ASSISTANT, TOOL, ERROR] = ["assistant", "tool", "error"];
3838
const Chat = () => {
3939
const lastQuestionRef = useRef<string>("");
4040
const chatMessageStreamEnd = useRef<HTMLDivElement | null>(null);
41+
const audioStopRef = useRef<(() => void) | null>(null);
4142
const [isLoading, setIsLoading] = useState<boolean>(false);
4243
const [isGenerating, setIsGenerating] = useState<boolean>(false); // Add this state
4344
const [showLoadingMessage, setShowLoadingMessage] = useState<boolean>(false);
@@ -303,11 +304,13 @@ const Chat = () => {
303304
};
304305

305306
const clearChat = () => {
307+
audioStopRef.current?.();
306308
lastQuestionRef.current = "";
307309
setActiveCitation(undefined);
308310
setAnswers([]);
309311
setConversationId(uuidv4());
310312
setSelectedConvId("");
313+
setActiveCardIndex(null);
311314
};
312315

313316
const stopGenerating = () => {
@@ -385,9 +388,12 @@ const Chat = () => {
385388
[]
386389
);
387390

388-
const handleSpeech = (index: number, status: string) => {
391+
const handleSpeech = (index: number, status: string, stopAudioFn?: () => void) => {
389392
if (status != "pause") setActiveCardIndex(index);
390393
setIsTextToSpeachActive(status == "speak" ? true : false);
394+
if (status == "speak" && stopAudioFn) {
395+
audioStopRef.current = stopAudioFn;
396+
}
391397
};
392398
const onSetShowHistoryPanel = () => {
393399
if (!showHistoryPanel) {
@@ -423,8 +429,15 @@ const Chat = () => {
423429
console.error("No conversation Id found");
424430
return;
425431
}
432+
433+
if (id !== selectedConvId) {
434+
audioStopRef.current?.();
435+
setActiveCardIndex(null);
436+
}
437+
426438
const messages = getMessagesByConvId(id);
427439
if (messages.length === 0) {
440+
setAnswers([]);
428441
setFetchingConvMessages(true);
429442
const responseMessages = await historyRead(id);
430443
setAnswers(responseMessages);
@@ -433,7 +446,10 @@ const Chat = () => {
433446
} else {
434447
setAnswers(messages);
435448
}
436-
setSelectedConvId(id);
449+
450+
if (id !== selectedConvId) {
451+
setSelectedConvId(id);
452+
}
437453
};
438454

439455
useEffect(() => {
@@ -477,6 +493,7 @@ const Chat = () => {
477493
);
478494
setChatHistory(tempChatHistory);
479495
if (id === selectedConvId) {
496+
audioStopRef.current?.();
480497
lastQuestionRef.current = "";
481498
setActiveCitation(undefined);
482499
setAnswers([]);

docs/LOCAL_DEPLOYMENT.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ azd env set USE_KEY_VAULT false
3636

3737
Also please refer to the section on [setting up RBAC auth](#authenticate-using-rbac).
3838

39+
40+
## 🛠️ Troubleshooting
41+
If you encounter any issues during the deployment process, please refer to the [TroubleShootingSteps](TroubleShootingSteps.md) document for detailed steps and solutions.
42+
3943
## Deployment Options & Steps
4044

4145
### Sandbox or WAF Aligned Deployment Options

docs/NON_DEVCONTAINER_SETUP.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,6 @@ The Azure Developer CLI (`azd`) is a developer-centric command-line interface (C
5454
> **Note:** This solution accelerator requires **Azure Developer CLI (azd) version 1.18.0 or higher**. Please ensure you have the latest version installed before proceeding with deployment. [Download azd here](https://learn.microsoft.com/en-us/azure/developer/azure-developer-cli/install-azd).
5555

5656
> Select your desired `subscription` and `location`. Wait a moment for the resource deployment to complete, click the website endpoint and you will see the web app page.
57+
58+
## 🛠️ Troubleshooting
59+
If you encounter any issues during the deployment process, please refer to the [TroubleShootingSteps](TroubleShootingSteps.md) document for detailed steps and solutions.

0 commit comments

Comments
 (0)