Commit 602f39c
committed
dashboard: fix Memories tab project filter returning zero results (#87)
The Memories tab project filter showed zero results for any selected
project, even though 'All projects' worked and History's filter worked.
Root cause was an identity-vs-path mismatch:
- enumerate_memory_projects() resolves stored memories.project_path
values through resolve_project_identity() into 'git:<hash>' /
'dir:<sha256>' identities and returns those to the frontend as
ProjectRow.identity (db.rs:1367-1481).
- MemoryBrowser sends p.identity as the filter value
(packages/dashboard/src/components/MemoryBrowser/MemoryBrowser.tsx:352).
- get_memories() and get_memory_stats() filtered with
'project_path = ?1' against the raw stored filesystem path
(db.rs:1586, 1786, 1855, 1863). 'git:abc123' never equals
'/Users/.../my-repo' so every projects-filtered query returned 0
rows.
History worked because session_matches_filter() compares the row's
already-resolved project_identity, not the raw path (db.rs:2206-2230).
Fix uses Option B from the reporter (chrisolszewski) — resolve the
incoming identity → all matching project_path values inside the DB
layer and filter with IN (?, ?, ...) instead of equality. This is the
cleanest of the three options because:
- Identity is the canonical concept. A 'git:<hash>' covers multiple
worktrees and clones of the same repo, all writing to the same
shared cortexkit memory pool but under different raw project_path
values. Sending p.primary_path from the frontend (Option A,
one-line fix) would silently miss memories written from other
clones with the same identity.
- Backward compatible. If the filter value is a legacy raw path
(older dashboard build, external caller), no rows resolve to it
as an identity and we fall back to filtering by that single value
— matching pre-fix behavior.
- No migration risk. No frontend churn beyond fixing the bug.
- Aligns with how History already works.
Changes:
- Add resolve_paths_for_memory_filter() helper that maps an
identity (or legacy path) to the concrete set of project_path
values to query against.
- Add build_in_placeholders() helper for parameterized IN clauses.
- Refactor get_memories() to resolve identity once at entry and
build dynamic IN-placeholder clauses; threads through both
FTS-fallback branches.
- Refactor get_memory_stats() to share a path-IN clause across
total/active/permanent/archived/with_embeddings/categories
queries, eliminating the previous 6 hard-coded WHERE
project_path = ?1 sites.
Tests: 8 new in memory_project_filter_tests covering the helper
plus end-to-end identity-filter behavior for both get_memories and
get_memory_stats. 72/72 dashboard tests pass.1 parent b05c2a4 commit 602f39c
1 file changed
Lines changed: 413 additions & 92 deletions
0 commit comments