feat: add DocumentPreviewer for chunk of chat reference and remove duplicate \n from record.progress_msg (#97)

* feat: Remove duplicate \n from record.progress_msg

* feat: add DocumentPreviewer for chunk of chat reference
This commit is contained in:
balibabu
2024-03-05 16:30:28 +08:00
committed by GitHub
parent 8a57f2afd5
commit 07d76ea18d
14 changed files with 333 additions and 104 deletions

View File

@@ -8,6 +8,8 @@
.popoverContentText {
white-space: pre-line;
max-height: 50vh;
overflow: auto;
.popoverContentErrorLabel {
color: red;
}

View File

@@ -21,6 +21,25 @@ interface IProps {
}
const PopoverContent = ({ record }: IProps) => {
const replaceText = (text: string) => {
// Remove duplicate \n
const nextText = text.replace(/(\n)\1+/g, '$1');
const replacedText = reactStringReplace(
nextText,
/(\[ERROR\].+\s)/g,
(match, i) => {
return (
<span key={i} className={styles.popoverContentErrorLabel}>
{match}
</span>
);
},
);
return replacedText;
};
const items: DescriptionsProps['items'] = [
{
key: 'process_begin_at',
@@ -35,17 +54,7 @@ const PopoverContent = ({ record }: IProps) => {
{
key: 'progress_msg',
label: 'Progress Msg',
children: reactStringReplace(
record.progress_msg.trim(),
/(\[ERROR\].+\s)/g,
(match, i) => {
return (
<span key={i} className={styles.popoverContentErrorLabel}>
{match}
</span>
);
},
),
children: replaceText(record.progress_msg.trim()),
},
];