Feat v0.4.7 note graph
All checks were successful
CI/CD / detect-changes (pull_request) Successful in 22s
CI/CD / test-frontend (pull_request) Successful in 5s
CI/CD / test-go-pg (pull_request) Successful in 2m48s
CI/CD / test-sqlite (pull_request) Successful in 3m5s
CI/CD / build-and-deploy (pull_request) Successful in 2m29s

Canvas force-directed graph view for notes surface. GET /graph API
endpoint returns all non-archived notes as nodes (with tags) and
resolved wikilinks as edges. Force simulation with repulsion,
attraction, and center gravity. Click focus dims unconnected nodes,
shift+click chains neighborhoods, double-click opens note. Hover
tooltips show title, tags, and connection count. Nodes colored by
folder (10-color palette), tag filter dims non-matching. Orphan
nodes shown with dashed stroke and hide toggle. Zoom/pan via scroll
wheel and mouse drag. Retina-aware canvas rendering with CSS
variable resolution via getComputedStyle.

Notes package 0.7.0 → 0.8.0.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-30 08:59:12 +00:00
parent 50d991001d
commit 6acfeab456
7 changed files with 615 additions and 24 deletions

View File

@@ -133,6 +133,10 @@ def on_request(req):
if method == "POST" and path == "/notes/move":
return _move_note(req)
# GET /graph — full graph data for visualization
if method == "GET" and path == "/graph":
return _get_graph()
# ── Link routes ──────────────────────────
# GET /links/:note_id — outgoing links
if method == "GET" and path.startswith("/links/"):
@@ -463,6 +467,44 @@ def _get_backlinks(note_id):
return _resp(200, {"data": items})
def _get_graph():
"""Return all non-archived notes as nodes and resolved links as edges."""
all_notes = db.query("notes", filters={"archived": 0}, limit=5000)
notes = all_notes or []
# batch-fetch tags
note_ids = [n.get("id", "") for n in notes]
tags_map = _tags_for_notes(note_ids)
# build nodes + id set for edge filtering
nodes = []
note_id_set = {}
for n in notes:
nid = n.get("id", "")
note_id_set[nid] = True
nodes.append({
"id": nid,
"title": n.get("title", "Untitled"),
"folder_id": _str(n.get("folder_id", "")),
"tags": tags_map.get(nid, []),
})
# fetch links, keep only resolved (both endpoints exist)
all_links = db.query("links", limit=10000)
edges = []
for link in (all_links or []):
src = _str(link.get("source_id", ""))
tgt = _str(link.get("target_id", ""))
if src and tgt and src in note_id_set and tgt in note_id_set:
edges.append({
"source": src,
"target": tgt,
"text": _str(link.get("link_text", "")),
})
return _resp(200, {"nodes": nodes, "edges": edges})
# ═══════════════════════════════════════════════
# Folder CRUD
# ═══════════════════════════════════════════════