From 8956da61bb596a83d2ca65be86ed61df1935e82e Mon Sep 17 00:00:00 2001 From: jreakin Date: Mon, 23 Mar 2026 09:03:40 -0500 Subject: [PATCH] fix(web): add 15 missing NodeLabel colors/sizes, escape table names, schema sync MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add NODE_COLORS and NODE_SIZES entries for all 15 multi-language labels (Struct, Trait, Impl, TypeAlias, Const, Static, Namespace, Union, Typedef, Macro, Property, Record, Delegate, Annotation, Constructor, Template) — fixes Record completeness - Escape table names in count/lookup queries with escapeTableName() to prevent silent failures for backtick-required tables - Add HAS_PROPERTY and ACCESSES to RelationshipType union - Update initPromise after db recreation in loadGraphToLbug so subsequent initLbug() calls return fresh db/conn refs Co-Authored-By: Claude Opus 4.6 (1M context) --- gitnexus-web/src/core/graph/types.ts | 2 ++ gitnexus-web/src/core/lbug/lbug-adapter.ts | 9 ++++-- gitnexus-web/src/lib/constants.ts | 32 ++++++++++++++++++++++ 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/gitnexus-web/src/core/graph/types.ts b/gitnexus-web/src/core/graph/types.ts index 27f3b7038..ed6da9a47 100644 --- a/gitnexus-web/src/core/graph/types.ts +++ b/gitnexus-web/src/core/graph/types.ts @@ -72,6 +72,8 @@ export type RelationshipType = | 'IMPLEMENTS' | 'EXTENDS' | 'HAS_METHOD' + | 'HAS_PROPERTY' + | 'ACCESSES' | 'MEMBER_OF' | 'STEP_IN_PROCESS' diff --git a/gitnexus-web/src/core/lbug/lbug-adapter.ts b/gitnexus-web/src/core/lbug/lbug-adapter.ts index ce6b8beeb..b3cca57af 100644 --- a/gitnexus-web/src/core/lbug/lbug-adapter.ts +++ b/gitnexus-web/src/core/lbug/lbug-adapter.ts @@ -121,6 +121,9 @@ export const loadGraphToLbug = async ( db = new lbugModule.Database(':memory:', BUFFER_POOL_SIZE); conn = new lbugModule.Connection(db); + // Update initPromise so subsequent initLbug() calls return the fresh db/conn + initPromise = Promise.resolve({ db, conn, lbug: lbugModule }); + // Re-run schema creation for (let i = 0; i < SCHEMA_QUERIES.length; i++) { try { @@ -282,7 +285,7 @@ export const loadGraphToLbug = async ( let totalNodes = 0; for (const tableName of NODE_TABLES) { try { - const countRes = await conn.query(`MATCH (n:${tableName}) RETURN count(n) AS cnt`); + const countRes = await conn.query(`MATCH (n:${escapeTableName(tableName)}) RETURN count(n) AS cnt`); const countRows = await countRes.getAllRows(); const countRow = countRows[0]; const count = countRow ? (countRow.cnt ?? countRow[0] ?? 0) : 0; @@ -440,7 +443,7 @@ export const getLbugStats = async (): Promise<{ nodes: number; edges: number }> let totalNodes = 0; for (const tableName of NODE_TABLES) { try { - const nodeResult = await conn.query(`MATCH (n:${tableName}) RETURN count(n) AS cnt`); + const nodeResult = await conn.query(`MATCH (n:${escapeTableName(tableName)}) RETURN count(n) AS cnt`); const nodeRows = await nodeResult.getAllRows(); const nodeRow = nodeRows[0]; totalNodes += Number(nodeRow?.cnt ?? nodeRow?.[0] ?? 0); @@ -583,7 +586,7 @@ export const testArrayParams = async (): Promise<{ success: boolean; error?: str let testNodeId: string | null = null; for (const tableName of NODE_TABLES) { try { - const nodeResult = await conn.query(`MATCH (n:${tableName}) RETURN n.id AS id LIMIT 1`); + const nodeResult = await conn.query(`MATCH (n:${escapeTableName(tableName)}) RETURN n.id AS id LIMIT 1`); const nodeRows = await nodeResult.getAllRows(); const nodeRow = nodeRows[0]; if (nodeRow) { diff --git a/gitnexus-web/src/lib/constants.ts b/gitnexus-web/src/lib/constants.ts index 201198624..4e2c57afa 100644 --- a/gitnexus-web/src/lib/constants.ts +++ b/gitnexus-web/src/lib/constants.ts @@ -20,6 +20,22 @@ export const NODE_COLORS: Record = { Community: '#818cf8', // Indigo light - cluster indicator Process: '#f43f5e', // Rose - execution flow indicator Section: '#60a5fa', // Blue light - structural section + Struct: '#f59e0b', // Amber - like Class + Trait: '#ec4899', // Pink - like Interface + Impl: '#14b8a6', // Teal - like Method + TypeAlias: '#a78bfa', // Violet light - like Type + Const: '#64748b', // Slate - like Variable + Static: '#64748b', // Slate - like Variable + Namespace: '#7c3aed', // Violet - like Module + Union: '#f97316', // Orange - like Enum + Typedef: '#a78bfa', // Violet light - like Type + Macro: '#eab308', // Yellow - like Decorator + Property: '#64748b', // Slate - like Variable + Record: '#f59e0b', // Amber - like Class + Delegate: '#14b8a6', // Teal - like Method + Annotation: '#eab308', // Yellow - like Decorator + Constructor: '#10b981', // Emerald - like Function + Template: '#a78bfa', // Violet light - like Type }; // Node sizes by type - clear visual hierarchy with dramatic size differences @@ -43,6 +59,22 @@ export const NODE_SIZES: Record = { Community: 0, // Hidden by default - metadata node Process: 0, // Hidden by default - metadata node Section: 8, // Structural section - similar to Folder + Struct: 8, // Like Class + Trait: 7, // Like Interface + Impl: 3, // Like Method + TypeAlias: 3, // Like Type + Const: 2, // Like Variable + Static: 2, // Like Variable + Namespace: 13, // Like Module + Union: 5, // Like Enum + Typedef: 3, // Like Type + Macro: 2, // Like Decorator + Property: 2, // Like Variable + Record: 8, // Like Class + Delegate: 3, // Like Method + Annotation: 2, // Like Decorator + Constructor: 4, // Like Function + Template: 3, // Like Type }; // Community color palette for cluster-based coloring