feat(tui): auto-correct base URL if required path suffix is missing

Providers that need /v1 (lmstudio, llamacpp, qwen) now declare a
url_suffix field. The AI settings save action appends it automatically
and notifies the user if they entered a URL without it.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
curo1305
2026-05-19 00:56:37 +02:00
parent a523fa61a3
commit fd6313acd9
2 changed files with 13 additions and 0 deletions
+9
View File
@@ -171,6 +171,15 @@ class _AITab(VerticalScroll):
base_url = self.query_one("#ai-base-url", Input).value.strip() or None
api_key = self.query_one("#ai-key", Input).value.strip()
if base_url and provider.url_suffix and not base_url.rstrip("/").endswith(provider.url_suffix):
base_url = base_url.rstrip("/") + provider.url_suffix
self.query_one("#ai-base-url", Input).value = base_url
self.app.notify(
f"Base URL must end with '{provider.url_suffix}' for {provider.display_name} — corrected automatically.",
severity="warning",
timeout=6,
)
cfg = load_config()
cfg.ai.provider_id = provider_id
cfg.ai.model = model