diff --git a/apps/editor/components/ui/action-menu/index.tsx b/apps/editor/components/ui/action-menu/index.tsx index 461b86dc..bc3ceec9 100644 --- a/apps/editor/components/ui/action-menu/index.tsx +++ b/apps/editor/components/ui/action-menu/index.tsx @@ -28,9 +28,9 @@ export function ActionMenu({ className }: { className?: string }) { className, )} > - {/* Structure Tools Row - Animated */} + {/* Item Catalog Row - Only show when in build mode with item tool */} - {tool === "item" && catalogCategory && ( + {mode === "build" && tool === "item" && catalogCategory && ( state.tool) const catalogCategory = useEditor((state) => state.catalogCategory) + const structureLayer = useEditor((state) => state.structureLayer) const setTool = useEditor((state) => state.setTool) const setCatalogCategory = useEditor((state) => state.setCatalogCategory) + // Filter tools based on structureLayer + const visibleTools = structureLayer === 'zones' + ? tools.filter((t) => t.id === 'zone') + : tools.filter((t) => t.id !== 'zone') + return (
- {tools.map((tool, index) => { + {visibleTools.map((tool, index) => { // For item tools with catalog category, check both tool and category match const isActive = activeTool === tool.id && diff --git a/apps/editor/components/ui/sidebar/panels/site-panel/index.tsx b/apps/editor/components/ui/sidebar/panels/site-panel/index.tsx index ecafb6a6..66a017c6 100644 --- a/apps/editor/components/ui/sidebar/panels/site-panel/index.tsx +++ b/apps/editor/components/ui/sidebar/panels/site-panel/index.tsx @@ -401,11 +401,14 @@ function ContentSection() { } function StructurePhaseView() { + const phase = useEditor((state) => state.phase); + return (
- + {/* Only show layer toggle in structure phase, furnish is always elements */} + {phase === "structure" && }
diff --git a/apps/editor/store/use-editor.tsx b/apps/editor/store/use-editor.tsx index c780fa8f..036e81c8 100644 --- a/apps/editor/store/use-editor.tsx +++ b/apps/editor/store/use-editor.tsx @@ -66,6 +66,9 @@ const useEditor = create()((set, get) => ({ set({ phase }) + // Clear tool and catalog when switching phases + set({ tool: null, catalogCategory: null }) + const viewer = useViewer.getState() const scene = useScene.getState() @@ -116,21 +119,51 @@ const useEditor = create()((set, get) => ({ case 'furnish': selectBuildingAndLevel0() viewer.setLevelMode('solo') + // Furnish mode only supports elements layer, not zones + set({ structureLayer: 'elements' }) break } }, mode: 'select', - setMode: (mode) => set({ mode }), + setMode: (mode) => { + set({ mode }) + + const { phase, structureLayer, tool } = get() + + // When entering build mode in structure phase with zones layer, activate zone tool + if (mode === 'build' && phase === 'structure' && structureLayer === 'zones') { + set({ tool: 'zone' }) + } + // When leaving build mode, clear tool + else if (mode !== 'build' && tool) { + set({ tool: null }) + } + }, tool: null, setTool: (tool) => set({ tool }), structureLayer: 'elements', setStructureLayer: (layer) => { + const { mode, tool } = get() set({ structureLayer: layer }) + const viewer = useViewer.getState() viewer.setSelection({ selectedIds: [], zoneId: null, }) + + // Handle tool changes based on layer + if (layer === 'zones') { + // In zones layer with build mode, activate zone tool + if (mode === 'build') { + set({ tool: 'zone' }) + } + } else { + // In elements layer, clear zone tool if it was active + if (tool === 'zone') { + set({ tool: null }) + } + } }, catalogCategory: null, setCatalogCategory: (category) => set({ catalogCategory: category }),