Skip to content

Fix #36: filter and search on the Semantic memories panel#39

Merged
emp3thy merged 1 commit into
mainfrom
auto-fix/issue-36-semantic-filter-search
May 5, 2026
Merged

Fix #36: filter and search on the Semantic memories panel#39
emp3thy merged 1 commit into
mainfrom
auto-fix/issue-36-semantic-filter-search

Conversation

@emp3thy
Copy link
Copy Markdown
Owner

@emp3thy emp3thy commented May 4, 2026

Closes #36

Summary

Adds filter affordances to the /semantic panel, mirroring the existing reflection_filter_form.html pattern:

  • Scope toggleall (default) / project only / general only. The default preserves existing behavior (project-scope rows for the current project plus all general-scope rows). project only returns only project-scope rows for the current project; general only returns general-scope rows from any project.
  • Substring search — case-insensitive match on content via SQL LIKE. % and _ in user input are escaped (with ESCAPE '\') so they match literally rather than as wildcards.
  • HTMX-driven — filter form sits at the page level (matching reflections.html); the panel hx-includes the form so each re-render carries the current filter values. Form fires on change/keyup with a 200 ms debounce.

Files touched:

  • better_memory/services/semantic.py — extends list_for_project with optional scope_filter and search kwargs (default None preserves existing behavior; existing callers in ui/app.py and mcp/server.py continue to work unchanged).
  • better_memory/ui/app.py/semantic/panel reads scope_filter and search query params; unknown scope_filter values fall back to default. /semantic page passes empty initial_filters.
  • better_memory/ui/templates/fragments/semantic_filter_form.html (new) — scope select + search input.
  • better_memory/ui/templates/semantic.html — includes the filter form and adds hx-include="#semantic-filter-form" to the panel div.
  • Tests: 7 new service-level tests in tests/services/test_semantic.py (filter combinations, LIKE-wildcard escaping, empty-string handling) and 6 new route-level tests in tests/ui/test_semantic.py.

All 65 semantic tests pass (52 pre-existing + 13 new). The 8 errors in tests/hooks/test_post_commit.py are pre-existing environmental signing failures, unrelated to this PR (verified on baseline).

The existing .filter-form CSS class already provides styling — no new CSS needed.

Confidence

~92%. The change strictly mirrors an existing, well-tested pattern (reflection_filter_form.html); the service-layer extension is additive with default None kwargs, so no existing callers change behavior.


This PR was generated by a scheduled Claude routine that scans open issues and opens PRs only when confidence ≥ 90%.


Generated by Claude Code

Adds a scope toggle ('all' / 'project only' / 'general only') and a
case-insensitive substring search to /semantic, mirroring the existing
reflection_filter_form pattern. Filters are server-side via SQL LIKE on
content, with %/_ in the user input escaped so they match literally.

https://claude.ai/code/session_01XMuYrQYtmog2kqWtTmkDxz
Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Claude BugBot Analysis

No bugs found in the changes. The SQL parameterisation is correct with no injection risk, the LIKE-escape logic properly escapes \, %, and _ and the ESCAPE '\' clause resolves to the single character \ in SQLite as intended, scope-filter branching always produces a non-empty WHERE clause with the right number of bound parameters, and the Flask input validation correctly normalises and whitelist-checks scope_filter before passing it to the service layer.

No bugs were detected in this PR.

@emp3thy emp3thy merged commit edf42de into main May 5, 2026
3 checks passed
@emp3thy emp3thy deleted the auto-fix/issue-36-semantic-filter-search branch May 5, 2026 18:53
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.

Filter / search on the Semantic memories panel

2 participants