feat(plugins): search plugins can answer the place search as you type

A searchProvider plugin can now implement an optional suggest() beside
search(). Its places then show up in the place search's typed-ahead list,
after the core suggestions and marked with the plugin's name, on desktop
and phone. An index that cannot take a request per keystroke leaves it
out and keeps answering the full search only.

The child reports which functions each hook object carries at load, so
GET /api/plugin-search/suggest only asks the plugins that implement
suggest: from the second character, three rows at most across all of
them, 800 ms to answer. The feed marks plugins holding
hook:search-provider and the client only asks the route while one is
installed. A plugin row carries its whole place, so picking it skips the
details lookup, which knows no plugin id. The phone's search results now
name their source as the desktop ones do, and the desktop dropdown
scrolls instead of running past the dialog.

Addresses discussion #2221.
This commit is contained in:
Maurice
2026-09-25 09:19:11 +02:00
parent 1727732841
commit 2a8071f642
38 changed files with 1248 additions and 96 deletions
+10
View File
@@ -517,6 +517,16 @@ export interface SearchProvider {
* Called for an explicit search, not for every keystroke: an external index has rate
* limits, and a request per typed letter would spend them on words nobody finished. */
search(request: SearchRequest, ctx: PluginContext): Promise<SearchResultPlace[]>;
/** Optional: places for the query while it is still being typed, shown under the
* core suggestions in the place search's dropdown. Implement it only when your index
* can take a request per keystroke, such as one you keep locally; leave it out and
* your places appear once the search is run, as before.
*
* Called from the second typed character on, with `limit` 3, and given 800 ms. The
* host keeps at most 3 rows across every provider, so return your best few, and
* `near` is where the person is planning. Picking a row takes it as it is, so fill in
* what you know (address, website, phone) here rather than later. */
suggest?(request: SearchRequest, ctx: PluginContext): Promise<SearchResultPlace[]>;
}
/**
* What the host asks a POI category provider for: the places of ONE of your declared