Skip to content

Commit 61f5a00

Browse files
authored
Merge pull request #472 from microsoft/macae-v3-fr-dev-92
Update PlanChat UI and simplify error handling
2 parents cdf7ef3 + 2c92348 commit 61f5a00

File tree

3 files changed

+18
-48
lines changed

3 files changed

+18
-48
lines changed

src/frontend/src/components/content/PlanChat.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import ContentNotFound from "../NotFound/ContentNotFound";
3333
import PlanChatBody from "./PlanChatBody";
3434
import renderBufferMessage from "./streaming/StreamingBufferMessage";
3535
import renderAgentMessages from "./streaming/StreamingAgentMessage";
36+
3637
interface SimplifiedPlanChatProps extends PlanChatProps {
3738
onPlanReceived?: (planData: MPlanData) => void;
3839
initialTask?: string;
@@ -141,6 +142,7 @@ const PlanChat: React.FC<SimplifiedPlanChatProps> = ({
141142
backgroundColor: 'var(--colorNeutralBackground1)'
142143
}}>
143144
{/* Messages Container */}
145+
<InlineToaster />
144146
<div
145147
ref={messagesContainerRef}
146148
style={{

src/frontend/src/components/content/PlanChatBody.tsx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@ const PlanChatBody: React.FC<SimplifiedPlanChatProps> = ({
1616
}) => {
1717
return (
1818

19-
<div style={{
20-
padding: '20px 24px 32px',
21-
borderTop: '1px solid var(--colorNeutralStroke2)',
22-
backgroundColor: 'var(--colorNeutralBackground1)',
23-
maxWidth: '800px',
24-
margin: '0 auto',
25-
width: '100%'
26-
}}
19+
<div
20+
style={{
21+
padding: '20px 24px 32px',
22+
borderTop: '1px solid var(--colorNeutralStroke2)',
23+
backgroundColor: 'var(--colorNeutralBackground1)',
24+
maxWidth: '800px',
25+
margin: '0 auto',
26+
width: '98%'
27+
}}
2728

2829
>
2930
<ChatInput
@@ -34,7 +35,7 @@ const PlanChatBody: React.FC<SimplifiedPlanChatProps> = ({
3435
placeholder={
3536
waitingForPlan
3637
? "Creating plan..."
37-
: "Send a message..."
38+
: "Add more info to this plan..."
3839
}
3940
>
4041
<Button

src/frontend/src/pages/PlanPage.tsx

Lines changed: 6 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ const PlanPage: React.FC = () => {
383383
setInput("");
384384
dismissToast(id);
385385
showToast("Clarification submitted successfully", "success");
386-
setClarificationMessage(null);
386+
387387
const agentMessageData = {
388388
agent: 'You',
389389
agent_type: AgentMessageType.HUMAN_AGENT,
@@ -400,45 +400,12 @@ const PlanPage: React.FC = () => {
400400

401401
} catch (error: any) {
402402
dismissToast(id);
403+
setSubmittingChatDisableInput(false);
404+
showToast(
405+
"Failed to submit clarification",
406+
"error"
407+
);
403408

404-
// Enhanced error handling for v3 backend
405-
let errorDetail = null;
406-
try {
407-
// Try to parse the error detail if it's a string
408-
if (typeof error?.response?.data?.detail === 'string') {
409-
errorDetail = JSON.parse(error.response.data.detail);
410-
} else {
411-
errorDetail = error?.response?.data?.detail;
412-
}
413-
} catch (parseError) {
414-
// If parsing fails, use the original error
415-
errorDetail = error?.response?.data?.detail;
416-
}
417-
418-
// Handle RAI validation errors with better UX
419-
if (errorDetail?.error_type === 'RAI_VALIDATION_FAILED') {
420-
const raiErrorData: RAIErrorData = {
421-
error_type: 'RAI_VALIDATION_FAILED',
422-
message: 'Content Policy Violation',
423-
description: errorDetail.message || 'Your input contains content that violates our content policy.',
424-
suggestions: errorDetail.suggestions || [
425-
'Please rephrase your message using professional language',
426-
'Avoid potentially harmful or inappropriate content',
427-
'Focus on business-appropriate requests'
428-
],
429-
user_action: 'Please modify your input and try again.'
430-
};
431-
432-
} else {
433-
// Handle other types of errors
434-
showToast(
435-
error?.response?.data?.detail?.message ||
436-
error?.response?.data?.detail ||
437-
error?.message ||
438-
"Failed to submit clarification",
439-
"error"
440-
);
441-
}
442409
} finally {
443410

444411
}

0 commit comments

Comments
 (0)