From 158bbcf7dfd15c3151f75166adb0f0a33f688a09 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sat, 17 Jan 2026 23:49:38 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=20Bolt:=20Fix=20shared=20state=20issu?= =?UTF-8?q?e=20in=20background=20gradient=20caching?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Introduces `cachedHorizonGlowHeight` to independently track dimensions for the horizon glow gradient, preventing stale rendering when `cachedHeight` is updated by other functions. --- src/background-themes.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/background-themes.ts b/src/background-themes.ts index c0307ac..754a1fd 100644 --- a/src/background-themes.ts +++ b/src/background-themes.ts @@ -1650,6 +1650,7 @@ function drawMouseParticles(ctx) { // Gradient caching let cachedGradient = null; let cachedHorizonGlow = null; +let cachedHorizonGlowHeight = 0; let cachedTheme = null; let cachedWidth = 0; let cachedHeight = 0; @@ -2340,6 +2341,7 @@ function drawEnhancedBackground(ctx, width, height) { cachedHeight = height; // Reset horizon glow cache when dimensions change cachedHorizonGlow = null; + cachedHorizonGlowHeight = 0; initStars(width, height); } @@ -2457,14 +2459,14 @@ function drawEnhancedBackground(ctx, width, height) { // Atmospheric glow at horizon (subtle light pollution effect) if (!lowPerfMode) { // Cache horizon glow gradient (recreate if height changes) - if (!cachedHorizonGlow || cachedHeight !== height) { + // Use a separate height tracker for horizon glow since cachedHeight is shared + if (!cachedHorizonGlow || cachedHorizonGlowHeight !== height) { const horizonGlow = ctx.createLinearGradient(0, height * 0.7, 0, height); horizonGlow.addColorStop(0, 'rgba(0, 0, 0, 0)'); horizonGlow.addColorStop(0.5, 'rgba(20, 30, 60, 0.05)'); horizonGlow.addColorStop(1, 'rgba(40, 50, 80, 0.1)'); cachedHorizonGlow = horizonGlow; - // Ensure cachedHeight is updated if we updated the glow - cachedHeight = height; + cachedHorizonGlowHeight = height; } ctx.globalAlpha = 1; ctx.fillStyle = cachedHorizonGlow;