From 7b8861144e728be61f3f411059dedbc4e71e857a Mon Sep 17 00:00:00 2001 From: Bohdan Triapitsyn Date: Fri, 15 May 2026 00:48:33 +0300 Subject: [PATCH] fix: prevent tooltip context crashes in chat (#1134) Keeps VS Code chat from crashing when tooltip context is unavailable Falls back safely for tooltip triggers and content --- packages/ui/src/components/ui/tooltip.tsx | 59 ++++++++++++++++------- 1 file changed, 42 insertions(+), 17 deletions(-) diff --git a/packages/ui/src/components/ui/tooltip.tsx b/packages/ui/src/components/ui/tooltip.tsx index 8be35698..945c3179 100644 --- a/packages/ui/src/components/ui/tooltip.tsx +++ b/packages/ui/src/components/ui/tooltip.tsx @@ -8,6 +8,25 @@ type AsChildRenderProps = { children?: React.ReactNode; }; +class TooltipPartBoundary extends React.Component<{ + children: React.ReactNode; + fallback?: React.ReactNode; +}, { hasError: boolean }> { + state = { hasError: false }; + + static getDerivedStateFromError() { + return { hasError: true }; + } + + render() { + if (this.state.hasError) { + return this.props.fallback ?? null; + } + + return this.props.children; + } +} + type ProviderProps = React.ComponentProps & { delayDuration?: number; skipDelayDuration?: number; @@ -54,7 +73,11 @@ function TooltipTrigger({ const renderProps: AsChildRenderProps = asChild && React.isValidElement(children) ? { render: children as React.ReactElement } : { children }; - return + return ( + + + + ) } type ContentProps = React.ComponentProps & { @@ -73,22 +96,24 @@ function TooltipContent({ ...props }: ContentProps) { return ( - - - - {children} - - - - + + + + + {children} + + + + + ) }