Skip to content

Commit 321ba91

Browse files
authored
Merge pull request microsoft#463 from microsoft/macae-v3-streaming-UI
Feat - enhance streaming UI with expandable thinking process
2 parents 74586c2 + b8fb0c7 commit 321ba91

File tree

1 file changed

+97
-13
lines changed

1 file changed

+97
-13
lines changed

src/frontend/src/components/content/streaming/StreamingBufferMessage.tsx

Lines changed: 97 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,115 @@
1+
import React, { useState } from 'react';
12
import {
2-
Accordion,
3-
AccordionItem,
4-
AccordionHeader,
5-
AccordionPanel,
3+
Button,
64
} from '@fluentui/react-components';
5+
import { ChevronRightRegular, ChevronDownRegular, CheckmarkCircle20Regular, ArrowTurnDownRightRegular } from '@fluentui/react-icons';
76
import ReactMarkdown from "react-markdown";
87
import remarkGfm from "remark-gfm";
98
import rehypePrism from "rehype-prism";
109

11-
// Render AI thinking/planning state
1210
const renderBufferMessage = (streamingMessageBuffer: string) => {
11+
const [isExpanded, setIsExpanded] = useState(false);
12+
1313
if (!streamingMessageBuffer || streamingMessageBuffer.trim() === "") return null;
14+
15+
const previewText = streamingMessageBuffer.length > 500
16+
? streamingMessageBuffer.substring(0, 500) + "..."
17+
: streamingMessageBuffer;
18+
1419
return (
15-
<Accordion collapsible defaultOpenItems="one">
16-
<AccordionItem value="one">
17-
18-
<AccordionPanel>
20+
<div style={{
21+
backgroundColor: 'var(--colorNeutralBackground2)',
22+
border: '1px solid var(--colorNeutralStroke1)',
23+
borderRadius: '8px',
24+
padding: '16px',
25+
marginBottom: '16px'
26+
}}>
27+
28+
<div style={{
29+
display: 'flex',
30+
justifyContent: 'space-between',
31+
alignItems: 'center',
32+
marginBottom: isExpanded ? '16px' : '8px'
33+
}}>
34+
<div style={{
35+
display: 'flex',
36+
alignItems: 'center',
37+
gap: '12px'
38+
}}>
39+
<CheckmarkCircle20Regular style={{
40+
color: 'var(--colorNeutralForeground1)',
41+
fontSize: '20px',
42+
width: '20px',
43+
height: '20px',
44+
flexShrink: 0
45+
}} />
46+
<span style={{
47+
fontWeight: '500',
48+
color: 'var(--colorNeutralForeground1)',
49+
fontSize: '14px',
50+
lineHeight: '20px'
51+
}}>
52+
AI Thinking Process
53+
</span>
54+
</div>
55+
56+
<Button
57+
appearance="secondary"
58+
size="small"
59+
// icon={isExpanded ? <ChevronDownRegular /> : <ChevronRightRegular />}
60+
onClick={() => setIsExpanded(!isExpanded)}
61+
style={{
62+
backgroundColor: 'var(--colorNeutralBackground3)',
63+
border: '1px solid var(--colorNeutralStroke2)',
64+
borderRadius: '16px',
65+
padding: '4px 12px',
66+
fontSize: '14px'
67+
}}
68+
>
69+
Details
70+
</Button>
71+
</div>
72+
73+
{!isExpanded && (
74+
<div style={{
75+
display: 'flex',
76+
alignItems: 'flex-start',
77+
gap: '8px',
78+
marginLeft: '32px'
79+
}}>
80+
<ArrowTurnDownRightRegular style={{
81+
color: 'var(--colorNeutralForeground3)',
82+
fontSize: '14px',
83+
marginTop: '2px',
84+
flexShrink: 0
85+
}} />
86+
<div style={{
87+
color: 'var(--colorNeutralForeground2)',
88+
fontSize: '14px',
89+
lineHeight: '1.4'
90+
}}>
91+
{previewText}
92+
</div>
93+
</div>
94+
)}
95+
96+
{isExpanded && (
97+
<div style={{
98+
// backgroundColor: 'var(--colorNeutralBackground1)',
99+
// border: '1px solid var(--colorNeutralStroke1)',
100+
// borderRadius: '6px',
101+
padding: '12px',
102+
marginTop: '8px'
103+
}}>
19104
<ReactMarkdown
20105
remarkPlugins={[remarkGfm]}
21106
rehypePlugins={[rehypePrism]}
22107
>
23108
{streamingMessageBuffer}
24109
</ReactMarkdown>
25-
</AccordionPanel>
26-
</AccordionItem>
27-
</Accordion>
28-
110+
</div>
111+
)}
112+
</div>
29113
);
30114
};
31115

0 commit comments

Comments
 (0)