Skip to content

Commit 592494f

Browse files
authored
Link to provider docs from the API options (#2112)
1 parent 37ecf96 commit 592494f

File tree

17 files changed

+64
-3
lines changed

17 files changed

+64
-3
lines changed

webview-ui/src/components/settings/ApiOptions.tsx

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,10 +243,55 @@ const ApiOptions = ({
243243
[selectedProvider],
244244
)
245245

246+
// Base URL for provider documentation
247+
const DOC_BASE_URL = "https://docs.roocode.com/providers"
248+
249+
// Custom URL path mappings for providers with different slugs
250+
const providerUrlSlugs: Record<string, string> = {
251+
"openai-native": "openai",
252+
openai: "openai-compatible",
253+
}
254+
255+
// Helper function to get provider display name from PROVIDERS constant
256+
const getProviderDisplayName = (providerKey: string): string | undefined => {
257+
const provider = PROVIDERS.find((p) => p.value === providerKey)
258+
return provider?.label
259+
}
260+
261+
// Helper function to get the documentation URL and name for the currently selected provider
262+
const getSelectedProviderDocUrl = (): { url: string; name: string } | undefined => {
263+
const displayName = getProviderDisplayName(selectedProvider)
264+
if (!displayName) {
265+
return undefined
266+
}
267+
268+
// Get the URL slug - use custom mapping if available, otherwise use the provider key
269+
const urlSlug = providerUrlSlugs[selectedProvider] || selectedProvider
270+
271+
return {
272+
url: `${DOC_BASE_URL}/${urlSlug}`,
273+
name: displayName,
274+
}
275+
}
276+
246277
return (
247278
<div className="flex flex-col gap-3">
248-
<div>
249-
<label className="block font-medium mb-1">{t("settings:providers.apiProvider")}</label>
279+
<div className="flex flex-col gap-1 relative">
280+
<div className="flex justify-between items-center">
281+
<label className="block font-medium mb-1">{t("settings:providers.apiProvider")}</label>
282+
{getSelectedProviderDocUrl() && (
283+
<div className="text-xs text-vscode-descriptionForeground">
284+
<VSCodeLink
285+
href={getSelectedProviderDocUrl()!.url}
286+
className="hover:text-vscode-foreground"
287+
target="_blank">
288+
{t("settings:providers.providerDocumentation", {
289+
provider: getSelectedProviderDocUrl()!.name,
290+
})}
291+
</VSCodeLink>
292+
</div>
293+
)}
294+
</div>
250295
<Select
251296
value={selectedProvider}
252297
onValueChange={(value) => setApiConfigurationField("apiProvider", value as ApiProvider)}>
@@ -256,7 +301,7 @@ const ApiOptions = ({
256301
<SelectContent>
257302
<SelectItem value="openrouter">OpenRouter</SelectItem>
258303
<SelectSeparator />
259-
{PROVIDERS.map(({ value, label }) => (
304+
{PROVIDERS.filter((p) => p.value !== "openrouter").map(({ value, label }) => (
260305
<SelectItem key={value} value={value}>
261306
{label}
262307
</SelectItem>

webview-ui/src/components/settings/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export const MODELS_BY_PROVIDER: Partial<Record<ApiProvider, Record<string, Mode
2121
}
2222

2323
export const PROVIDERS = [
24+
{ value: "openrouter", label: "OpenRouter" },
2425
{ value: "anthropic", label: "Anthropic" },
2526
{ value: "gemini", label: "Google Gemini" },
2627
{ value: "deepseek", label: "DeepSeek" },

webview-ui/src/i18n/locales/ca/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
},
8484
"providers": {
8585
"configProfile": "Perfil de configuració",
86+
"providerDocumentation": "Documentació de {{provider}}",
8687
"description": "Deseu diferents configuracions d'API per canviar ràpidament entre proveïdors i configuracions.",
8788
"apiProvider": "Proveïdor d'API",
8889
"openRouterApiKey": "Clau API d'OpenRouter",

webview-ui/src/i18n/locales/de/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
},
8484
"providers": {
8585
"configProfile": "Konfigurationsprofil",
86+
"providerDocumentation": "{{provider}}-Dokumentation",
8687
"description": "Speichern Sie verschiedene API-Konfigurationen, um schnell zwischen Anbietern und Einstellungen zu wechseln.",
8788
"apiProvider": "API-Anbieter",
8889
"model": "Modell",

webview-ui/src/i18n/locales/en/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
}
8383
},
8484
"providers": {
85+
"providerDocumentation": "{{provider}} documentation",
8586
"configProfile": "Configuration Profile",
8687
"description": "Save different API configurations to quickly switch between providers and settings.",
8788
"apiProvider": "API Provider",

webview-ui/src/i18n/locales/es/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
},
8484
"providers": {
8585
"configProfile": "Perfil de configuración",
86+
"providerDocumentation": "Documentación de {{provider}}",
8687
"description": "Guarde diferentes configuraciones de API para cambiar rápidamente entre proveedores y ajustes.",
8788
"apiProvider": "Proveedor de API",
8889
"model": "Modelo",

webview-ui/src/i18n/locales/fr/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
},
8484
"providers": {
8585
"configProfile": "Profil de configuration",
86+
"providerDocumentation": "Documentation {{provider}}",
8687
"description": "Enregistrez différentes configurations d'API pour basculer rapidement entre les fournisseurs et les paramètres.",
8788
"apiProvider": "Fournisseur d'API",
8889
"model": "Modèle",

webview-ui/src/i18n/locales/hi/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
},
8484
"providers": {
8585
"configProfile": "कॉन्फिगरेशन प्रोफाइल",
86+
"providerDocumentation": "{{provider}} दस्तावेज़ीकरण",
8687
"description": "विभिन्न API कॉन्फ़िगरेशन सहेजें ताकि प्रदाताओं और सेटिंग्स के बीच त्वरित रूप से स्विच कर सकें।",
8788
"apiProvider": "API प्रदाता",
8889
"model": "मॉडल",

webview-ui/src/i18n/locales/it/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
},
8484
"providers": {
8585
"configProfile": "Profilo di configurazione",
86+
"providerDocumentation": "Documentazione {{provider}}",
8687
"description": "Salva diverse configurazioni API per passare rapidamente tra fornitori e impostazioni.",
8788
"apiProvider": "Fornitore API",
8889
"model": "Modello",

webview-ui/src/i18n/locales/ja/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
},
8484
"providers": {
8585
"configProfile": "設定プロファイル",
86+
"providerDocumentation": "{{provider}}のドキュメント",
8687
"description": "異なるAPI設定を保存して、プロバイダーと設定をすばやく切り替えることができます。",
8788
"apiProvider": "APIプロバイダー",
8889
"model": "モデル",

0 commit comments

Comments
 (0)