From 668398e66aa5b491e01829b1a8eed1f00d3e0d62 Mon Sep 17 00:00:00 2001 From: Sean Date: Wed, 25 Mar 2026 07:05:57 -0400 Subject: [PATCH] fix: reset previousPartIdsRef on build clear; clarify first-hydration skip comment --- app/(app)/(builder)/builder/page.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/(app)/(builder)/builder/page.tsx b/app/(app)/(builder)/builder/page.tsx index d6d51b6..73eacd5 100644 --- a/app/(app)/(builder)/builder/page.tsx +++ b/app/(app)/(builder)/builder/page.tsx @@ -618,6 +618,7 @@ function GunbuilderPageContent() { if (ids.length === 0) { lastHydrateKeyRef.current = ""; setParts([]); + previousPartIdsRef.current = new Set(); // keep in sync so re-selecting fires the event setError(null); setLoading(false); return; @@ -670,8 +671,9 @@ function GunbuilderPageContent() { setParts(hydrated); - // Track newly selected parts (fires after API returns with real names). - // Skip the first hydration — that's restoring a saved build, not a new selection. + // Track newly selected parts after API fetch — fires with real name, not a numeric ID. + // Skip the first hydration: this covers both localStorage build restoration and ?select= + // share-link arrivals. Neither represents a live user interaction in the current session. if (isFirstPartsHydrationRef.current) { isFirstPartsHydrationRef.current = false; } else {