fix(store): localised docs, debounced typing, explicit-submit always AI
Some checks failed
Security / Security check (push) Failing after 1s

Three Stefan-found bugs in one pass:

1. Documentation rendered in English even when Studio was set
   to German. _loadDocs now passes Localizations.localeOf(...)
   to fetchModuleDocs(); the hub tries README.de.md before
   README.md when locale='de'.

2. 'Keine Treffer' flickered on every keystroke. _onAskTyping
   used to call _runSearch synchronously per character — a
   short 2-3-letter substring matched nothing, so the empty-
   state showed for a frame, then the next character revealed
   results. Add a 250ms typing debounce (Timer + cancel on
   dispose) so the search only re-runs once typing pauses.

3. Submit button did substring search even when System-AI was
   enabled — the _looksLikeQuestion heuristic only routed
   4+-word / question-mark queries through the LLM. The user
   reasonably expected an explicit submit (with the AI-icon
   showing on the button) to actually use AI. New behaviour:
   when system-AI is enabled, the submit button always calls
   _runAiQuery; live-typing keeps substring filtering. The
   heuristic helper was removed (now unused).

Signed-off-by: flemming-it <stefan.a.flemming@googlemail.com>
This commit is contained in:
flemming-it 2026-05-24 22:07:40 +02:00
parent ec7417fef5
commit 98a6414eaa
2 changed files with 35 additions and 17 deletions

View file

@ -350,8 +350,8 @@ class HubService {
/// back as `errorKind` strings (not exceptions) so callers can
/// render fallback UI without try/catch ceremony.
Future<({String errorKind, String text, String sourceUrl})>
fetchModuleDocs(String name) async {
final r = await _client.fetchModuleDocs(name);
fetchModuleDocs(String name, {String locale = ''}) async {
final r = await _client.fetchModuleDocs(name, locale: locale);
return (
errorKind: r.errorKind,
text: r.text,