()
| 154 | } |
| 155 | |
| 156 | function updateProviderUI() { |
| 157 | if (!providerSelect) return; |
| 158 | const p = providerSelect.value; |
| 159 | const meta = state.config?.supportedProviders?.[p]; |
| 160 | |
| 161 | if (!meta) return; |
| 162 | |
| 163 | if (meta.authType === "oauth") { |
| 164 | // Show OAuth section, hide API Key section |
| 165 | if (apikeySection) apikeySection.style.display = "none"; |
| 166 | if (oauthSection) oauthSection.style.display = ""; |
| 167 | if (saveBtn) saveBtn.style.display = "none"; |
| 168 | checkOAuthStatus(); |
| 169 | } else { |
| 170 | // Show API Key section, hide OAuth section |
| 171 | if (apikeySection) apikeySection.style.display = ""; |
| 172 | if (oauthSection) oauthSection.style.display = "none"; |
| 173 | if (saveBtn) saveBtn.style.display = ""; |
| 174 | |
| 175 | // Toggle BaseURL input |
| 176 | if (baseUrlGroup) { |
| 177 | baseUrlGroup.style.display = meta.supportsBaseUrl ? "" : "none"; |
| 178 | } |
| 179 | |
| 180 | if (baseUrlInput) { |
| 181 | baseUrlInput.placeholder = |
| 182 | meta.baseUrlPlaceholder || "https://api.openai.com/v1"; |
| 183 | } |
| 184 | |
| 185 | // Show model name field only when a custom base URL is filled in |
| 186 | updateModelIdVisibility(); |
| 187 | |
| 188 | // Update placeholder |
| 189 | if (apiKeyInput) { |
| 190 | apiKeyInput.placeholder = meta.placeholder || "sk-..."; |
| 191 | } |
| 192 | } |
| 193 | } |
| 194 | |
| 195 | function updateModelIdVisibility() { |
| 196 | if (!modelIdGroup) return; |
no test coverage detected