Skip to content

feat(memory-graph): add in-graph node search#1308

Open
abhay-codes07 wants to merge 1 commit into
supermemoryai:mainfrom
abhay-codes07:feat/graph-node-search
Open

feat(memory-graph): add in-graph node search#1308
abhay-codes07 wants to merge 1 commit into
supermemoryai:mainfrom
abhay-codes07:feat/graph-node-search

Conversation

@abhay-codes07

Copy link
Copy Markdown
Contributor

What

Adds node search to the memory graph. The graph already supports pan, zoom, fit, center, and arrow-key navigation between neighbours, but there was no way to jump to a specific document or memory by name. On a graph with a few hundred nodes, finding "the Berlin memory" meant scanning the canvas by eye.

This adds a search box to the bottom-left control stack that finds nodes by text, highlights where the matches are, and steps through them.

How it works

  • searchNodes(nodes, query) — a pure, case-insensitive substring matcher over document title/summary/type and memory memory/content. Matches are ranked (primary-field prefix > primary-field substring > supporting-copy substring), with the input order as a stable tiebreaker so results never depend on where the force simulation dropped a node. Exported from the package for advanced/headless use.
  • SearchControl — an input styled to match the existing navigation controls, with a live current/total counter, prev/next steppers, and a clear button.
  • Wiring in MemoryGraph — the focused match is selected and centered through the same selectAndCenter path arrow-key navigation already uses, and the documents behind every match are highlighted (a memory match highlights its parent document) by merging into the existing highlightDocumentIds pipeline rather than adding a parallel one.

Interaction

  • / focuses the search box, consistent with the existing single-key shortcuts (z fit, c center, +/- zoom)
  • Enter / Shift+Enter step to the next / previous match
  • Escape clears the search
  • The existing keyboard handlers already ignore events originating from inputs, so typing a query never triggers the fit/zoom/arrow shortcuts

Configuration

On by default. Embedders can hide it with showSearch={false} or relabel the placeholder with searchPlaceholder. I defaulted it on because it is the point of the PR and it degrades gracefully (it renders only when there are nodes), but if you would rather ship it opt-in I am happy to flip the default.

Testing

  • searchNodes: empty/whitespace query, case-insensitivity, memory text vs content matching, primary-over-secondary ranking, prefix-over-substring ranking, stable order for ties, null-title/missing-content tolerance
  • SearchControl (mounted): typing forwards to the handler, counter shows 1-based position and total, zero-results state, Enter/Shift+Enter stepping, Escape and clear-button behaviour, disabled steppers with no matches
  • 14 new tests; full package suite green (202 passing), tsc --noEmit clean, biome check clean, vite build succeeds

cc @MaheshtheDev @ishaanxgupta

The graph had no way to find a specific document or memory once the node
count grew past a screenful. You could pan, zoom, fit, and arrow-key
between neighbours, but locating "the Berlin memory" in a few hundred
nodes meant eyeballing the canvas.

Add a search box to the bottom-left control stack that finds nodes by
text and steps through the matches:

- searchNodes(nodes, query): a pure, case-insensitive substring matcher
  over document title/summary/type and memory text/content. Results are
  ranked (title/memory prefix, then substring, then supporting copy) with
  input order as a stable tiebreaker, so ordering never depends on where
  the force simulation happened to drop a node. Exported for advanced use.
- SearchControl: an input styled like the existing navigation controls,
  with a live "current/total" counter, prev/next steppers, and a clear
  button. Enter / Shift+Enter cycle matches, Escape clears.
- Wiring in MemoryGraph: the focused match is selected and centered
  (reusing the same selectAndCenter path as arrow-key navigation), and the
  documents behind all matches are highlighted (memory matches highlight
  their parent document) by merging into the existing highlightDocumentIds
  pipeline. Press "/" to focus the box, consistent with the existing
  single-key shortcuts.

The box is on by default; embedders can hide it with showSearch={false}
or relabel it with searchPlaceholder. Existing keyboard handlers already
ignore events originating from inputs, so typing a query never triggers
the fit/zoom/arrow shortcuts.

Tested: 14 new tests (searchNodes ranking/empty-query/null-field cases;
SearchControl typing, Enter/Shift+Enter/Escape, clear, counter, disabled
states). Full package suite green (202 tests), tsc --noEmit clean, biome
clean, vite build succeeds.
Copilot AI review requested due to automatic review settings July 18, 2026 08:23

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

2 participants