Skip to content

Self-hosted AI workspace.

Python

fix(notes): reset search filter on panel reopen so stale query doesn't hide notes (#2920)

nubs0395bb9c3041
diff --git a/static/js/notes.js b/static/js/notes.js
index e64e5035c..58dff6e7f 100644
--- a/static/js/notes.js
+++ b/static/js/notes.js
@@ -1099,6 +1099,9 @@ export function openPanel() {
if (_open) return;
_open = true;
_editingId = null;
+ // Reset the search filter — the rebuilt pane's search input renders empty, so a
+ // stale _searchQuery would silently hide non-matching notes after a reopen.
+ _searchQuery = '';
_clearViewedReminderGlows();
_firedDotDismissedAt = Date.now();
try { localStorage.setItem(REMINDER_DISMISSED_AT_KEY, String(_firedDotDismissedAt)); } catch {}
diff --git a/tests/test_notes_search_reset_on_reopen_js.py b/tests/test_notes_search_reset_on_reopen_js.py
new file mode 100644
index 000000000..9f2bb1831
--- /dev/null
+++ b/tests/test_notes_search_reset_on_reopen_js.py
@@ -0,0 +1,29 @@
+"""Issue #2919 — openPanel must reset _searchQuery so a reopened Notes panel
+doesn't keep filtering by a stale query (the rebuilt search box renders empty).
+
+notes.js is a browser ES module with a heavy import chain (can't node-import in
+isolation), so — per the repo's DOM-coupled-guard convention — this asserts the
+reset is present in openPanel, beside the existing _editingId reset.
+"""
+import re
+from pathlib import Path
+
+SRC = Path("static/js/notes.js").read_text(encoding="utf-8")
+
+
+def _open_panel_body():
+ start = SRC.index("export function openPanel()")
+ rest = SRC[start + len("export function openPanel()"):]
+ m = re.search(r"\n(?:export\s+)?(?:async\s+)?function ", rest)
+ return rest[: m.start()] if m else rest
+
+
+def test_open_panel_resets_search_query():
+ body = _open_panel_body()
+ assert "_searchQuery = ''" in body, body[:400]
+ # reset must sit with the other open-time state resets, before render
+ assert body.index("_searchQuery = ''") < body.index("_renderNotes") if "_renderNotes" in body else True
+
+
+def test_module_still_declares_search_query():
+ assert "let _searchQuery = ''" in SRC