Keep a whole search, and say what is new in it

A search here is more than the words in the box: it is the source, the
channel, every filter that channel offers, and the query together. The
bookmark in the search bar keeps all of it, the one in the header opens
the list, and tapping a row puts the whole thing back.

Each saved search remembers the ids of the newest videos it showed the
last time it was opened. Once a day -- at startup, when the tab is looked
at again, and on a slow heartbeat for tabs left open -- the client asks
each one's first page again and counts how many of those videos it has
never shown. That count is the badge, on the row and summed in the
header, and it stops at 9+. Opening a saved search is viewing it, so the
count goes out and the mark moves to what is on screen now.

Nothing new leaves the device: the check is the same listing request the
grid would have made, and everything else is localStorage.

Also: handleSearch's "put this in the box without searching for it" half
is now App.videos.setSearchBox, which is what applying a saved search
needs.

tests/smoke_saved_searches.py covers it end to end against a fixture
listing whose ids the test shifts to mean "new uploads": 46 checks.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MPZFnNdHbPGDTqQUNiE4ZN
This commit is contained in:
Simon
2026-10-17 05:59:19 +00:00
parent f977852253
commit bc7c0047b7
9 changed files with 1581 additions and 15 deletions

View File

@@ -185,6 +185,26 @@ App.enhance = App.enhance || {};
});
});
}
// Saved searches: the list itself, the one-press save, and every
// saved search as a row of its own so ⌘K can jump straight to one.
if (App.savedSearches && App.ui && App.ui.savedSearches) {
const saved = App.savedSearches.getAll();
out.push({ label: 'Saved searches', hint: saved.length ? `${saved.length} saved` : 'Nothing saved yet', run: () => App.ui.savedSearches.open() });
const match = App.savedSearches.findMatching();
out.push({
label: match ? `Remove saved search: ${match.name}` : 'Save the current search',
hint: 'Source · channel · filters · query',
run: () => App.ui.savedSearches.toggleCurrent()
});
saved.forEach((entry) => {
const label = App.savedSearches.badgeLabel(entry.newCount);
out.push({
label: entry.name,
hint: label ? `Saved search · ${label} new` : 'Saved search',
run: () => App.savedSearches.apply(entry.id)
});
});
}
out.push({ label: 'Reload channel', hint: 'Refresh the current feed', run: () => { if (App.videos) App.videos.resetAndReload(); } });
out.push({ label: 'Open Menu', hint: 'Source · channel · filters', run: () => { if (App.ui) App.ui.toggleDrawer('menu'); } });
out.push({ label: 'Open Settings', hint: 'Preferences', run: () => { if (App.ui) App.ui.toggleDrawer('settings'); } });