Skip to content

Smart graph: option to show tags as nodes - #473

Merged
Leo310 merged 3 commits into
mainfrom
feat/graph-tag-nodes
Sep 11, 2026
Merged

Smart graph: option to show tags as nodes#473
Leo310 merged 3 commits into
mainfrom
feat/graph-tag-nodes

Conversation

@Leo310

@Leo310 Leo310 commented Sep 11, 2026

Copy link
Copy Markdown
Member

Resolves #288.

What

A new Scope → Tags toggle in the smart graph draws each tag as a node linked to every note that carries it, matching Obsidian's native graph with its Tags filter on.

  • Tag nodes use the theme's --graph-node-tag colour, size by how many notes carry them, and show "N notes" in the tooltip.
  • Clicking a tag node (or its context-menu entry) opens Obsidian's search on tag:#…, the same as clicking a tag in a note. The tag-search helper moved from MarkdownRenderer.svelte to utils/tagSearch.ts so chat and graph share it.
  • Tag edges are undirected (no arrowheads) and always drawn when tags are shown, independent of the wiki/semantic link toggles.
  • Tags match case-insensitively with the first-seen casing as label; a note mentioning a tag twice links to it once; nested tags are their own nodes.

Design: tags are a display layer

Tag nodes pull their notes together in the layout, but they never feed topic detection or the semantic scan:

  • Edges are a new "tag" EdgeType; getTopicEdges and the isolated/bridge heuristics only read wiki/semantic edges, so topics are unchanged.
  • graphTopologySignature ignores the tag layer, so flipping the toggle is a rebuild that hits every cache (partitions, hierarchy, ladder, semantic edges) instead of re-running Leiden.
  • buildCollapsedGraph passes tag nodes through untouched (never folded into Unsorted, kind preserved), tag edges are re-pointed to topic bubbles but not counted as crossing links, and resolveNodePaths hands chat no path for a tag.
  • applyWikiPatch diffs tag edges alongside wiki edges, so an unchanged tag layer stays a no-op and tag nodes never surface as added/removed/touched note paths.
  • Note counts shown to the user, the semantic-scan ceiling and the drift threshold count notes only.
  • A tag edge counts toward the tag's degree only (computeNodeDegrees, shared by the build, the fused recompute and the live patch). Note degree is the tie-breaker for topic representatives, so it stays exactly what it is without tags.

Verification

  • bun run check, format, lint, and the full unit suite (1662 tests) pass; new tests cover the builder, live patch, collapse and signature behaviour.
  • Live smoke in a slot vault: toggling the setting rebuilds the graph with green tag nodes and no console errors (screenshot below).

tags as nodes

(Screenshot lives on the orphan branch assets/pr-graph-tag-nodes; delete it after merge.)

AI assistance: written with AI coding agents from the maintainer's brief; reviewed and tested by the maintainer.

A new Scope toggle, "Tags", draws each tag as a node linked to every
note carrying it — the same picture as Obsidian's own graph with its
Tags filter on. Tag nodes take the theme's --graph-node-tag colour,
size by note count, open a tag: search on click, and get a matching
context-menu entry.

Tags are a display layer over the note graph: their edges are typed
"tag", excluded from topic detection and the semantic scan, and left
out of the topology signature, so toggling them never invalidates the
cached partitions, hierarchy or edges. They pass through topic
collapsing untouched, are never folded into the Unsorted bubble, and
hand no paths to chat selection. The live vault patch diffs tag edges
alongside wiki edges so an unchanged tag layer is still a no-op.

The tag-search helper moves out of MarkdownRenderer into
utils/tagSearch.ts so the chat and the graph share it.
GraphCanvas pre-splits links by drawable type before each frame and the
list only knew wiki and semantic, so tag edges were built, laid out and
counted but never drawn — and hovering a tag node highlighted nothing.
Leo310 added a commit that referenced this pull request Sep 11, 2026
@greptile-apps

greptile-apps Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds an optional smart-graph display layer that represents tags as themed nodes connected to their notes.

  • Adds tag-node construction, rendering, tooltips, search interactions, settings, and live graph updates.
  • Keeps tag nodes and edges out of semantic scans, topic detection, representative selection, note counts, and chat paths.
  • Preserves tags when topics are collapsed while excluding tag relationships from topic crossing-link counts.
  • Centralizes degree calculation so tag edges size tag nodes without changing note degree or topic representatives.
  • Adds focused tests for graph construction, topology signatures, live patches, collapsing, and degree behavior.

Confidence Score: 5/5

The PR appears safe to merge; no actionable new defect remains, and the previously reported topic-representative issue is fully fixed.

Tag edges now contribute degree only to tag nodes across full builds, semantic fusion, and live patches, so enabling tags no longer changes note degree or topic representatives. The remaining display-layer boundaries are consistently maintained.

Important Files Changed

Filename Overview
src/views/smart-graph/graphDataBuilder.ts Builds case-insensitive tag nodes and note-to-tag edges while keeping note degrees independent of tags.
src/components/graph/SmartGraphView.svelte Integrates the tag setting into graph rebuilds, semantic filtering, note counts, live updates, and tag search.
src/components/graph/GraphCanvas.svelte Adds tag-specific click, context-menu, preview, sizing, and edge handling.
src/components/graph/pixiRenderer.ts Renders themed tag nodes and always-visible undirected tag edges with note-count tooltips.
src/utils/graphUtils.ts Adds tag identity helpers, tag-independent topology signatures, and centralized degree computation.
src/utils/liveGraphPatch.ts Includes tag-layer changes in live patches without exposing synthetic tag identifiers as note paths.
src/utils/mergeNodes.ts Preserves tag nodes through topic collapsing and excludes them from note-path resolution.
src/utils/tagSearch.ts Extracts the existing Obsidian tag-search behavior for reuse by chat and graph interactions.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
    V[Filtered vault notes] --> W[Wiki edges]
    V --> S[Semantic edges]
    V --> G[Tag display layer]
    W --> T[Topic detection]
    S --> T
    W --> R[Graph rendering]
    S --> R
    G --> R
    G -. excluded .-> T
    G -. excluded .-> C[Semantic scan and chat paths]
Loading

Reviews (2): Last reviewed commit: "Smart graph: tag edges count toward tag ..." | Re-trigger Greptile

Comment thread src/views/smart-graph/graphDataBuilder.ts Outdated
Note degree breaks ties for a topic's representative, which anchors the
topic's fallback label, colour and the titles sent for naming. Letting
tag edges inflate it meant the display-only Tags toggle could re-label
topics whose membership hadn't changed. One shared computeNodeDegrees
now serves the full build, the fused recompute and the live patch: a
tag edge counts for its tag (how many notes carry it) and not for the
note.
@Leo310
Leo310 merged commit 293bf59 into main Sep 11, 2026
3 checks passed
@Leo310
Leo310 deleted the feat/graph-tag-nodes branch September 11, 2026 09:23
Leo310 added a commit that referenced this pull request Sep 11, 2026
Tags join the smart graph: a Scope → Tags toggle draws each tag as a node
linked to the notes that carry it (#473), tag edges feed topic detection
damped by tag breadth so status tags can't swallow a vault (#474), and a
topic's own tags are drawn inside its region (#476). The Inferred links
controls are disabled when no graph embedding index is selected, and
changing the index selection now rebuilds the graph (#475).

minAppVersion unchanged at 1.11.4. Nothing touched PROVIDER_TEMPLATES,
src/skills/defaults/, BUILT_IN_TOOL_IDS or CURATED_PLUGIN_INTEGRATIONS,
so the site's enumerable facts need no refresh.
Leo310 added a commit to s2b-dev/site that referenced this pull request Sep 11, 2026
Plugin 2.1.0 added a Scope → Tags toggle (s2b-dev/smart-second-brain#473,
#474, #476). The overview documents the control under Scope, tag nodes
under What's drawn, and a Tags shape topics section under Topics. The
how-it-works page now lists three edge kinds and the topic-detection
weights (1 + log2 links, 1/√breadth for tags, 0.7 × cosine), plus the
half-of-its-notes bar for a tag to count as a topic's own.
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.

Include option to show tags as nodes in the graph

1 participant