Skip to content

fix(viewer): make the graph view honour the active filters - #123

Open
njordr wants to merge 1 commit into
zircote:mainfrom
njordr:fix/graph-respects-filters
Open

njordr wants to merge 1 commit into
zircote:mainfrom
njordr:fix/graph-respects-filters

Conversation

@njordr

@njordr njordr commented Sep 14, 2026

Copy link
Copy Markdown

The bug

Pick any facet in the viewer and the graph ignores it. The header updates to 2 of 3 records, the list, cards and timeline all narrow, and the canvas keeps drawing the whole collection.

renderListView, renderCardView and renderTimelineView all read state.filteredRecords. renderGraphView reads state.graph, which the generator builds once over every record and which no filter touches.

The fix

Filter the graph against the visible records before the layout runs.

  • A node survives when its record survives the filter.
  • An edge survives when both of its ends do.
  • A placeholder node is the one case that needs care. It stands for a related reference to a record outside the collection, so it has no status, category, project or author to filter on and can never match a facet. It survives while the record pointing at it survives, which keeps a dangling reference visible instead of silently dropping it when no filter is active.

The empty state also told the wrong story: a filter matching nothing reported No relationships to display. It now separates that from a collection where nothing is related.

Checking it

With two records in one project and a third in another, selecting that project drops the graph from three nodes to two and keeps the edge between the pair. Clearing the filter restores the third.

make check passes: cargo fmt --check, cargo clippy -- -D warnings, and the full suite. The change is confined to templates/app.js, so no Rust test covers it; happy to add coverage if you have a preferred approach for the templates.

The list, card and timeline views all render from `state.filteredRecords`. The
graph view read `state.graph` instead, which the generator builds once over the
whole collection, so narrowing by status, category, project, author or tag left
the graph drawing every record. The header said "2 of 3 records" above a canvas
showing three.

Filter the graph against the visible records before laying it out. Placeholder
nodes, which stand for references to records outside the collection and carry no
facets of their own, survive while the record pointing at them does. An empty
graph now distinguishes "nothing matches the filters" from "nothing is related".
@njordr
njordr requested a review from zircote as a code owner September 14, 2026 15:26
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.

1 participant