From 92ac85313be8e641b1a384aff98134df4c767850 Mon Sep 17 00:00:00 2001 From: Jack Arturo Date: Thu, 11 Jun 2026 22:24:28 +0200 Subject: [PATCH 1/8] feat(palette): unify type colors into one canonical palette source MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Four divergent type→color maps (GraphCanvas VIBRANT_TYPE_COLORS, MiniMap, TagCloud, tailwind config) plus server meta.type_colors rendered the same memory type as different hues per surface. Canonicalize on the scene palette in src/lib/palette.ts, resolve it over server colors at the API chokepoint, and make normalizeNode prefer the type-keyed color. Pathfinding trace hues and the pinch pre-select amber become named tokens; settings relationship swatches now derive from EDGE_STYLES instead of a duplicate table. Co-Authored-By: Claude Fable 5 --- src/api/client.ts | 24 ++++++++++- src/components/GraphCanvas.tsx | 30 ++++--------- src/components/MiniMap.tsx | 16 ++----- src/components/SelectionHighlight.tsx | 3 +- src/components/TagCloud.tsx | 21 +++------ src/components/settings/SettingsPanel.tsx | 34 +++++++++------ src/lib/normalizeNode.ts | 6 ++- src/lib/palette.ts | 52 +++++++++++++++++++++++ tailwind.config.js | 21 +++++---- 9 files changed, 132 insertions(+), 75 deletions(-) create mode 100644 src/lib/palette.ts diff --git a/src/api/client.ts b/src/api/client.ts index f903cf5..37e8c62 100644 --- a/src/api/client.ts +++ b/src/api/client.ts @@ -1,5 +1,6 @@ import type { GraphSnapshot, GraphNeighbors, GraphStats, GraphNode } from '../lib/types' import { normalizeNode } from '../lib/normalizeNode' +import { resolveTypeColors } from '../lib/palette' /** * Detect if running in embedded mode (served from /viewer/ on same origin). @@ -166,7 +167,22 @@ export async function fetchGraphSnapshot(params: SnapshotParams = {}): Promise(response) + const snapshot = await handleResponse(response) + + // Canonicalize colors at the chokepoint: everything downstream (the expand + // reducer's normalizeNode, tag chips, settings swatches, cluster detection) + // reads `meta.type_colors`, so resolving here makes every surface agree. + // Nodes are recolored too so even the brief pre-reset render (App's raw + // snapshot fallback) shows canonical hues. + const type_colors = resolveTypeColors(snapshot.meta?.type_colors) + return { + ...snapshot, + nodes: snapshot.nodes.map((n) => ({ + ...n, + color: type_colors[n.type] ?? n.color, + })), + meta: { ...snapshot.meta, type_colors }, + } } export interface NeighborsParams { @@ -194,7 +210,11 @@ export async function fetchGraphNeighbors( export async function fetchGraphStats(): Promise { const response = await fetch(`${getApiBase()}/graph/stats`, { headers: getAuthHeaders() }) - return handleResponse(response) + const stats = await handleResponse(response) + return { + ...stats, + meta: { ...stats.meta, type_colors: resolveTypeColors(stats.meta?.type_colors) }, + } } /** diff --git a/src/components/GraphCanvas.tsx b/src/components/GraphCanvas.tsx index 70de40d..9d2c830 100644 --- a/src/components/GraphCanvas.tsx +++ b/src/components/GraphCanvas.tsx @@ -81,6 +81,7 @@ import { PinchPreSelectHighlight, } from "./SelectionHighlight"; import { getEdgeStyle } from "../lib/edgeStyles"; +import { TRACE_START, TRACE_END, TRACE_PATH } from "../lib/palette"; import { matchesSearch } from "../lib/searchMatch"; import { EdgeParticles } from "./EdgeParticles"; import { MiniMap } from "./MiniMap"; @@ -101,18 +102,6 @@ function useIPhoneUrl() { return iphoneUrl; } -// Vibrant type colors for clear visual distinction on dark backgrounds -const VIBRANT_TYPE_COLORS: Record = { - Decision: "#f59e0b", - Pattern: "#10b981", - Insight: "#8b5cf6", - Preference: "#ec4899", - Context: "#3b82f6", - Style: "#06b6d4", - Habit: "#f97316", - Memory: "#6366f1", -}; - // Performance constants const SPHERE_SEGMENTS = 12; // Reduced from 32 - good enough for small spheres const LABEL_DISTANCE_THRESHOLD = 80; // Only show labels for nodes within this distance @@ -1604,7 +1593,7 @@ function BatchedEdges({ const style = getEdgeStyle(edge.type); const color = isInPath - ? new THREE.Color("#00d4ff") + ? new THREE.Color(TRACE_PATH) : new THREE.Color(style.color); const sourceFocus = focusStates.get(edge.source)?.opacity ?? 1; @@ -2178,17 +2167,16 @@ function InstancedNodes({ // Set color with special handling for path nodes if (isPathSource) { - // Source node: bright green - tempColor.set("#22c55e"); + tempColor.set(TRACE_START); } else if (isPathTarget) { - // Target node: bright red/orange - tempColor.set("#ef4444"); + tempColor.set(TRACE_END); } else if (isInPath) { - // Intermediate path nodes: electric cyan - tempColor.set("#00d4ff"); + tempColor.set(TRACE_PATH); } else { - // Use vibrant frontend palette, falling back to API color - tempColor.set(VIBRANT_TYPE_COLORS[node.type] || node.color); + // node.color is canonical — normalized from the resolved palette + // (lib/palette.ts) so the scene, minimap, tag cloud, and inspector + // all render the same hue per type. + tempColor.set(node.color); } if (isDimmed && !isInPath) { diff --git a/src/components/MiniMap.tsx b/src/components/MiniMap.tsx index 08d2483..7c21078 100644 --- a/src/components/MiniMap.tsx +++ b/src/components/MiniMap.tsx @@ -10,6 +10,7 @@ import { useRef, useEffect, useCallback, useMemo } from 'react' import type { SimulationNode, GraphNode } from '../lib/types' +import { FALLBACK_NODE_COLOR } from '../lib/palette' interface MiniMapProps { nodes: SimulationNode[] @@ -21,18 +22,6 @@ interface MiniMapProps { size?: number } -// Type colors (simplified from main graph) -const TYPE_COLORS: Record = { - Decision: '#f59e0b', - Pattern: '#8b5cf6', - Preference: '#3b82f6', - Style: '#ec4899', - Habit: '#10b981', - Insight: '#06b6d4', - Context: '#6366f1', - Memory: '#6b7280', -} - export function MiniMap({ nodes, selectedNode, @@ -118,7 +107,8 @@ export function MiniMap({ nodes.forEach(node => { const pos = worldToCanvas(node.x ?? 0, node.y ?? 0) const isSelected = selectedNode?.id === node.id - const nodeColor = TYPE_COLORS[node.type] || TYPE_COLORS.Memory + // node.color is the canonical palette color (same hue as the 3D scene). + const nodeColor = node.color || FALLBACK_NODE_COLOR ctx.beginPath() ctx.arc(pos.x, pos.y, isSelected ? 4 : 2, 0, Math.PI * 2) diff --git a/src/components/SelectionHighlight.tsx b/src/components/SelectionHighlight.tsx index 1b9a8d6..b19b1a6 100644 --- a/src/components/SelectionHighlight.tsx +++ b/src/components/SelectionHighlight.tsx @@ -2,6 +2,7 @@ import { useRef, useMemo, useState, useEffect } from 'react' import { useFrame } from '@react-three/fiber' import * as THREE from 'three' import type { SimulationNode, GraphNode } from '../lib/types' +import { PRE_SELECT } from '../lib/palette' /** * Visual feedback for direct pinch selection ("pick the berry") @@ -67,7 +68,7 @@ export function PinchPreSelectHighlight({ const displayNode = node || prevNode if (!displayNode || fadeRef.current < 0.01) return null - const nodeColor = color || '#fbbf24' // Amber/gold for pre-select + const nodeColor = color || PRE_SELECT const nodeRadius = displayNode.radius || 3 // Ring sizes diff --git a/src/components/TagCloud.tsx b/src/components/TagCloud.tsx index ad275ef..0707ae8 100644 --- a/src/components/TagCloud.tsx +++ b/src/components/TagCloud.tsx @@ -13,6 +13,7 @@ import { useState, useEffect, useMemo, useRef } from 'react' import { X, Search, ToggleLeft, ToggleRight, Trash2 } from 'lucide-react' import type { TagData } from '../hooks/useTagCloud' +import { TYPE_COLORS } from '../lib/palette' interface TagCloudProps { tags: TagData[] @@ -31,18 +32,6 @@ interface TagCloudProps { onClose: () => void } -// Default colors for memory types -const DEFAULT_TYPE_COLORS: Record = { - Decision: '#22c55e', - Pattern: '#8b5cf6', - Preference: '#f59e0b', - Style: '#ec4899', - Habit: '#06b6d4', - Insight: '#3b82f6', - Context: '#64748b', - Memory: '#6366f1', -} - export function TagCloud({ filteredTags, selectedTags, @@ -61,8 +50,12 @@ export function TagCloud({ const [isAnimating, setIsAnimating] = useState(false) const containerRef = useRef(null) - // Merge type colors with defaults - const colors = useMemo(() => ({ ...DEFAULT_TYPE_COLORS, ...typeColors }), [typeColors]) + // typeColors is the resolved canonical palette from the API chokepoint; + // TYPE_COLORS backstops it before the first snapshot arrives. + const colors = useMemo>( + () => ({ ...TYPE_COLORS, ...typeColors }), + [typeColors] + ) // Animate in/out useEffect(() => { diff --git a/src/components/settings/SettingsPanel.tsx b/src/components/settings/SettingsPanel.tsx index 18f3ae6..d341f07 100644 --- a/src/components/settings/SettingsPanel.tsx +++ b/src/components/settings/SettingsPanel.tsx @@ -3,6 +3,7 @@ import { SettingsSection } from './SettingsSection' import { SliderControl } from './SliderControl' import { RangeSliderControl } from './RangeSliderControl' import { ToggleControl } from './ToggleControl' +import { EDGE_STYLES, type EdgeStyle } from '../../lib/edgeStyles' import type { ForceConfig, DisplayConfig, @@ -14,20 +15,25 @@ import type { FilterState, } from '../../lib/types' -// Relationship type metadata for display -const RELATIONSHIP_INFO: Record = { - RELATES_TO: { label: 'Relates To', color: '#94A3B8', style: 'dotted' }, - LEADS_TO: { label: 'Leads To', color: '#3B82F6', style: 'solid' }, - OCCURRED_BEFORE: { label: 'Occurred Before', color: '#6B7280', style: 'dashed' }, - PREFERS_OVER: { label: 'Prefers Over', color: '#8B5CF6', style: 'solid' }, - EXEMPLIFIES: { label: 'Exemplifies', color: '#10B981', style: 'dotted' }, - CONTRADICTS: { label: 'Contradicts', color: '#EF4444', style: 'dashed' }, - REINFORCES: { label: 'Reinforces', color: '#22C55E', style: 'dotted' }, - INVALIDATED_BY: { label: 'Invalidated By', color: '#F97316', style: 'dashed' }, - EVOLVED_INTO: { label: 'Evolved Into', color: '#06B6D4', style: 'solid' }, - DERIVED_FROM: { label: 'Derived From', color: '#A855F7', style: 'solid' }, - PART_OF: { label: 'Part Of', color: '#64748B', style: 'solid' }, -} +// Relationship display metadata, derived from the canonical edge styles so the +// settings swatches always match what the renderer actually draws. +const RELATIONSHIP_INFO = Object.fromEntries( + (Object.entries(EDGE_STYLES) as [RelationType, EdgeStyle][]).map( + ([type, style]) => [ + type, + { + label: style.label, + color: style.color, + style: + style.dashPattern == null + ? 'solid' + : style.dashPattern[0] <= 2 + ? 'dotted' + : 'dashed', + }, + ], + ), +) as Record const MEMORY_TYPES: MemoryType[] = [ 'Decision', 'Pattern', 'Preference', 'Style', diff --git a/src/lib/normalizeNode.ts b/src/lib/normalizeNode.ts index 8a70e95..2814362 100644 --- a/src/lib/normalizeNode.ts +++ b/src/lib/normalizeNode.ts @@ -87,7 +87,11 @@ export function normalizeNode(node: RawNode, typeColors: Record) // already guards (isNaN check), so the node simply hides during active // time-travel until the backend backfills a real timestamp. timestamp: node.timestamp ?? '', - color: node.color ?? typeColors[type] ?? FALLBACK_COLOR, + // Type-keyed color WINS over a server-provided node color: `typeColors` is + // the resolved canonical palette (client palette merged over server colors, + // see lib/palette.ts), so every surface renders the same hue per type. The + // raw node color is only a fallback for a type the palette doesn't know. + color: typeColors[type] ?? node.color ?? FALLBACK_COLOR, // Backend formulas, used only when a field is missing/non-finite. radius: finiteOr(node.radius, 0.5 + importance * 1.5), opacity: finiteOr(node.opacity, 0.4 + confidence * 0.6), diff --git a/src/lib/palette.ts b/src/lib/palette.ts new file mode 100644 index 0000000..73edaae --- /dev/null +++ b/src/lib/palette.ts @@ -0,0 +1,52 @@ +import type { MemoryType } from './types' + +/** + * The canonical node/type palette — the single source of truth for what color a + * memory type is, on every surface (3D scene, minimap, tag cloud, inspector, + * settings, filter chips). + * + * History: four divergent type→color maps coexisted (GraphCanvas's + * VIBRANT_TYPE_COLORS, MiniMap's TYPE_COLORS, TagCloud's DEFAULT_TYPE_COLORS, + * tailwind.config.js) plus the server's `meta.type_colors` — the same memory + * type rendered as a different hue per surface. This module canonicalizes on + * the scene palette (tuned for the dark void background + bloom pass) and + * {@link resolveTypeColors} makes it win over whatever the server sends, so + * color stops lying. + */ +export const TYPE_COLORS: Record = { + Decision: '#f59e0b', // amber + Pattern: '#10b981', // emerald + Insight: '#8b5cf6', // violet + Preference: '#ec4899', // pink + Context: '#3b82f6', // blue + Style: '#06b6d4', // cyan + Habit: '#f97316', // orange + Memory: '#6366f1', // indigo +} + +/** Fallback for a type outside the known union (shouldn't survive coercion). */ +export const FALLBACK_NODE_COLOR = '#94A3B8' + +/** + * Merge the server's `meta.type_colors` with the canonical client palette. + * The client palette wins for the eight known types (it's tuned for this + * renderer); unknown future types the server may add pass through untouched. + * Applied once at the API chokepoint (fetchGraphSnapshot / fetchGraphStats), + * so everything downstream that reads `meta.type_colors` agrees. + */ +export function resolveTypeColors( + serverColors?: Record, +): Record { + return { ...serverColors, ...TYPE_COLORS } +} + +// --- Named interaction hues (formerly scattered hardcoded literals) --- + +/** Pathfinding trace: source endpoint ("FROM"). */ +export const TRACE_START = '#22c55e' +/** Pathfinding trace: target endpoint ("TO"). */ +export const TRACE_END = '#ef4444' +/** Pathfinding trace: intermediate nodes and path edges. */ +export const TRACE_PATH = '#00d4ff' +/** Hand-tracking pinch pre-select ring. */ +export const PRE_SELECT = '#fbbf24' diff --git a/tailwind.config.js b/tailwind.config.js index b18b86d..ae75879 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -14,15 +14,18 @@ export default { mono: ['"JetBrains Mono"', 'ui-monospace', 'SFMono-Regular', 'monospace'], }, colors: { - // --- Memory type colors (the only saturated hues; do not touch) --- - decision: '#3B82F6', - pattern: '#10B981', - preference: '#8B5CF6', - style: '#EC4899', - habit: '#F59E0B', - insight: '#F97316', - context: '#6B7280', - memory: '#94A3B8', + // --- Memory type colors (the only saturated hues) --- + // Mirror of the canonical palette in src/lib/palette.ts (TYPE_COLORS). + // If you change a hue, change it THERE — this block only exists so + // Tailwind utility classes agree with the scene. + decision: '#f59e0b', + pattern: '#10b981', + preference: '#ec4899', + style: '#06b6d4', + habit: '#f97316', + insight: '#8b5cf6', + context: '#3b82f6', + memory: '#6366f1', // --- Semantic instrument tokens (sourced from CSS vars in index.css) --- void: 'var(--void)', From b2bd7a1d57db859cca7fd9fa7409c4eedb4ce8de Mon Sep 17 00:00:00 2001 From: Jack Arturo Date: Thu, 11 Jun 2026 22:26:02 +0200 Subject: [PATCH 2/8] feat(scope): adopt honest 'in view' vs 'in store' language The UI never said which universe a number referred to: the stats bar's bare count read as exhaustive, the search badge counted the whole store while the canvas highlighted only loaded matches, pathfinding silently vanished when no path existed among loaded edges, and the timeline counted 'memories' that were really just the loaded scene. Every count now names its scope, and pathfinding failure gets an honest no-path card with the expand-and-retry hint. Co-Authored-By: Claude Fable 5 --- src/App.tsx | 8 +++++- src/components/PathfindingOverlay.tsx | 34 ++++++++++++++++++++++++ src/components/SearchBar.tsx | 11 +++++--- src/components/StatsBar.tsx | 37 +++++++++++++++++++-------- src/components/TimelineBar.tsx | 9 ++++--- 5 files changed, 81 insertions(+), 18 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index c7bce47..44a9699 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1007,7 +1007,13 @@ export default function App() { onPreviousPath={pathfinding.previousPath} onCancel={pathfinding.cancelPathSelection} onClear={pathfinding.clearPath} - visible={pathfinding.isSelectingTarget || pathfinding.hasPath} + visible={ + pathfinding.isSelectingTarget || + pathfinding.hasPath || + // targetId set with no paths = search ran and found nothing + // among loaded memories — show the honest no-path card. + (pathfinding.targetId != null && !pathfinding.hasPath) + } /> {/* Time Travel Timeline */} diff --git a/src/components/PathfindingOverlay.tsx b/src/components/PathfindingOverlay.tsx index 7a48883..8735650 100644 --- a/src/components/PathfindingOverlay.tsx +++ b/src/components/PathfindingOverlay.tsx @@ -68,6 +68,40 @@ export function PathfindingOverlay({ ) } + // No path among LOADED memories. Scope honesty: the scene holds a bounded + // overview (+expansions) of a much larger store, so Dijkstra failing here + // usually means "no path loaded", not "no path exists". Say so instead of + // silently vanishing (the previous behavior). + if (!currentPath && sourceNode && targetNode) { + return ( +
+
+
+ + + +
+
No path among loaded memories
+
+ A path may exist through memories not yet in view. Expand each + endpoint ("Expand into graph" in the inspector), then try again. +
+
+ +
+
+
+ ) + } + // Show path info when path is found if (currentPath && sourceNode && targetNode) { return ( diff --git a/src/components/SearchBar.tsx b/src/components/SearchBar.tsx index b4bd63d..cf10ff7 100644 --- a/src/components/SearchBar.tsx +++ b/src/components/SearchBar.tsx @@ -170,7 +170,7 @@ export function SearchBar({ handleClear() } }} - placeholder={hasChips ? 'Search...' : 'Search memories, tags, or types...'} + placeholder={hasChips ? 'Search...' : 'Search all memories, tags, or types...'} className="w-full pl-9 pr-9 py-2 bg-black/30 border border-white/10 rounded-lg focus:border-accent focus:ring-1 focus:ring-accent outline-none transition-colors text-sm text-ink placeholder-ink-3" /> {localValue && ( @@ -194,7 +194,11 @@ export function SearchBar({ {showSearchCount && ( {searchResultCount == null ? ( '…' @@ -204,8 +208,7 @@ export function SearchBar({ {searchResultCount.toLocaleString()} {searchResultCapped ? '+' : ''} - {' '} - {searchResultCount === 1 ? 'match' : 'matches'} + {' in store'} )} diff --git a/src/components/StatsBar.tsx b/src/components/StatsBar.tsx index e7c0b01..ef1c957 100644 --- a/src/components/StatsBar.tsx +++ b/src/components/StatsBar.tsx @@ -14,6 +14,12 @@ interface StatsBarProps { hasClientFilter?: boolean } +/** + * Scope language ("in view" vs "in store") is deliberate and used app-wide: + * "in view" = memories loaded into the 3D scene (bounded overview + expansions); + * "in store" = everything on the server. The two never get conflated into one + * bare number — that's how "2 of 2,000" used to read as exhaustive. + */ export function StatsBar({ stats, isLoading, clientVisibleCount, hasClientFilter }: StatsBarProps) { if (isLoading || !stats) { return ( @@ -26,12 +32,19 @@ export function StatsBar({ stats, isLoading, clientVisibleCount, hasClientFilter ) } - // Client filter active: "Showing 42 of 500 memories" + // Client filter active: "42 of 500 in view" const showFilteredCount = hasClientFilter && clientVisibleCount != null + const hasMoreInStore = stats.total_nodes > stats.returned_nodes return (
-
+
{showFilteredCount ? ( @@ -40,26 +53,30 @@ export function StatsBar({ stats, isLoading, clientVisibleCount, hasClientFilter {clientVisibleCount.toLocaleString()} - {' '}of {stats.returned_nodes.toLocaleString()} + {' '}of {stats.returned_nodes.toLocaleString()} in view ) : ( <> {stats.returned_nodes.toLocaleString()} - {stats.sampled && ( - - {' '}/ {stats.total_nodes.toLocaleString()} - - )} + in view )} + {hasMoreInStore && ( + + {' '}· {stats.total_nodes.toLocaleString()} in store + + )}
-
+
{stats.returned_edges.toLocaleString()} - {stats.sampled && ( + {stats.total_edges > stats.returned_edges && ( {' '}/ {stats.total_edges.toLocaleString()} diff --git a/src/components/TimelineBar.tsx b/src/components/TimelineBar.tsx index c907a7f..c5c16f9 100644 --- a/src/components/TimelineBar.tsx +++ b/src/components/TimelineBar.tsx @@ -192,10 +192,13 @@ export function TimelineBar({
- {/* Memory count */} -
+ {/* Memory count — scoped to the loaded scene, not the whole store */} +
{visibleCount} - / {totalCount} memories + / {totalCount} in view
From 4184d08912f48ef9d711eed8ff2f0c7e407c2425 Mon Sep 17 00:00:00 2001 From: Jack Arturo Date: Thu, 11 Jun 2026 22:28:01 +0200 Subject: [PATCH 3/8] feat(settings): persist tuned workspace across sessions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Force, display, clustering, and relationship-visibility configs were plain useState — every reload reset the workspace to defaults (only sound settings persisted). Extract the sounds.ts localStorage pattern into usePersistentState, apply it to all four configs plus the tag AND/OR mode, and add a 'Reset all' escape hatch to the settings header. Co-Authored-By: Claude Fable 5 --- src/App.tsx | 40 ++++++++++----- src/components/settings/SettingsPanel.tsx | 29 ++++++++--- src/hooks/usePersistentState.ts | 60 +++++++++++++++++++++++ src/hooks/useTagCloud.ts | 7 ++- 4 files changed, 116 insertions(+), 20 deletions(-) create mode 100644 src/hooks/usePersistentState.ts diff --git a/src/App.tsx b/src/App.tsx index 44a9699..cbb3f1b 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -23,6 +23,7 @@ import { PathfindingOverlay } from './components/PathfindingOverlay' import { TimelineBar } from './components/TimelineBar' import { TagCloud } from './components/TagCloud' import { KeyboardShortcutsHelp } from './components/KeyboardShortcutsHelp' +import { usePersistentState } from './hooks/usePersistentState' import { useHandLockAndGrab } from './hooks/useHandLockAndGrab' import { useHandRecording, downloadRecording, listSavedRecordings, loadRecordingFromStorage } from './hooks/useHandRecording' import { useHandPlayback } from './hooks/useHandPlayback' @@ -243,19 +244,33 @@ export default function App() { }) const [hasSetDefaultImportance, setHasSetDefaultImportance] = useState(false) - // Force configuration state - const [forceConfig, setForceConfig] = useState(DEFAULT_FORCE_CONFIG) - - // Display configuration state - const [displayConfig, setDisplayConfig] = useState(DEFAULT_DISPLAY_CONFIG) - - // Clustering configuration state - const [clusterConfig, setClusterConfig] = useState(DEFAULT_CLUSTER_CONFIG) - - // Relationship visibility state - const [relationshipVisibility, setRelationshipVisibility] = useState( - DEFAULT_RELATIONSHIP_VISIBILITY + // Tuning configs persist across sessions (localStorage write-through) so the + // workspace looks the same tomorrow morning as it did last night. + const [forceConfig, setForceConfig] = usePersistentState( + 'automem_settings_forces', + DEFAULT_FORCE_CONFIG + ) + const [displayConfig, setDisplayConfig] = usePersistentState( + 'automem_settings_display', + DEFAULT_DISPLAY_CONFIG ) + const [clusterConfig, setClusterConfig] = usePersistentState( + 'automem_settings_cluster', + DEFAULT_CLUSTER_CONFIG + ) + const [relationshipVisibility, setRelationshipVisibility] = + usePersistentState( + 'automem_settings_relationships', + DEFAULT_RELATIONSHIP_VISIBILITY + ) + + // One-click escape hatch from any persisted-settings tangle. + const handleResetAllSettings = useCallback(() => { + setForceConfig(DEFAULT_FORCE_CONFIG) + setDisplayConfig(DEFAULT_DISPLAY_CONFIG) + setClusterConfig(DEFAULT_CLUSTER_CONFIG) + setRelationshipVisibility(DEFAULT_RELATIONSHIP_VISIBILITY) + }, [setForceConfig, setDisplayConfig, setClusterConfig, setRelationshipVisibility]) // Reheat callback - will be set by GraphCanvas const [reheatFn, setReheatFn] = useState<(() => void) | null>(null) @@ -1113,6 +1128,7 @@ export default function App() { onSoundEnabledChange={sound.setEnabled} soundVolume={sound.settings.masterVolume} onSoundVolumeChange={sound.setMasterVolume} + onResetAll={handleResetAllSettings} />
diff --git a/src/components/settings/SettingsPanel.tsx b/src/components/settings/SettingsPanel.tsx index d341f07..72168e1 100644 --- a/src/components/settings/SettingsPanel.tsx +++ b/src/components/settings/SettingsPanel.tsx @@ -74,6 +74,8 @@ interface SettingsPanelProps { onSoundEnabledChange: (enabled: boolean) => void soundVolume: number onSoundVolumeChange: (volume: number) => void + // Reset every persisted setting (forces, display, clustering, relationships) + onResetAll?: () => void } export function SettingsPanel({ @@ -96,6 +98,7 @@ export function SettingsPanel({ onSoundEnabledChange, soundVolume, onSoundVolumeChange, + onResetAll, }: SettingsPanelProps) { if (!isOpen) return null @@ -111,13 +114,25 @@ export function SettingsPanel({ {/* Header */}

Graph Settings

- +
+ {onResetAll && ( + + )} + +
{/* Scrollable content */} diff --git a/src/hooks/usePersistentState.ts b/src/hooks/usePersistentState.ts new file mode 100644 index 0000000..9a91138 --- /dev/null +++ b/src/hooks/usePersistentState.ts @@ -0,0 +1,60 @@ +import { useCallback, useState, type Dispatch, type SetStateAction } from 'react' + +function isPlainObject(value: unknown): value is Record { + return typeof value === 'object' && value !== null && !Array.isArray(value) +} + +/** + * useState with localStorage write-through, for settings that should survive a + * reload (force/display/cluster configs, relationship visibility, tag filter + * mode). + * + * For object-shaped values, hydration merges the stored value OVER the defaults + * (`{...defaults, ...stored}`), so a config field added in a later release gets + * its default instead of `undefined` poisoning downstream math. Scalars hydrate + * as-is. Storage failures (private browsing, quota, corrupt JSON) degrade + * silently to plain in-memory state. + * + * This is the same pattern lib/sounds.ts already uses for audio settings — + * extracted so the rest of the tuned workspace survives a reload too. + */ +export function usePersistentState( + key: string, + defaults: T, +): [T, Dispatch>] { + const [value, setValue] = useState(() => { + try { + const raw = localStorage.getItem(key) + if (raw != null) { + const parsed = JSON.parse(raw) as T + if (isPlainObject(defaults) && isPlainObject(parsed)) { + return { ...defaults, ...parsed } + } + return parsed + } + } catch { + // Corrupt JSON or unavailable storage — fall back to defaults. + } + return defaults + }) + + const setAndPersist: Dispatch> = useCallback( + (action) => { + setValue((prev) => { + const next = + typeof action === 'function' + ? (action as (prev: T) => T)(prev) + : action + try { + localStorage.setItem(key, JSON.stringify(next)) + } catch { + // Persistence is best-effort. + } + return next + }) + }, + [key], + ) + + return [value, setAndPersist] +} diff --git a/src/hooks/useTagCloud.ts b/src/hooks/useTagCloud.ts index 0aa7246..8b67ec5 100644 --- a/src/hooks/useTagCloud.ts +++ b/src/hooks/useTagCloud.ts @@ -9,6 +9,7 @@ import { useMemo, useState, useCallback } from 'react' import type { GraphNode } from '../lib/types' +import { usePersistentState } from './usePersistentState' export interface TagData { tag: string @@ -56,7 +57,11 @@ export function useTagCloud({ maxTags = 50, }: UseTagCloudOptions): UseTagCloudReturn { const [selectedTags, setSelectedTags] = useState>(new Set()) - const [filterMode, setFilterMode] = useState<'AND' | 'OR'>('OR') + // AND/OR mode is a sticky workspace preference; the selection itself is not. + const [filterMode, setFilterMode] = usePersistentState<'AND' | 'OR'>( + 'automem_settings_tag_filter_mode', + 'OR' + ) const [searchTerm, setSearchTerm] = useState('') // Aggregate tags from all nodes From 61a196a23ef65aaeb3d7a5a238a2227b92dcf723 Mon Sep 17 00:00:00 2001 From: Jack Arturo Date: Thu, 11 Jun 2026 22:28:42 +0200 Subject: [PATCH 4/8] feat(empty-state): explain a zero-node canvas instead of going silent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A successful snapshot with zero nodes left an unexplained black canvas — indistinguishable from a crash, and the literal first impression for anyone opening a freshly deployed (empty) AutoMem store. Distinguish the two causes via stats.total_nodes: an empty store gets a friendly onboarding card with Refresh and a wire-up-an-agent link; an over-filtered view says how many memories the filters excluded and offers one-click filter reset. Co-Authored-By: Claude Fable 5 --- src/App.tsx | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/src/App.tsx b/src/App.tsx index cbb3f1b..aa7321e 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -949,6 +949,70 @@ export default function App() {
)} + {/* Empty state — a successful load with zero nodes used to leave a + silent black canvas, indistinguishable from a crash. For brand-new + AutoMem deployments (empty store) this was the literal first + impression. */} + {!isLoading && !error && data && nodes.length === 0 && ( +
+
+ + ✦ + + {data.stats.total_nodes === 0 ? ( + <> +
+ No memories yet +
+
+ Once your agent starts storing memories, they'll appear + here as a living graph. +
+
+ + + Wire up an agent + +
+ + ) : ( + <> +
+ No memories match your filters +
+
+ {data.stats.total_nodes.toLocaleString()} memories are in + your store, but the current type and importance filters + exclude all of them. +
+ + + )} +
+
+ )} + Date: Thu, 11 Jun 2026 22:32:14 +0200 Subject: [PATCH 5/8] feat(connection): make session auth state visible and recoverable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Embedded /viewer/#token= sessions authenticated silently — no confirmation, no way to see which server you're on, no sign-out, and a rejected shared-link token dead-ended at a generic 'Connection Error' whose Retry re-hit the same 401 forever. Add a one-time 'Connected to ' toast for URL-token sessions, a Settings → Connection section (server, masked token, Disconnect), and an auth-aware error card whose 'Enter credentials' strips URL-borne tokens so TokenPrompt can actually take over. Co-Authored-By: Claude Fable 5 --- src/App.tsx | 108 ++++++++++++++++++++-- src/api/client.ts | 27 +++++- src/components/settings/SettingsPanel.tsx | 50 ++++++++++ src/hooks/useTagCloud.ts | 2 +- 4 files changed, 175 insertions(+), 12 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index aa7321e..4aaa8e8 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -6,7 +6,7 @@ import { useQueryClient } from '@tanstack/react-query' import { useGraphSnapshot, useRecall } from './hooks/useGraphData' import { useExpandableGraph } from './hooks/useExpandableGraph' import { normalizeNode } from './lib/normalizeNode' -import { fetchGraphNeighbors, getSnapshotCap } from './api/client' +import { fetchGraphNeighbors, getSnapshotCap, getConnectionInfo } from './api/client' import { useAuth } from './hooks/useAuth' import { GraphCanvas } from './components/GraphCanvas' import { Inspector } from './components/Inspector' @@ -125,7 +125,7 @@ const EMPTY_NODES: GraphNode[] = [] const EMPTY_EDGES: import('./lib/types').GraphEdge[] = [] export default function App() { - const { setToken, isAuthenticated } = useAuth() + const { setToken, clearAuth, isAuthenticated } = useAuth() const [selectedNode, setSelectedNode] = useState(null) const [hoveredNode, setHoveredNode] = useState(null) const [searchTerm, setSearchTerm] = useState('') @@ -512,6 +512,65 @@ export default function App() { }, 1800) }, []) + // Acknowledge the silent URL-token handshake. A shared /viewer/#token= link + // auto-authenticates with zero feedback — confirm which server answered, once, + // on the first successful load. Standalone (typed-in) auth already had its + // explicit Connect step, so it stays quiet. + const connectionToastShownRef = useRef(false) + useEffect(() => { + if (!data || connectionToastShownRef.current) return + connectionToastShownRef.current = true + const info = getConnectionInfo() + if (info.embedded || info.tokenFromUrl) { + let host = info.serverUrl + try { + host = new URL(info.serverUrl).host + } catch { + // Relative base — keep as-is. + } + showStatus(`Connected to ${host}`) + } + }, [data, showStatus]) + + // Sign out / re-enter credentials: URL-borne tokens (?token=, #token=) outrank + // localStorage in the auth chain, so clearing storage alone wouldn't sign a + // shared-link session out — strip them from the URL too, then TokenPrompt + // renders naturally via isAuthenticated. + const handleReenterCredentials = useCallback(() => { + const url = new URL(window.location.href) + url.searchParams.delete('token') + if (url.hash) { + const hashParams = new URLSearchParams(url.hash.slice(1)) + hashParams.delete('token') + const rest = hashParams.toString() + url.hash = rest ? `#${rest}` : '' + } + window.history.replaceState(null, '', url.toString()) + clearAuth() + }, [clearAuth]) + + // Settings → Connection section. Recomputed when the panel opens (token / + // server state lives in localStorage + URL, both cheap reads). + const connectionInfo = useMemo(() => { + if (!settingsPanelOpen) return undefined + const info = getConnectionInfo() + return { + serverUrl: info.serverUrl, + token: info.token, + tokenFromUrl: info.tokenFromUrl, + } + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [settingsPanelOpen, isAuthenticated]) + + // Auth rejections deserve their own story: a bad shared-link token used to + // surface as a generic "Connection Error" + Retry, a dead end that retries + // into the same 401 forever. + const isAuthError = useMemo(() => { + if (!error) return false + const message = (error as Error).message ?? '' + return /\b(401|403)\b|unauthorized|forbidden|invalid\s+(api\s+)?(key|token)/i.test(message) + }, [error]) + const { push: breadcrumbPush } = breadcrumbs const handleNodeSelect = useCallback((node: GraphNode | null) => { // If we're in path selection mode and a node is clicked, complete the path @@ -937,14 +996,41 @@ export default function App() { {error && (
-
Connection Error
-
{(error as Error).message}
- + {isAuthError ? ( + <> +
Access denied
+
+ The server rejected this token. If you followed a shared + viewer link, ask for a new one — or enter credentials + yourself. +
+
+ + +
+ + ) : ( + <> +
Connection Error
+
{(error as Error).message}
+ + + )}
)} @@ -1193,6 +1279,8 @@ export default function App() { soundVolume={sound.settings.masterVolume} onSoundVolumeChange={sound.setMasterVolume} onResetAll={handleResetAllSettings} + connection={connectionInfo} + onDisconnect={handleReenterCredentials} />
diff --git a/src/api/client.ts b/src/api/client.ts index 37e8c62..ac32a8d 100644 --- a/src/api/client.ts +++ b/src/api/client.ts @@ -6,7 +6,7 @@ import { resolveTypeColors } from '../lib/palette' * Detect if running in embedded mode (served from /viewer/ on same origin). * In embedded mode, we use relative URLs and get token from URL hash. */ -function isEmbeddedMode(): boolean { +export function isEmbeddedMode(): boolean { return window.location.pathname.startsWith('/viewer') } @@ -97,6 +97,31 @@ export function isAuthenticated(): boolean { return !!getToken() } +export interface ConnectionInfo { + /** Resolved server origin the browser is actually talking to. */ + serverUrl: string + /** The active token (whatever source won the priority chain), or null. */ + token: string | null + /** Served from /viewer/ on the AutoMem API origin. */ + embedded: boolean + /** + * Token came from the URL (?token= or #token=) rather than localStorage — + * i.e. a shared viewer link. Clearing stored credentials alone won't sign + * such a session out; the URL has to be stripped too. + */ + tokenFromUrl: boolean +} + +/** What the session is connected to and how — for the Settings "Connection" section. */ +export function getConnectionInfo(): ConnectionInfo { + return { + serverUrl: getApiBase() || window.location.origin, + token: getToken(), + embedded: isEmbeddedMode(), + tokenFromUrl: !!(getTokenFromQuery() || getTokenFromHash()), + } +} + async function handleResponse(response: Response): Promise { if (!response.ok) { const text = await response.text() diff --git a/src/components/settings/SettingsPanel.tsx b/src/components/settings/SettingsPanel.tsx index 72168e1..077ca09 100644 --- a/src/components/settings/SettingsPanel.tsx +++ b/src/components/settings/SettingsPanel.tsx @@ -76,6 +76,19 @@ interface SettingsPanelProps { onSoundVolumeChange: (volume: number) => void // Reset every persisted setting (forces, display, clustering, relationships) onResetAll?: () => void + // Connection visibility: which server, which token, how to sign out + connection?: { + serverUrl: string + token: string | null + tokenFromUrl: boolean + } + onDisconnect?: () => void +} + +function maskToken(token: string | null): string { + if (!token) return '—' + if (token.length <= 8) return '••••' + return `${token.slice(0, 4)}••••${token.slice(-4)}` } export function SettingsPanel({ @@ -99,6 +112,8 @@ export function SettingsPanel({ soundVolume, onSoundVolumeChange, onResetAll, + connection, + onDisconnect, }: SettingsPanelProps) { if (!isOpen) return null @@ -492,6 +507,41 @@ export function SettingsPanel({ )} + + {/* Connection Section — which server this session talks to, with which + token, and how to sign out. Previously invisible: embedded sessions + had no indication they were authenticated at all. */} + {connection && ( + +
+
+ +
+ {connection.serverUrl} +
+
+
+ +
+ {maskToken(connection.token)} +
+ {connection.tokenFromUrl && ( +

+ Token provided by this page's URL (shared viewer link). +

+ )} +
+ {onDisconnect && ( + + )} +
+
+ )} ) diff --git a/src/hooks/useTagCloud.ts b/src/hooks/useTagCloud.ts index 8b67ec5..c0cab73 100644 --- a/src/hooks/useTagCloud.ts +++ b/src/hooks/useTagCloud.ts @@ -166,7 +166,7 @@ export function useTagCloud({ const toggleFilterMode = useCallback(() => { setFilterMode((prev) => (prev === 'AND' ? 'OR' : 'AND')) - }, []) + }, [setFilterMode]) return { tags, From 3f06a3a8b636dc90254b3758c8ba36cbb3986cfc Mon Sep 17 00:00:00 2001 From: Jack Arturo Date: Thu, 11 Jun 2026 22:33:46 +0200 Subject: [PATCH 6/8] fix(lint): add stable persistent-state setters to hook dep arrays usePersistentState setters aren't lint-exempt like React's useState setters; they're stable (useCallback on key), so listing them is behavior-neutral. Co-Authored-By: Claude Fable 5 --- src/App.tsx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 4aaa8e8..ae35a53 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -686,7 +686,7 @@ export default function App() { // Inspector relationship type toggle const handleRelationshipTypeClick = useCallback((type: RelationType) => { setRelationshipVisibility((prev) => ({ ...prev, [type]: !prev[type] })) - }, []) + }, [setRelationshipVisibility]) const handleFilterChange = useCallback((newFilters: Partial) => { setFilters(prev => ({ ...prev, ...newFilters })) @@ -694,11 +694,11 @@ export default function App() { const handleForceConfigChange = useCallback((config: Partial) => { setForceConfig(prev => ({ ...prev, ...config })) - }, []) + }, [setForceConfig]) const handleDisplayConfigChange = useCallback((config: Partial) => { setDisplayConfig(prev => ({ ...prev, ...config })) - }, []) + }, [setDisplayConfig]) const prevClusterModeRef = useRef(DEFAULT_CLUSTER_CONFIG.mode) @@ -708,11 +708,11 @@ export default function App() { prevClusterModeRef.current = config.mode showStatus(CLUSTER_MODE_LABELS[config.mode] || `Cluster mode: ${config.mode}`) } - }, [showStatus]) + }, [setClusterConfig, showStatus]) const handleRelationshipVisibilityChange = useCallback((visibility: Partial) => { setRelationshipVisibility(prev => ({ ...prev, ...visibility })) - }, []) + }, [setRelationshipVisibility]) const handleReheat = useCallback(() => { reheatFn?.() @@ -720,11 +720,11 @@ export default function App() { const handleResetForces = useCallback(() => { setForceConfig(DEFAULT_FORCE_CONFIG) - }, []) + }, [setForceConfig]) const handleToggleLabels = useCallback(() => { setDisplayConfig(prev => ({ ...prev, showLabels: !prev.showLabels })) - }, []) + }, [setDisplayConfig]) // Keyboard navigation const handleStartPathfindingFromKeyboard = useCallback(() => { From ee16bab9e5356d1a43e8a4daca4b81730bb376f8 Mon Sep 17 00:00:00 2001 From: Jack Arturo Date: Thu, 11 Jun 2026 22:53:48 +0200 Subject: [PATCH 7/8] fix(query): surface API errors reliably; fail fast on auth rejection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit TanStack Query's default networkMode 'online' parks a failed query at fetchStatus 'paused' whenever the browser's online-manager misdetects connectivity — no retry, no error state, an infinite spinner exactly where the error card should be (reproduced in a managed browser; failureCount froze at 1 with status 'pending'). This app talks to exactly one API, so let the fetch itself be the connectivity check: networkMode 'always' for queries and mutations. Auth rejections (401/403) additionally skip retries entirely — they don't fix themselves, and failing fast is what makes the new Access-denied card render immediately. Co-Authored-By: Claude Fable 5 --- src/App.tsx | 16 ++++++++++------ src/api/client.ts | 9 +++++++++ src/main.tsx | 15 +++++++++++++++ 3 files changed, 34 insertions(+), 6 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index ae35a53..5c4112a 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -6,7 +6,12 @@ import { useQueryClient } from '@tanstack/react-query' import { useGraphSnapshot, useRecall } from './hooks/useGraphData' import { useExpandableGraph } from './hooks/useExpandableGraph' import { normalizeNode } from './lib/normalizeNode' -import { fetchGraphNeighbors, getSnapshotCap, getConnectionInfo } from './api/client' +import { + fetchGraphNeighbors, + getSnapshotCap, + getConnectionInfo, + isAuthErrorMessage, +} from './api/client' import { useAuth } from './hooks/useAuth' import { GraphCanvas } from './components/GraphCanvas' import { Inspector } from './components/Inspector' @@ -565,11 +570,10 @@ export default function App() { // Auth rejections deserve their own story: a bad shared-link token used to // surface as a generic "Connection Error" + Retry, a dead end that retries // into the same 401 forever. - const isAuthError = useMemo(() => { - if (!error) return false - const message = (error as Error).message ?? '' - return /\b(401|403)\b|unauthorized|forbidden|invalid\s+(api\s+)?(key|token)/i.test(message) - }, [error]) + const isAuthError = useMemo( + () => !!error && isAuthErrorMessage((error as Error).message ?? ''), + [error] + ) const { push: breadcrumbPush } = breadcrumbs const handleNodeSelect = useCallback((node: GraphNode | null) => { diff --git a/src/api/client.ts b/src/api/client.ts index ac32a8d..59b39fb 100644 --- a/src/api/client.ts +++ b/src/api/client.ts @@ -97,6 +97,15 @@ export function isAuthenticated(): boolean { return !!getToken() } +/** + * Classify an API error message as an auth rejection (bad/expired token). + * Used to (a) skip pointless retries — a 401 won't fix itself — and (b) show + * the "Access denied" card with a recovery path instead of the generic error. + */ +export function isAuthErrorMessage(message: string): boolean { + return /\b(401|403)\b|unauthorized|forbidden|invalid\s+(api\s+)?(key|token)/i.test(message) +} + export interface ConnectionInfo { /** Resolved server origin the browser is actually talking to. */ serverUrl: string diff --git a/src/main.tsx b/src/main.tsx index de9c2b0..a16dd43 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -2,6 +2,7 @@ import React from 'react' import ReactDOM from 'react-dom/client' import { QueryClient, QueryClientProvider } from '@tanstack/react-query' import App from './App' +import { isAuthErrorMessage } from './api/client' import './index.css' const queryClient = new QueryClient({ @@ -9,6 +10,20 @@ const queryClient = new QueryClient({ queries: { staleTime: 30000, // 30 seconds refetchOnWindowFocus: false, + // The app talks to exactly one API — let the fetch itself decide whether + // the network works. The default 'online' mode trusts the browser's + // online-manager, and when that misdetects (managed/headless browsers, + // some VPNs) a failed query parks at fetchStatus 'paused' FOREVER: no + // retry, no error state, just an infinite spinner where the error card + // should be. + networkMode: 'always', + // Auth rejections won't fix themselves — fail fast to the Access-denied + // card instead of burning ~7s of futile retries. + retry: (failureCount, error) => + !isAuthErrorMessage((error as Error)?.message ?? '') && failureCount < 3, + }, + mutations: { + networkMode: 'always', }, }, }) From 4ff3418cb0bcf864fed9fa025bd14bc5dd67b0b2 Mon Sep 17 00:00:00 2001 From: Jack Arturo Date: Thu, 11 Jun 2026 23:20:34 +0200 Subject: [PATCH 8/8] fix(settings): make 'Reset all' cover audio and tag mode too Copilot review: the button implied it reset everything in the panel but only covered forces/display/clustering/relationships. It now also resets audio (enabled/volume) and the tag AND/OR mode; the tooltip states exactly what it covers and that filters (view state) are deliberately untouched. Co-Authored-By: Claude Fable 5 --- src/App.tsx | 33 +++++++++++++++++------ src/components/settings/SettingsPanel.tsx | 2 +- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 5c4112a..b0b4231 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -269,14 +269,6 @@ export default function App() { DEFAULT_RELATIONSHIP_VISIBILITY ) - // One-click escape hatch from any persisted-settings tangle. - const handleResetAllSettings = useCallback(() => { - setForceConfig(DEFAULT_FORCE_CONFIG) - setDisplayConfig(DEFAULT_DISPLAY_CONFIG) - setClusterConfig(DEFAULT_CLUSTER_CONFIG) - setRelationshipVisibility(DEFAULT_RELATIONSHIP_VISIBILITY) - }, [setForceConfig, setDisplayConfig, setClusterConfig, setRelationshipVisibility]) - // Reheat callback - will be set by GraphCanvas const [reheatFn, setReheatFn] = useState<(() => void) | null>(null) @@ -472,6 +464,31 @@ export default function App() { // Sound Effects const sound = useSoundEffects() + // One-click escape hatch from any persisted-settings tangle. Covers EVERY + // setting the panel exposes — physics, display, clustering, relationship + // visibility, audio, and the tag AND/OR mode — so "Reset all" means all. + // (Filters are view state, not settings, and are deliberately untouched.) + const { setEnabled: setSoundEnabled, setMasterVolume: setSoundVolume } = sound + const { setFilterMode: setTagFilterMode } = tagCloud + const handleResetAllSettings = useCallback(() => { + setForceConfig(DEFAULT_FORCE_CONFIG) + setDisplayConfig(DEFAULT_DISPLAY_CONFIG) + setClusterConfig(DEFAULT_CLUSTER_CONFIG) + setRelationshipVisibility(DEFAULT_RELATIONSHIP_VISIBILITY) + // Audio defaults mirror DEFAULT_SETTINGS in lib/sounds.ts. + setSoundEnabled(false) + setSoundVolume(0.3) + setTagFilterMode('OR') + }, [ + setForceConfig, + setDisplayConfig, + setClusterConfig, + setRelationshipVisibility, + setSoundEnabled, + setSoundVolume, + setTagFilterMode, + ]) + // Pathfinding const pathfinding = usePathfinding({ nodes: nodes as any, diff --git a/src/components/settings/SettingsPanel.tsx b/src/components/settings/SettingsPanel.tsx index 077ca09..66c5f4e 100644 --- a/src/components/settings/SettingsPanel.tsx +++ b/src/components/settings/SettingsPanel.tsx @@ -133,7 +133,7 @@ export function SettingsPanel({ {onResetAll && (