From ca9c994bfea18af81af917a46a6fc81a63946366 Mon Sep 17 00:00:00 2001 From: Russell Ballestrini Date: Fri, 11 Jul 2025 14:56:02 -0400 Subject: [PATCH] fix model endpoint routing: use model's registered endpoint over custom when available, add page title to translate modal tab --- src/config.js | 26 ++++++++++++++++++++++---- src/translate-modal.js | 4 +++- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/config.js b/src/config.js index da1c429..4752849 100644 --- a/src/config.js +++ b/src/config.js @@ -79,11 +79,29 @@ export async function getAPIConfig() { const customBaseURL = localStorage.getItem("customBaseURL"); const customAPIKey = localStorage.getItem("customAPIKey"); + // Import model functions to get the currently selected model + const { getSelectedModel } = await import("./models.js"); + const selectedModel = getSelectedModel(); + + // Check if the selected model has a registered endpoint - use that instead of custom + const { getSelectedModelEndpoint } = await import("./models.js"); + const modelEndpoint = getSelectedModelEndpoint(); + + // If model has its own endpoint, use that regardless of custom setting + if (modelEndpoint && modelEndpoint !== customBaseURL) { + console.log("🚀 Model has registered endpoint - using:", modelEndpoint); + return { + isCustom: false, + endpoint: modelEndpoint, + model: selectedModel, + apiKey: API_KEY, + headers: { + "Content-Type": "application/json" + } + }; + } + if (customBaseURL && customAPIKey) { - // Import model functions to get the currently selected model - const { getSelectedModel } = await import("./models.js"); - const selectedModel = getSelectedModel(); - console.log("🔧 Using CUSTOM API:", { endpoint: customBaseURL, model: selectedModel, diff --git a/src/translate-modal.js b/src/translate-modal.js index 1247751..9468ad4 100644 --- a/src/translate-modal.js +++ b/src/translate-modal.js @@ -65,7 +65,9 @@ export function openTranslateModal() { pageTabLink.setAttribute("aria-selected", "true"); pageTabLink.setAttribute("aria-controls", "page-panel"); pageTabLink.href = "#page-panel"; - pageTabLink.textContent = getUIText("translatePageTab"); + // Include original page title in tab text + const originalTitle = document.title || 'Page'; + pageTabLink.textContent = `${getUIText("translatePageTab")}: ${originalTitle}`; pageTabLink.setAttribute("data-i18n", "translatePageTab"); pageTabItem.appendChild(pageTabLink);