Skip to content

Make memory graph cluster colors configurable#1162

Open
advaitpaliwal wants to merge 1 commit into
supermemoryai:mainfrom
advaitpaliwal:codex/configurable-memory-graph-cluster-colors
Open

Make memory graph cluster colors configurable#1162
advaitpaliwal wants to merge 1 commit into
supermemoryai:mainfrom
advaitpaliwal:codex/configurable-memory-graph-cluster-colors

Conversation

@advaitpaliwal

Copy link
Copy Markdown

Summary

  • add clusterColors to the memory graph theme contract
  • read cluster palettes from --graph-cluster-colors or colors.clusterColors
  • use the configured palette for node cluster assignment and legend swatches

Why

Consumers can already override most graph colors through CSS variables or the colors prop, but cluster colors were still hard-coded in graph data and legend rendering. This lets host apps fully align the graph palette without patching package internals.

Validation

  • bunx biome check packages/memory-graph/src/types.ts packages/memory-graph/src/constants.ts packages/memory-graph/src/hooks/use-graph-theme.ts packages/memory-graph/src/hooks/use-graph-data.ts packages/memory-graph/src/components/legend.tsx
  • bun run check-types in packages/memory-graph
  • bun run test in packages/memory-graph (172 passed)

@advaitpaliwal advaitpaliwal marked this pull request as ready for review June 25, 2026 02:40
@graphite-app graphite-app Bot requested a review from Dhravya June 25, 2026 02:40
Comment on lines +85 to +88
const swatches =
colors.clusterColors.length > 0
? colors.clusterColors.slice(0, 5)
: [colors.memStrokeDefault]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent fallback behavior when clusterColors is empty. The legend shows [colors.memStrokeDefault] (single color), but the graph data functions in use-graph-data.ts fall back to DEFAULT_CLUSTER_COLORS (full palette). This causes a mismatch where the legend could display one color while the actual graph uses the default multi-color palette.

// Fix: Use consistent fallback
const swatches =
	colors.clusterColors.length > 0
		? colors.clusterColors.slice(0, 5)
		: DEFAULT_CLUSTER_COLORS.slice(0, 5)

This ensures the legend accurately represents the colors actually used in the graph when clusterColors is explicitly set to an empty array via overrides.

Suggested change
const swatches =
colors.clusterColors.length > 0
? colors.clusterColors.slice(0, 5)
: [colors.memStrokeDefault]
const swatches =
colors.clusterColors.length > 0
? colors.clusterColors.slice(0, 5)
: DEFAULT_CLUSTER_COLORS.slice(0, 5)

Spotted by Graphite

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant