diff --git a/web/containers/ErrorMessage/index.test.tsx b/web/containers/ErrorMessage/index.test.tsx
index d9866d3c0f..cb0cc3cf6f 100644
--- a/web/containers/ErrorMessage/index.test.tsx
+++ b/web/containers/ErrorMessage/index.test.tsx
@@ -69,7 +69,7 @@ describe('ErrorMessage Component', () => {
render()
- expect(screen.getByText('troubleshooting assistance')).toBeInTheDocument()
+ expect(screen.getByText('Troubleshooting')).toBeInTheDocument()
})
it('opens troubleshooting modal when link is clicked', () => {
@@ -84,7 +84,7 @@ describe('ErrorMessage Component', () => {
render()
- fireEvent.click(screen.getByText('troubleshooting assistance'))
+ fireEvent.click(screen.getByText('Troubleshooting'))
expect(mockSetModalTroubleShooting).toHaveBeenCalledWith(true)
})
})
diff --git a/web/containers/ErrorMessage/index.tsx b/web/containers/ErrorMessage/index.tsx
index 71fd56c5d3..cd9334283e 100644
--- a/web/containers/ErrorMessage/index.tsx
+++ b/web/containers/ErrorMessage/index.tsx
@@ -1,3 +1,5 @@
+import { useRef, useState } from 'react'
+
import {
EngineManager,
ErrorCode,
@@ -7,6 +9,8 @@ import {
import { useAtomValue, useSetAtom } from 'jotai'
+import { CheckIcon, ClipboardIcon, SearchCodeIcon } from 'lucide-react'
+
import AutoLink from '@/containers/AutoLink'
import ModalTroubleShooting, {
modalTroubleShootingAtom,
@@ -24,30 +28,25 @@ const ErrorMessage = ({ message }: { message: ThreadMessage }) => {
const setMainState = useSetAtom(mainViewStateAtom)
const setSelectedSettingScreen = useSetAtom(selectedSettingAtom)
const activeAssistant = useAtomValue(activeAssistantAtom)
-
- const defaultDesc = () => {
- return (
- <>
-
- {`Something's wrong.`} Access
- setModalTroubleShooting(true)}
- >
- troubleshooting assistance
-
- now.
-
-
- >
- )
- }
+ const errorDivRef = useRef(null)
+ const [copied, setCopied] = useState(false)
const getEngine = () => {
const engineName = activeAssistant?.model?.engine
return engineName ? EngineManager.instance().get(engineName) : null
}
+ const handleCopy = () => {
+ if (errorDivRef.current) {
+ const errorText = errorDivRef.current.innerText
+ if (errorText) {
+ navigator.clipboard.writeText(errorText)
+ setCopied(true)
+ setTimeout(() => setCopied(false), 2000)
+ }
+ }
+ }
+
const getErrorTitle = () => {
const engine = getEngine()
@@ -69,9 +68,9 @@ const ErrorMessage = ({ message }: { message: ThreadMessage }) => {
{' '}
and try again.
- {defaultDesc()}
>
)
+
default:
return (
{
{message?.content[0]?.text?.value && (
)}
- {defaultDesc()}
>
)}
@@ -99,15 +97,54 @@ const ErrorMessage = ({ message }: { message: ThreadMessage }) => {
}
return (
-
- {!!message.metadata?.error && (
-
- {getErrorTitle()}
+
+
+
+
Error
+
+
+ setModalTroubleShooting(true)}
+ >
+
+ Troubleshooting
+
+
+
+
+ {copied ? (
+ <>
+
+ Copied
+ >
+ ) : (
+ <>
+
+ Copy
+ >
+ )}
+
+
+
+
- )}
+
)
}