Chronologically ordered Firefox history via dedicated trigger fh#8
Chronologically ordered Firefox history via dedicated trigger fh#8ffpyt wants to merge 10 commits intoalbertlauncher:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a dedicated history-browsing pathway for the Firefox plugin so users can browse history in true recency order (without Albert’s fuzzy-ranking reordering), while keeping the existing f fuzzy search behavior for bookmarks/history indexing.
Changes:
- Added
FirefoxHistoryHandler (GeneratorQueryHandler)triggered byfhto return history inlast_visit_date DESCorder with optionalLIKEfiltering. - Refactored plugin structure so
Pluginowns shared config/state and exposes two independent handlers viaextensions(). - Added
get_recent_history()SQL helper to retrieve non-nulllast_visit_dateentries ordered by recency.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
__init__.py |
Adds get_recent_history, introduces new FirefoxHistoryHandler, and refactors plugin into separate handlers with dedicated triggers. |
README.md |
Documents the new fh trigger for chronological history browsing. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
Still not tested @ffpyt . Sorry for the delay. Cannot commit time for now. |
|
@ManuelSchneid3r Tested here. Works fine! TL;DR: new handler to display recent history --> |
|
Ah just found that the scan for bookmarks/history ran twice @ManuelSchneid3r I think I need your opinion here: 2 handlers, so theoretically, 2 instances => 2 scans. Unless we can share something between the two? @ffpyt Maybe you have an idea? (I did not dig much here) |
|
@tomsquest Thanks for your testing! You are right that my changes caused the duplicate scan of bookmarks at startup. Basically, the root cause was calling updateIndexItems after instantiation of the FirefoxQueryHandler. @abstractmethod
def updateIndexItems(self):
"""
Updates the index.
Called when the index needs to be updated, i.e. for initialization, on user changes to the
index config (fuzzy, etc…) and probably by the client itself if the items changed. This
function should call ``setIndexItems`` to update the index.
Do not call this method on plugin initialization. It will be called once loaded.
"""With this change my debug log does not show a duplicate scan anymore. Technically, there is still a "duplicate scan" not visible in the log just now: Do you think this shall also be optimized / fixed? |
|
@ffpyt Seems fine on my side. I don't have any duplication whatsoever (1 log line for bookmarks, 1 for history, that's it). So seems good for me! 👏 |
Add ordered Firefox history via dedicated
FirefoxHistoryHandlerMotivation
The existing
FirefoxQueryHandlerusesIndexQueryHandlerwhich ranks results by fuzzy match quality. This is great for searching bookmarks & history by name, but makes it impossible to browse history in chronological order — Albert always reorders results by relevance, even for an empty query.Changes
New
FirefoxHistoryHandler(GeneratorQueryHandler)A self-contained handler triggered by
fhthat yields history in recency order on every query. Typing after the trigger filters results by title or URL via a SQLLIKEclause while preserving the ordering. Because it usesGeneratorQueryHandler, Albert displays results exactly as returned without reranking.Refactored
PluginThe plugin now properly separates concerns:
Plugin(PluginInstance)owns shared state and configuration, while query handlers are standalone objects passed shared state at construction time.extensions()returns both handlers, letting Albert dispatch each trigger independently.New
get_recent_history()functionA dedicated SQL query separate from the existing
get_history()(which is preserved unchanged for bookmark/history indexing). It filters out entries wherelast_visit_date IS NULL— avoiding unvisited prefetched or autocomplete URLs polluting the results — and returns rows ordered bylast_visit_date DESCwith an optional search filter and limit.Triggers
fFirefoxQueryHandlerfhFirefoxHistoryHandler