fix(ai): add reset for models_ac and streamline model autocomplete handling
Some checks failed
CI Code / Check spelling (pull_request) Successful in 22s
CI Code / Check coding style (pull_request) Successful in 36s
CI Code / Code Coverage (pull_request) Failing after 1m11s
CI Code / Linux (debian) (pull_request) Failing after 3m10s
CI Code / Linux (ubuntu) (pull_request) Failing after 3m20s
CI Code / Linux (arch) (pull_request) Failing after 4m3s

Replace the custom ai_models_find function with a dedicated
ai_models_ac autocomplete list. Update the /ai switch trigger to
include a trailing space for consistent parsing.
This commit is contained in:
2026-05-13 12:59:29 +00:00
parent 277c82fb5d
commit 2f1637ca8e
2 changed files with 3 additions and 40 deletions

View File

@@ -406,37 +406,6 @@ ai_providers_find(const char* const search_str, gboolean previous, void* context
return autocomplete_complete(providers_ac, search_str, FALSE, previous);
}
/* Stateful model name finder for autocomplete.
* Uses the current session's provider models for completion. */
gchar*
ai_models_find(const char* const search_str, gboolean previous, void* context)
{
ProfAiWin* aiwin = (ProfAiWin*)context;
if (!aiwin || !aiwin->session) {
return NULL;
}
AIProvider* provider = aiwin->session->provider;
if (!provider || !provider->models) {
return NULL;
}
/* Create a temporary autocomplete for models */
Autocomplete models_ac = autocomplete_new();
GList* curr = provider->models;
while (curr) {
autocomplete_add(models_ac, curr->data);
curr = g_list_next(curr);
}
/* NULL search_str is treated as empty string for cycling */
const char* effective_search = (search_str != NULL) ? search_str : "";
gchar* result = autocomplete_complete(models_ac, effective_search, FALSE, previous);
autocomplete_free(models_ac);
return result;
}
/* Reset the provider autocomplete state.
* Called from cmd_ac_reset() to clear autocomplete state when the user presses Ctrl+C. */
void