From 184e7fac161fde849e4a78698602219d901d7413 Mon Sep 17 00:00:00 2001 From: cyberkunju Date: Thu, 9 Oct 2025 00:11:06 +0530 Subject: [PATCH 1/3] Tooltip Flickering & EDGE_CONFIG Handling --- app/api/session/route.ts | 16 ++++++++++++++-- app/page.tsx | 21 +++++++++++++++++++-- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/app/api/session/route.ts b/app/api/session/route.ts index 2244ab9..08994f7 100644 --- a/app/api/session/route.ts +++ b/app/api/session/route.ts @@ -131,13 +131,25 @@ async function createSession(timezone?: string) { apiKey: process.env.BROWSERBASE_API_KEY!, }); - const config = await getAll(); + let config: EdgeConfig | undefined; + try { + // Attempt to get the Edge Config + config = await getAll(); + } catch (error) { + // If Edge Config is not available, fall back to default values + console.error("Could not get Edge Config, falling back to defaults", error); + config = { + advancedStealth: undefined, + proxies: undefined, + regionDistribution: undefined, + }; + } const { advancedStealth: advancedStealthConfig, proxies: proxiesConfig, regionDistribution: distributionsConfig, - } = config; + } = config || {}; const advancedStealth: boolean = advancedStealthConfig ?? true; const proxies: boolean = proxiesConfig ?? true; diff --git a/app/page.tsx b/app/page.tsx index d166ebe..93bde82 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -16,17 +16,34 @@ const Tooltip = ({ text: string; }) => { const [isHovered, setIsHovered] = useState(false); + const timeoutRef = useRef(null); + + const showTooltip = useCallback(() => { + if (timeoutRef.current) { + clearTimeout(timeoutRef.current); + timeoutRef.current = null; + } + setIsHovered(true); + }, []); + + const hideTooltip = useCallback(() => { + timeoutRef.current = setTimeout(() => { + setIsHovered(false); + }, 200); + }, []); return (
setIsHovered(true)} - onMouseLeave={() => setIsHovered(false)} + onMouseEnter={showTooltip} + onMouseLeave={hideTooltip} > {children} {isHovered && ( Date: Thu, 9 Oct 2025 00:52:12 +0530 Subject: [PATCH 2/3] fixed --- app/api/session/route.ts | 23 +++++++++++------------ app/page.tsx | 23 +++++++++++++++-------- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/app/api/session/route.ts b/app/api/session/route.ts index 08994f7..d9a5430 100644 --- a/app/api/session/route.ts +++ b/app/api/session/route.ts @@ -131,25 +131,24 @@ async function createSession(timezone?: string) { apiKey: process.env.BROWSERBASE_API_KEY!, }); - let config: EdgeConfig | undefined; + let config: Partial = {}; try { - // Attempt to get the Edge Config - config = await getAll(); - } catch (error) { - // If Edge Config is not available, fall back to default values - console.error("Could not get Edge Config, falling back to defaults", error); - config = { - advancedStealth: undefined, - proxies: undefined, - regionDistribution: undefined, - }; + // If EDGE_CONFIG is not set, this will throw an error. + // We catch it and fall back to an empty config object. + config = (await getAll()) || {}; + } catch { + // This is expected if EDGE_CONFIG is not set, so we can ignore the error + // and fall back to the default configuration. + console.log( + "EDGE_CONFIG not found or invalid, using default configuration." + ); } const { advancedStealth: advancedStealthConfig, proxies: proxiesConfig, regionDistribution: distributionsConfig, - } = config || {}; + } = config; const advancedStealth: boolean = advancedStealthConfig ?? true; const proxies: boolean = proxiesConfig ?? true; diff --git a/app/page.tsx b/app/page.tsx index 93bde82..6d8588b 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -18,32 +18,39 @@ const Tooltip = ({ const [isHovered, setIsHovered] = useState(false); const timeoutRef = useRef(null); - const showTooltip = useCallback(() => { + const handleMouseEnter = () => { if (timeoutRef.current) { clearTimeout(timeoutRef.current); - timeoutRef.current = null; } setIsHovered(true); - }, []); + }; - const hideTooltip = useCallback(() => { + const handleMouseLeave = () => { timeoutRef.current = setTimeout(() => { setIsHovered(false); }, 200); + }; + + useEffect(() => { + return () => { + if (timeoutRef.current) { + clearTimeout(timeoutRef.current); + } + }; }, []); return (
{children} {isHovered && ( Date: Thu, 9 Oct 2025 20:25:19 +0530 Subject: [PATCH 3/3] removed the redundant comments --- app/api/session/route.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/app/api/session/route.ts b/app/api/session/route.ts index d9a5430..78ba0ed 100644 --- a/app/api/session/route.ts +++ b/app/api/session/route.ts @@ -133,12 +133,8 @@ async function createSession(timezone?: string) { let config: Partial = {}; try { - // If EDGE_CONFIG is not set, this will throw an error. - // We catch it and fall back to an empty config object. config = (await getAll()) || {}; } catch { - // This is expected if EDGE_CONFIG is not set, so we can ignore the error - // and fall back to the default configuration. console.log( "EDGE_CONFIG not found or invalid, using default configuration." );