feat(memory-graph): add in-graph node search#1308
Open
abhay-codes07 wants to merge 1 commit into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 documenttitle/summary/typeand memorymemory/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 livecurrent/totalcounter, prev/next steppers, and a clear button.MemoryGraph— the focused match is selected and centered through the sameselectAndCenterpath arrow-key navigation already uses, and the documents behind every match are highlighted (a memory match highlights its parent document) by merging into the existinghighlightDocumentIdspipeline rather than adding a parallel one.Interaction
/focuses the search box, consistent with the existing single-key shortcuts (zfit,ccenter,+/-zoom)Enter/Shift+Enterstep to the next / previous matchEscapeclears the searchConfiguration
On by default. Embedders can hide it with
showSearch={false}or relabel the placeholder withsearchPlaceholder. 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 toleranceSearchControl(mounted): typing forwards to the handler, counter shows 1-based position and total, zero-results state,Enter/Shift+Enterstepping,Escapeand clear-button behaviour, disabled steppers with no matchestsc --noEmitclean,biome checkclean,vite buildsucceedscc @MaheshtheDev @ishaanxgupta