mirror of
https://github.com/simstudioai/sim.git
synced 2026-01-10 07:27:57 -05:00
* improvement: panel tabs handler on click * fix: output break words * feat: keyboard navigation; improvement: SEO/GEO; refactor: file structure, unused fonts; fix: chat streaming, notification stack * feat: unresolved value handling on error; fix: layout refresh; refactor: delete old panel * refactor: control bar delete; improvement: workflow constants; fix: clear notifications keyboard shortcut * update developers count * fixed relative imports --------- Co-authored-by: waleed <walif6@gmail.com>
49 lines
1.2 KiB
TypeScript
49 lines
1.2 KiB
TypeScript
'use client'
|
|
|
|
import { useEffect } from 'react'
|
|
import { createLogger } from '@/lib/logs/console/logger'
|
|
|
|
const logger = createLogger('RootLayout')
|
|
|
|
const BROWSER_EXTENSION_ATTRIBUTES = [
|
|
'data-new-gr-c-s-check-loaded',
|
|
'data-gr-ext-installed',
|
|
'data-gr-ext-disabled',
|
|
'data-grammarly',
|
|
'data-fgm',
|
|
'data-lt-installed',
|
|
]
|
|
|
|
/**
|
|
* Client component that intercepts console.error to filter and log hydration errors
|
|
* while ignoring errors caused by browser extensions.
|
|
*/
|
|
export function HydrationErrorHandler() {
|
|
useEffect(() => {
|
|
const originalError = console.error
|
|
console.error = (...args) => {
|
|
if (args[0].includes('Hydration')) {
|
|
const isExtensionError = BROWSER_EXTENSION_ATTRIBUTES.some((attr) =>
|
|
args.some((arg) => typeof arg === 'string' && arg.includes(attr))
|
|
)
|
|
|
|
if (!isExtensionError) {
|
|
logger.error('Hydration Error', {
|
|
details: args,
|
|
componentStack: args.find(
|
|
(arg) => typeof arg === 'string' && arg.includes('component stack')
|
|
),
|
|
})
|
|
}
|
|
}
|
|
originalError.apply(console, args)
|
|
}
|
|
|
|
return () => {
|
|
console.error = originalError
|
|
}
|
|
}, [])
|
|
|
|
return null
|
|
}
|