feat: add source filter to knowledge graph visualization - #4640
Conversation
|
👋 Hi! This PR's description is missing some required sections from our PR template. Workflow runs won't be auto-approved until the description is updated. Missing sections:
Please update your PR description to include these sections, then push or re-save the description. The workflows will be approved on the next cycle. |
1 similar comment
|
👋 Hi! This PR's description is missing some required sections from our PR template. Workflow runs won't be auto-approved until the description is updated. Missing sections:
Please update your PR description to include these sections, then push or re-save the description. The workflows will be approved on the next cycle. |
a5c3dfe to
82750d4
Compare
82750d4 to
b234244
Compare
UX Review (Fable 5, fork) — 🟡 CONCERNSUX-level review of UX-Verdict: CONCERNS Selecting a source with no entities collapses the whole panel — filter control included — into a misleading "No graph data yet" dead end. Watch
Suggestions
[UX-REVIEWED] a336b01 |
GPT 5.6 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
Design Review (Fable 5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS Real hairball problem, solved at the right layer with the existing mentions→items→sources join pattern; proportionate and backward compatible. Suggestions
[DESIGN-REVIEWED] a336b01 |
First Principles Review (Fable 5, fork) — 🟡 CONCERNSPremise-level review of Reading the contract, intent file, patch, and the base handler and First-Principles-Verdict: CONCERNS The comma-separated multi-source What this change shipsIntent: let a user isolate the knowledge graph to one source so multi-source graphs stop being a hairball — an ADDITION (closes #4636).
Watch
Subtractions
[FIRST-PRINCIPLES-REVIEWED] a336b01 |
Opus 4.8 Review (fork) — ✅ no blocking findingsReviewed Review detailsBoth candidates are self-rated low confidence. Let me verify the two factual anchors. Candidate 1: Source IDs are Candidate 2: The unfiltered graph is built from No Step 2 finding grounds out: the No findings. [OPUS-REVIEWED] a336b01 |
Add a source_id query parameter to GET /api/knowledge/graph that filters entities to only those mentioned in items belonging to the specified sources. On the frontend, render a source dropdown in the graph toolbar when multiple sources exist, allowing users to isolate the graph to a single knowledge source. Backward compatible: omitting source_id returns the same result as before.
b234244 to
a336b01
Compare
Problem / Motivation
When multiple knowledge sources are registered, the graph visualization shows all entities from all sources mixed together. With many sources this becomes a dense hairball where it's hard to see the structure of any single source's entities and relationships.
Why it matters
Users who index several projects or document collections need to explore each source's entity graph independently. Without filtering, the visualization is unusable at scale — entities from unrelated sources obscure the relationships that matter.
What changed (motivation → approach → change)
Goal: Let users isolate the knowledge graph to a single source.
Approach: Filter at the entity level via the existing
mentions → items → sourcesrelationship chain. This avoids duplicating graph-building logic and reuses the same join pattern already used bylist_items.Changes:
src/kiro_crew/dashboard/handlers/knowledge.py): Added optionalsource_idquery parameter toGET /api/knowledge/graph. When set, only entities mentioned in items belonging to those sources are included. Parameterized SQL, backward compatible.website/src/pages/knowledge/KnowledgeGraph.tsx): Added aSimpleSelectsource filter dropdown in the graph toolbar. Only renders when 2+ sources exist. Selecting a source re-queries withsource_id.all_sourcesandfilter_by_sourcekeys with translations.Tests
test_source_id_filter_restricts_to_mentioned_entities— creates two sources with distinct entities, verifies filtering returns only the correct source's entitiestest_source_id_filter_with_no_mentions_returns_empty— verifies a source with no entity mentions returns an empty graphManual verification
Screenshots / video
(entity extraction was contended during testing). The UI change is a single
SimpleSelectdropdown added to the existing graph toolbar.Related Issues
Closes #4636
Checklist