From 883640e20cd01b64abc5ea7202edb9c04c33ffed Mon Sep 17 00:00:00 2001
From: th
Date: Thu, 16 Apr 2026 09:09:18 +0200
Subject: [PATCH] search: saved searches via bookmark button
Small bookmark icon in the search header bar opens a popup listing
localStorage-persisted search strings. Clicking an entry fills the
input and runs the search; the x button deletes it; "save current
search" at the bottom saves the active input (no dupes). List
persists across sessions, no server round-trip.
Tests: 6 cases covering button/popup toggle, save + recall, delete,
save-current-button, and duplicate rejection. All snapshot/restore
localStorage in try/finally so they don't leak into user data or
cross-test state.
Co-Authored-By: Claude Opus 4.6 (1M context)
---
config.php | 2 +-
electron/package.json | 2 +-
public/index.php | 9 ++
public/js/modules/search.js | 85 +++++++++++++++++++
public/plugins/tests/search.test.js | 122 ++++++++++++++++++++++++++++
5 files changed, 218 insertions(+), 2 deletions(-)
diff --git a/config.php b/config.php
index 8b10e1b..a073478 100644
--- a/config.php
+++ b/config.php
@@ -1,7 +1,7 @@
+
+
+
+
+
+
+
diff --git a/public/js/modules/search.js b/public/js/modules/search.js
index b9b4c3e..b27ef2f 100644
--- a/public/js/modules/search.js
+++ b/public/js/modules/search.js
@@ -403,3 +403,88 @@ replaceAllBtn?.addEventListener('click', async () => {
search(input.value);
setTimeout(() => { replaceStatus.style.color = ''; }, 3000);
});
+
+// ── Saved searches ──────────────────────────────────────────────
+// localStorage-persisted list of search strings. The bookmark button
+// toggles a popup that lets the user pick one (fills input + runs),
+// save the current input value, or delete saved entries.
+
+const SAVED_KEY = 'hyprcrd-saved-searches';
+const savedBtn = $('search-saved-btn');
+const savedPopup = $('search-saved-popup');
+const savedList = $('search-saved-list');
+const savedAdd = $('search-saved-add');
+
+function loadSaved() {
+ try { return JSON.parse(localStorage.getItem(SAVED_KEY) || '[]'); } catch { return []; }
+}
+function storeSaved(arr) {
+ localStorage.setItem(SAVED_KEY, JSON.stringify(arr));
+}
+
+function renderSavedList() {
+ if (!savedList) return;
+ const items = loadSaved();
+ if (!items.length) {
+ savedList.innerHTML = '