Refactor ChatPanel to handle missing contexts
Refactored `ChatPanel` to handle missing contexts by adding conditional rendering for the `Accordion` and `contexts` map. Also, added `pre` tag styling to the message content.
This commit is contained in:
parent
767933cf95
commit
ea32ab6e24
@ -244,6 +244,7 @@ const chatPanel = () => {
|
|||||||
<Flex
|
<Flex
|
||||||
key={`message-${index}`}
|
key={`message-${index}`}
|
||||||
mih={50}
|
mih={50}
|
||||||
|
miw={300}
|
||||||
gap="md"
|
gap="md"
|
||||||
justify="flex-start"
|
justify="flex-start"
|
||||||
align="flex-start"
|
align="flex-start"
|
||||||
@ -263,7 +264,11 @@ const chatPanel = () => {
|
|||||||
paddingLeft: 0,
|
paddingLeft: 0,
|
||||||
paddingRight: 0,
|
paddingRight: 0,
|
||||||
width: 'calc(100% - 62px)',
|
width: 'calc(100% - 62px)',
|
||||||
|
pre: {
|
||||||
|
whiteSpace: 'break-spaces'
|
||||||
|
}
|
||||||
}}>
|
}}>
|
||||||
|
{contexts &&
|
||||||
<Accordion variant="contained" chevronPosition="left" style={{ backgroundColor: '#FFF' }}>
|
<Accordion variant="contained" chevronPosition="left" style={{ backgroundColor: '#FFF' }}>
|
||||||
{
|
{
|
||||||
contexts?.map(({ context }, index) => {
|
contexts?.map(({ context }, index) => {
|
||||||
@ -289,6 +294,7 @@ const chatPanel = () => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
</Accordion>
|
</Accordion>
|
||||||
|
}
|
||||||
<ReactMarkdown
|
<ReactMarkdown
|
||||||
components={{
|
components={{
|
||||||
code({ node, inline, className, children, ...props }) {
|
code({ node, inline, className, children, ...props }) {
|
||||||
@ -393,7 +399,9 @@ const chatPanel = () => {
|
|||||||
viewportRef={scrollViewport}>
|
viewportRef={scrollViewport}>
|
||||||
{messageList.length > 0 ? messageList : defaultMessages}
|
{messageList.length > 0 ? messageList : defaultMessages}
|
||||||
</ScrollArea>
|
</ScrollArea>
|
||||||
<Stack sx={{ position: 'absolute', bottom: 10, width: scrollViewport.current?.clientWidth }}>
|
<Stack
|
||||||
|
sx={{ position: 'absolute', bottom: 10, width: scrollViewport.current?.clientWidth }}>
|
||||||
|
{contexts &&
|
||||||
<Accordion variant="contained" chevronPosition="left" style={{ backgroundColor: '#FFF' }}>
|
<Accordion variant="contained" chevronPosition="left" style={{ backgroundColor: '#FFF' }}>
|
||||||
{
|
{
|
||||||
contexts.map(({ context }, index) => {
|
contexts.map(({ context }, index) => {
|
||||||
@ -427,6 +435,7 @@ const chatPanel = () => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
</Accordion>
|
</Accordion>
|
||||||
|
}
|
||||||
<Menu
|
<Menu
|
||||||
id='commandMenu'
|
id='commandMenu'
|
||||||
position='top-start'
|
position='top-start'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user