|
| 1 | +import React, { useState } from 'react'; |
1 | 2 | import { |
2 | | - Accordion, |
3 | | - AccordionItem, |
4 | | - AccordionHeader, |
5 | | - AccordionPanel, |
| 3 | + Button, |
6 | 4 | } from '@fluentui/react-components'; |
| 5 | +import { ChevronRightRegular, ChevronDownRegular, CheckmarkCircle20Regular, ArrowTurnDownRightRegular } from '@fluentui/react-icons'; |
7 | 6 | import ReactMarkdown from "react-markdown"; |
8 | 7 | import remarkGfm from "remark-gfm"; |
9 | 8 | import rehypePrism from "rehype-prism"; |
10 | 9 |
|
11 | | -// Render AI thinking/planning state |
12 | 10 | const renderBufferMessage = (streamingMessageBuffer: string) => { |
| 11 | + const [isExpanded, setIsExpanded] = useState(false); |
| 12 | + |
13 | 13 | if (!streamingMessageBuffer || streamingMessageBuffer.trim() === "") return null; |
| 14 | + |
| 15 | + const previewText = streamingMessageBuffer.length > 500 |
| 16 | + ? streamingMessageBuffer.substring(0, 500) + "..." |
| 17 | + : streamingMessageBuffer; |
| 18 | + |
14 | 19 | 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 | + }}> |
19 | 104 | <ReactMarkdown |
20 | 105 | remarkPlugins={[remarkGfm]} |
21 | 106 | rehypePlugins={[rehypePrism]} |
22 | 107 | > |
23 | 108 | {streamingMessageBuffer} |
24 | 109 | </ReactMarkdown> |
25 | | - </AccordionPanel> |
26 | | - </AccordionItem> |
27 | | - </Accordion> |
28 | | - |
| 110 | + </div> |
| 111 | + )} |
| 112 | + </div> |
29 | 113 | ); |
30 | 114 | }; |
31 | 115 |
|
|
0 commit comments