From 6cff29e1646e5d861711d2f44c126e30382147c0 Mon Sep 17 00:00:00 2001 From: Jeff Emmett Date: Wed, 24 Dec 2025 10:54:13 -0500 Subject: [PATCH] feat: disable Holon functionality via HOLON_ENABLED flag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Added HOLON_ENABLED feature flag (set to false) to completely disable Holon functionality - HoloSphereService methods now return early with default values when disabled - Removed all console.log/error output when Holon is disabled - HolonShapeUtil shows "Feature Disabled" message when flag is false - HolonBrowser shows disabled message instead of attempting connections - Code preserved for future Nostr integration re-enablement 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- src/components/HolonBrowser.tsx | 62 ++++++++++++++++++++++++++++++++- src/lib/HoloSphereService.ts | 28 +++++++++------ src/shapes/HolonShapeUtil.tsx | 42 ++++++++++++++++++++-- 3 files changed, 119 insertions(+), 13 deletions(-) diff --git a/src/components/HolonBrowser.tsx b/src/components/HolonBrowser.tsx index 3d432af..ae5ce87 100644 --- a/src/components/HolonBrowser.tsx +++ b/src/components/HolonBrowser.tsx @@ -1,5 +1,5 @@ import React, { useState, useEffect, useRef } from 'react' -import { holosphereService, HoloSphereService, HolonData, HolonLens } from '@/lib/HoloSphereService' +import { holosphereService, HoloSphereService, HolonData, HolonLens, HOLON_ENABLED } from '@/lib/HoloSphereService' import * as h3 from 'h3-js' interface HolonBrowserProps { @@ -32,6 +32,66 @@ export function HolonBrowser({ isOpen, onClose, onSelectHolon, shapeMode = false const [isLoadingData, setIsLoadingData] = useState(false) const inputRef = useRef(null) + // If Holon functionality is disabled, show a disabled message + if (!HOLON_ENABLED) { + if (!isOpen) return null + + const disabledContent = ( +
+
🌐
+

+ Holon Browser Disabled +

+

+ Holon functionality is currently disabled while awaiting Nostr integration. + This feature will be re-enabled in a future update. +

+ {!shapeMode && ( + + )} +
+ ) + + if (shapeMode) { + return disabledContent + } + + return ( +
+
e.stopPropagation()} + > + {disabledContent} +
+
+ ) + } + useEffect(() => { if (isOpen && inputRef.current) { inputRef.current.focus() diff --git a/src/lib/HoloSphereService.ts b/src/lib/HoloSphereService.ts index 6a5bea0..95ed785 100644 --- a/src/lib/HoloSphereService.ts +++ b/src/lib/HoloSphereService.ts @@ -7,6 +7,10 @@ * TODO: Integrate with Nostr protocol when Holons.io provides their Nostr-based API */ +// Feature flag to completely disable Holon functionality +// Set to true when ready to re-enable +export const HOLON_ENABLED = false + import * as h3 from 'h3-js' export interface HolonData { @@ -45,7 +49,10 @@ export class HoloSphereService { constructor(_appName: string = 'canvas-holons', _strict: boolean = false, _openaiKey?: string) { this.isInitialized = true - console.log('⚠️ HoloSphere service initialized (STUB MODE - awaiting Nostr integration)') + // Only log if Holon functionality is enabled + if (HOLON_ENABLED) { + console.log('⚠️ HoloSphere service initialized (STUB MODE - awaiting Nostr integration)') + } } async initialize(): Promise { @@ -54,37 +61,40 @@ export class HoloSphereService { // Get a holon for specific coordinates and resolution async getHolon(lat: number, lng: number, resolution: number): Promise { + if (!HOLON_ENABLED) return '' try { return h3.latLngToCell(lat, lng, resolution) } catch (error) { - console.error('❌ Error getting holon:', error) + // Silently fail when disabled return '' } } // Store data in local cache (placeholder for Nostr) async putData(holon: string, lens: string, data: any): Promise { + if (!HOLON_ENABLED) return false const key = `${holon}:${lens}` const existing = this.localCache.get(key) || {} this.localCache.set(key, { ...existing, ...data }) - console.log(`📝 [STUB] Stored data locally: ${key}`) return true } // Retrieve data from local cache async getData(holon: string, lens: string, _key?: string): Promise { + if (!HOLON_ENABLED) return null const cacheKey = `${holon}:${lens}` return this.localCache.get(cacheKey) || null } // Retrieve data with subscription (stub - just returns cached data) async getDataWithWait(holon: string, lens: string, _timeoutMs: number = 5000): Promise { - console.log(`🔍 [STUB] getDataWithWait: holon=${holon}, lens=${lens}`) + if (!HOLON_ENABLED) return null return this.getData(holon, lens) } // Delete data from local cache async deleteData(holon: string, lens: string, _key?: string): Promise { + if (!HOLON_ENABLED) return false const cacheKey = `${holon}:${lens}` this.localCache.delete(cacheKey) return true @@ -92,7 +102,7 @@ export class HoloSphereService { // Schema methods (stub) async setSchema(_lens: string, _schema: any): Promise { - console.log('⚠️ [STUB] setSchema not implemented') + if (!HOLON_ENABLED) return false return true } @@ -102,24 +112,25 @@ export class HoloSphereService { // Subscribe to changes (stub - no-op) subscribe(_holon: string, _lens: string, _callback: (data: any) => void): void { - console.log('⚠️ [STUB] subscribe not implemented - awaiting Nostr integration') + // No-op when disabled or in stub mode } // Get holon hierarchy using h3-js getHolonHierarchy(holon: string): { parent?: string; children: string[] } { + if (!HOLON_ENABLED) return { children: [] } try { const resolution = h3.getResolution(holon) const parent = resolution > 0 ? h3.cellToParent(holon, resolution - 1) : undefined const children = h3.cellToChildren(holon, resolution + 1) return { parent, children } } catch (error) { - console.error('❌ Error getting holon hierarchy:', error) return { children: [] } } } // Get all scales for a holon getHolonScalespace(holon: string): string[] { + if (!HOLON_ENABLED) return [] try { const resolution = h3.getResolution(holon) const scales: string[] = [holon] @@ -133,19 +144,16 @@ export class HoloSphereService { return scales } catch (error) { - console.error('❌ Error getting holon scalespace:', error) return [] } } // Federation methods (stub) async federate(_spaceId1: string, _spaceId2: string, _password1?: string, _password2?: string, _bidirectional?: boolean): Promise { - console.log('⚠️ [STUB] federate not implemented - awaiting Nostr integration') return false } async propagate(_holon: string, _lens: string, _data: any, _options?: { useReferences?: boolean; targetSpaces?: string[] }): Promise { - console.log('⚠️ [STUB] propagate not implemented - awaiting Nostr integration') return false } diff --git a/src/shapes/HolonShapeUtil.tsx b/src/shapes/HolonShapeUtil.tsx index a41c9c5..afec982 100644 --- a/src/shapes/HolonShapeUtil.tsx +++ b/src/shapes/HolonShapeUtil.tsx @@ -4,7 +4,7 @@ import { TLBaseShape, } from "tldraw" import React, { useState, useRef, useEffect, useCallback } from "react" -import { holosphereService, HoloSphereService, HolonConnection } from "@/lib/HoloSphereService" +import { holosphereService, HoloSphereService, HolonConnection, HOLON_ENABLED } from "@/lib/HoloSphereService" import * as h3 from 'h3-js' import { StandardizedToolWrapper } from "../components/StandardizedToolWrapper" import { usePinnedToView } from "../hooks/usePinnedToView" @@ -99,7 +99,45 @@ export class HolonShape extends BaseBoxShapeUtil { data, connections, lastUpdated } = shape.props - console.log('🔧 Holon component rendering - isEditing:', isEditing, 'holonId:', holonId) + // If Holon functionality is disabled, show a disabled message + if (!HOLON_ENABLED) { + return ( + +
+
🌐
+
+ Holon Feature Disabled +
+
+ Holon functionality is currently disabled. It will be re-enabled when Nostr integration is available. +
+
+
+ ) + } const [isHovering, setIsHovering] = useState(false) const [isLoading, setIsLoading] = useState(false)