From 0fc32a1e19d78dc296fc55a2d2beee78bc4c44a4 Mon Sep 17 00:00:00 2001 From: simoleo89 Date: Sat, 16 May 2026 12:31:19 +0200 Subject: [PATCH] wired-tools: hoist variable-highlight toggle + overlays to the store MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move the highlight feature pair into useWiredCreatorToolsUiStore: isVariableHighlightActive (toggle UI flag) and variableHighlightOverlays (computed screen-space overlay positions). The two screen-coords effects in WiredCreatorToolsView stay where they are (they need React's lifecycle to install / tear down WiredSelectionVisualizer highlights on the active room objects) but now write to setVariableHighlightOverlays. WiredVariablesTabView drops the isVariableHighlightActive + onToggleVariableHighlight props and consumes the store directly — same shape as the previous tab-prop reductions on this branch. The toggle button keeps the same UX (Highlight ↔ Undo) but no longer crosses the prop boundary. Direct benefit: closing and reopening the panel while a variable highlight is active no longer flickers the overlays off and back on — the active flag + the last-computed overlay set both persist in zustand and the effect re-runs from the same starting point. Tests: three new cases on the store (toggle via direct + updater, overlay replace + clear, close/reopen persistence). 190/190 passing. variableHighlightObjectsRef stays a useRef inside the component: it tracks the live PIXI objects WiredSelectionVisualizer drew onto, used only for the cleanup pass — refs don't trigger renders and don't need to live in the store. --- .../wired-tools/WiredCreatorToolsView.tsx | 8 ++-- .../wired-tools/WiredVariablesTabView.tsx | 8 ++-- .../wiredCreatorToolsUiStore.test.ts | 44 ++++++++++++++++++- .../wired-tools/wiredCreatorToolsUiStore.ts | 23 +++++++++- 4 files changed, 71 insertions(+), 12 deletions(-) diff --git a/src/components/wired-tools/WiredCreatorToolsView.tsx b/src/components/wired-tools/WiredCreatorToolsView.tsx index 5ada188..f5cefcd 100644 --- a/src/components/wired-tools/WiredCreatorToolsView.tsx +++ b/src/components/wired-tools/WiredCreatorToolsView.tsx @@ -77,8 +77,10 @@ export const WiredCreatorToolsView: FC<{}> = () => const setIsManagedGiveOpen = useWiredCreatorToolsUiStore(s => s.setIsManagedGiveOpen); const [ managedGiveVariableItemId, setManagedGiveVariableItemId ] = useState(0); const [ managedGiveValue, setManagedGiveValue ] = useState('0'); - const [ isVariableHighlightActive, setIsVariableHighlightActive ] = useState(false); - const [ variableHighlightOverlays, setVariableHighlightOverlays ] = useState([]); + const isVariableHighlightActive = useWiredCreatorToolsUiStore(s => s.isVariableHighlightActive); + const setIsVariableHighlightActive = useWiredCreatorToolsUiStore(s => s.setIsVariableHighlightActive); + const variableHighlightOverlays = useWiredCreatorToolsUiStore(s => s.variableHighlightOverlays); + const setVariableHighlightOverlays = useWiredCreatorToolsUiStore(s => s.setVariableHighlightOverlays); const variableHighlightObjectsRef = useRef>([]); const shouldPauseVariableSnapshotRefresh = (!!editingVariable || !!editingManagedHolderVariableId || isInspectionGiveOpen || isManagedGiveOpen); const [ selectedVariableKeys, setSelectedVariableKeys ] = useState>({ @@ -3145,8 +3147,6 @@ export const WiredCreatorToolsView: FC<{}> = () => selectedVariableDefinition={ selectedVariableDefinition } onPickVariable={ key => setSelectedVariableKeys(prev => ({ ...prev, [variablesType]: key })) } canVariableHighlight={ canVariableHighlight } - isVariableHighlightActive={ isVariableHighlightActive } - onToggleVariableHighlight={ () => setIsVariableHighlightActive(value => !value) } variableManageCanOpen={ variableManageCanOpen } onOpenManagePanel={ () => { diff --git a/src/components/wired-tools/WiredVariablesTabView.tsx b/src/components/wired-tools/WiredVariablesTabView.tsx index 2ca1ed9..163a53d 100644 --- a/src/components/wired-tools/WiredVariablesTabView.tsx +++ b/src/components/wired-tools/WiredVariablesTabView.tsx @@ -10,8 +10,6 @@ export interface WiredVariablesTabViewProps selectedVariableDefinition: VariableDefinition | null; onPickVariable: (key: string) => void; canVariableHighlight: boolean; - isVariableHighlightActive: boolean; - onToggleVariableHighlight: () => void; variableManageCanOpen: boolean; onOpenManagePanel: () => void; selectedVariableProperties: { key: string; value: string; }[]; @@ -30,8 +28,6 @@ export const WiredVariablesTabView: FC = ({ selectedVariableDefinition, onPickVariable, canVariableHighlight, - isVariableHighlightActive, - onToggleVariableHighlight, variableManageCanOpen, onOpenManagePanel, selectedVariableProperties, @@ -40,6 +36,8 @@ export const WiredVariablesTabView: FC = ({ { const variablesType = useWiredCreatorToolsUiStore(s => s.variablesType); const setVariablesType = useWiredCreatorToolsUiStore(s => s.setVariablesType); + const isVariableHighlightActive = useWiredCreatorToolsUiStore(s => s.isVariableHighlightActive); + const setIsVariableHighlightActive = useWiredCreatorToolsUiStore(s => s.setIsVariableHighlightActive); return (
@@ -83,7 +81,7 @@ export const WiredVariablesTabView: FC = ({