From 584c09ea49cfe7194aa72c95e45a0b90e53a2ddd Mon Sep 17 00:00:00 2001 From: Matt Rubens Date: Sun, 30 Mar 2025 12:45:59 -0400 Subject: [PATCH] Link to provider docs from the API options --- .../src/components/settings/ApiOptions.tsx | 51 +++++++++++++++++-- .../src/components/settings/constants.ts | 1 + webview-ui/src/i18n/locales/ca/settings.json | 1 + webview-ui/src/i18n/locales/de/settings.json | 1 + webview-ui/src/i18n/locales/en/settings.json | 1 + webview-ui/src/i18n/locales/es/settings.json | 1 + webview-ui/src/i18n/locales/fr/settings.json | 1 + webview-ui/src/i18n/locales/hi/settings.json | 1 + webview-ui/src/i18n/locales/it/settings.json | 1 + webview-ui/src/i18n/locales/ja/settings.json | 1 + webview-ui/src/i18n/locales/ko/settings.json | 1 + webview-ui/src/i18n/locales/pl/settings.json | 1 + .../src/i18n/locales/pt-BR/settings.json | 1 + webview-ui/src/i18n/locales/tr/settings.json | 1 + webview-ui/src/i18n/locales/vi/settings.json | 1 + .../src/i18n/locales/zh-CN/settings.json | 1 + .../src/i18n/locales/zh-TW/settings.json | 1 + 17 files changed, 64 insertions(+), 3 deletions(-) diff --git a/webview-ui/src/components/settings/ApiOptions.tsx b/webview-ui/src/components/settings/ApiOptions.tsx index 3ed1158f54..cf6eec02d6 100644 --- a/webview-ui/src/components/settings/ApiOptions.tsx +++ b/webview-ui/src/components/settings/ApiOptions.tsx @@ -243,10 +243,55 @@ const ApiOptions = ({ [selectedProvider], ) + // Base URL for provider documentation + const DOC_BASE_URL = "https://docs.roocode.com/providers" + + // Custom URL path mappings for providers with different slugs + const providerUrlSlugs: Record = { + "openai-native": "openai", + openai: "openai-compatible", + } + + // Helper function to get provider display name from PROVIDERS constant + const getProviderDisplayName = (providerKey: string): string | undefined => { + const provider = PROVIDERS.find((p) => p.value === providerKey) + return provider?.label + } + + // Helper function to get the documentation URL and name for the currently selected provider + const getSelectedProviderDocUrl = (): { url: string; name: string } | undefined => { + const displayName = getProviderDisplayName(selectedProvider) + if (!displayName) { + return undefined + } + + // Get the URL slug - use custom mapping if available, otherwise use the provider key + const urlSlug = providerUrlSlugs[selectedProvider] || selectedProvider + + return { + url: `${DOC_BASE_URL}/${urlSlug}`, + name: displayName, + } + } + return (
-
- +
+
+ + {getSelectedProviderDocUrl() && ( +
+ + {t("settings:providers.providerDocumentation", { + provider: getSelectedProviderDocUrl()!.name, + })} + +
+ )} +