diff --git a/ui/desktop/src/App.tsx b/ui/desktop/src/App.tsx index 36c6d27dc7ce..01abe6c6b67d 100644 --- a/ui/desktop/src/App.tsx +++ b/ui/desktop/src/App.tsx @@ -25,9 +25,5 @@ export default function App() { return window.electron.reloadApp()} />; } - if (isLauncher) { - return ; - } else { - return ; - } + return isLauncher ? : ; } \ No newline at end of file diff --git a/ui/desktop/src/ChatWindow.tsx b/ui/desktop/src/ChatWindow.tsx index b6e68ef479a6..fe45411b954d 100644 --- a/ui/desktop/src/ChatWindow.tsx +++ b/ui/desktop/src/ChatWindow.tsx @@ -190,8 +190,8 @@ function ChatContent({ }; return ( -
-
+
+
diff --git a/ui/desktop/src/components/UserMessage.tsx b/ui/desktop/src/components/UserMessage.tsx index ab1261acbf29..92cef9d53498 100644 --- a/ui/desktop/src/components/UserMessage.tsx +++ b/ui/desktop/src/components/UserMessage.tsx @@ -8,8 +8,8 @@ export default function UserMessage({ message }) { const urls = extractUrls(message.content, []); return ( -
-
+
+
{ + constructor(props: { children: React.ReactNode }) { + super(props) + this.state = { hasError: false } + } + + static getDerivedStateFromError(_: Error) { + return { hasError: true } + } + + componentDidCatch(error: Error, errorInfo: React.ErrorInfo) { + // Send error to main process + window.electron.logInfo(`[ERROR] ${error.toString()}\n${errorInfo.componentStack}`) + } + + render() { + if (this.state.hasError) { + return

Something went wrong.

+ } + + return this.props.children + } +} + +// Set up console interceptors +const originalConsole = { + log: console.log, + error: console.error, + warn: console.warn, + info: console.info, +} + +// Intercept console methods +console.log = (...args) => { + window.electron.logInfo(`[LOG] ${args.join(' ')}`) + originalConsole.log(...args) +} + +console.error = (...args) => { + window.electron.logInfo(`[ERROR] ${args.join(' ')}`) + originalConsole.error(...args) +} + +console.warn = (...args) => { + window.electron.logInfo(`[WARN] ${args.join(' ')}`) + originalConsole.warn(...args) +} + +console.info = (...args) => { + window.electron.logInfo(`[INFO] ${args.join(' ')}`) + originalConsole.info(...args) +} + +// Capture unhandled promise rejections +window.addEventListener('unhandledrejection', (event) => { + window.electron.logInfo(`[UNHANDLED REJECTION] ${event.reason}`) +}) + +// Capture global errors +window.addEventListener('error', (event) => { + window.electron.logInfo(`[GLOBAL ERROR] ${event.message} at ${event.filename}:${event.lineno}:${event.colno}`) +}) + ReactDOM.createRoot(document.getElementById('root')!).render( - - - + + + + + , ) \ No newline at end of file