From c3d1d9cccc6c50584b28beda02eb1cc77775d5f2 Mon Sep 17 00:00:00 2001 From: FlyM1ss Date: Fri, 3 Jul 2026 21:15:11 +0800 Subject: [PATCH] refactor(extension): remove dead MCP toggle plumbing The MCP mode toggle UI was disabled (commented out) in an earlier cleanup, so `document.getElementById('mcpModeSwitch')` always returned null and `useMCP` was hardwired to false at every call site. MCP is now the default for all agents: the LLM runs with the MCP tools server-side on the standard chat endpoints, so there is no client-side mode to pick. Remove the now-dead plumbing: - api.js: drop the `useMCP` param from getChatResponse / getChatResponseStream and the unreachable `if (useMCP)` branch, which also silently disabled streaming whenever the toggle was set. - handlers.js: drop the mcpModeSwitch read, the `!useMCP` term in the streaming gate, the 'MCP mode' status label, and the useMCP argument at every call site. - settings_window.js: delete the commented-out MCP toggle tombstone. RAG is left untouched (a separately parked feature). No behavior change: useMCP was always false, so no reachable code path is altered. Co-Authored-By: Claude Opus 4.8 (1M context) --- Main/frontend/src/modules/api.js | 27 ++++--------------- .../src/modules/components/settings_window.js | 17 ------------ Main/frontend/src/modules/handlers.js | 22 +++++---------- 3 files changed, 12 insertions(+), 54 deletions(-) diff --git a/Main/frontend/src/modules/api.js b/Main/frontend/src/modules/api.js index 1ba34e1..46152c1 100644 --- a/Main/frontend/src/modules/api.js +++ b/Main/frontend/src/modules/api.js @@ -94,11 +94,10 @@ function buildChatRequestBody(question, selectedModel, promptMode) { } // Function to get chat response from server -function getChatResponse(question, selectedModel, promptMode, useRAG, useMCP) { - // The MCP toggle used to select a dedicated 'get_mcp_response' endpoint - // that does not exist in the backend (every call 404'd). The regular - // chat endpoint already runs the LLM with the available MCP tools, so - // all modes share the two real endpoints now. +function getChatResponse(question, selectedModel, promptMode, useRAG) { + // Every mode shares the two real chat endpoints; the LLM already runs + // with the available MCP tools server-side, so there is no separate MCP + // endpoint or client-side toggle. const endpoint = promptMode ? 'get_adv_response' : 'get_chat_response'; return fetch(buildBackendUrl(`/${endpoint}/`), { @@ -130,7 +129,7 @@ function getChatResponse(question, selectedModel, promptMode, useRAG, useMCP) { // readyState CLOSED behavior on non-200 responses; // - the returned cleanup function cancels the stream (AbortController now, // eventSource.close() before). -function getChatResponseStream(question, selectedModel, promptMode, useRAG, useMCP, callbacks = {}) { +function getChatResponseStream(question, selectedModel, promptMode, useRAG, callbacks = {}) { const { onChunk, onSources, @@ -139,22 +138,6 @@ function getChatResponseStream(question, selectedModel, promptMode, useRAG, useM onStatus, } = callbacks; - // MCP mode doesn't support streaming yet - if (useMCP) { - return getChatResponse(question, selectedModel, promptMode, useRAG, useMCP) - .then(data => { - const modelResponse = data.resp ? data.resp[selectedModel] : data.reply; - if (typeof onComplete === 'function') { - onComplete(modelResponse, data); - } - }) - .catch(error => { - if (typeof onError === 'function') { - onError(error); - } - }); - } - // Build SSE endpoint based on mode (research vs thinking) const url = buildBackendUrl(promptMode ? '/get_adv_response_stream/' : '/get_chat_response_stream/'); const requestBody = JSON.stringify(buildChatRequestBody(question, selectedModel, promptMode)); diff --git a/Main/frontend/src/modules/components/settings_window.js b/Main/frontend/src/modules/components/settings_window.js index 02055bd..3389663 100644 --- a/Main/frontend/src/modules/components/settings_window.js +++ b/Main/frontend/src/modules/components/settings_window.js @@ -174,22 +174,6 @@ function createSettingsWindow(isFixedModeRef, settingsButton, positionModeButton - // —– MCP Mode Toggle —– - // MCP Mode toggle temporarily disabled - /* - const mcpLabel = document.createElement('label'); - mcpLabel.className = 'settings-checkbox-label'; - mcpLabel.innerText = "MCP Mode"; - const mcpSwitch = document.createElement('input'); - mcpSwitch.type = "checkbox"; - mcpSwitch.id = "mcpModeSwitch"; - mcpSwitch.style.transform = 'translate(4px, -2px)'; - mcpLabel.appendChild(mcpSwitch); - */ - - - - // RAG Section // RAG settings temporarily disabled /* @@ -335,7 +319,6 @@ function createSettingsWindow(isFixedModeRef, settingsButton, positionModeButton */ // Append elements to settings window - // settings_window.appendChild(mcpLabel); // settings_window.appendChild(ragSectionContainer); settingsButton.onclick = function (event) { diff --git a/Main/frontend/src/modules/handlers.js b/Main/frontend/src/modules/handlers.js index 0ceacf6..31414ae 100644 --- a/Main/frontend/src/modules/handlers.js +++ b/Main/frontend/src/modules/handlers.js @@ -263,7 +263,6 @@ function createActionButtons( userQuestion, promptMode, useRAG, - useMCP, selectedModel ) { const buttonContainer = document.createElement('div'); @@ -474,18 +473,14 @@ async function handleChatResponse(question, promptMode = false, useStreaming = t const ragSwitchEl = document.getElementById('ragSwitch'); const useRAG = ragSwitchEl ? !!ragSwitchEl.checked : false; - // Read the MCP mode toggle - const mcpSwitchEl = document.getElementById('mcpModeSwitch'); - const useMCP = mcpSwitchEl ? !!mcpSwitchEl.checked : false; - const selectedModel = getSelectedModel(); - // Check if streaming is available (not for MCP or RAG modes) - const canStream = useStreaming && !useMCP && !useRAG; + // Check if streaming is available (not for RAG mode) + const canStream = useStreaming && !useRAG; if (!canStream) { pushAgentStatus({ label: 'Processing', - detail: useMCP ? 'MCP mode' : useRAG ? 'RAG mode' : 'Standard pipeline', + detail: useRAG ? 'RAG mode' : 'Standard pipeline', }); } @@ -505,7 +500,6 @@ async function handleChatResponse(question, promptMode = false, useStreaming = t selectedModel, promptMode, useRAG, - useMCP, { // onChunk callback - called for each chunk of text onChunk: (_chunk, fullResponse) => { @@ -549,7 +543,6 @@ async function handleChatResponse(question, promptMode = false, useStreaming = t question, promptMode, useRAG, - useMCP, selectedModel ); attachValidateButtonIfClaims(actionButtons, { @@ -638,15 +631,15 @@ async function handleChatResponse(question, promptMode = false, useStreaming = t ); } else { // Use regular non-streaming response - getChatResponse(question, selectedModel, promptMode, useRAG, useMCP) + getChatResponse(question, selectedModel, promptMode, useRAG) .then((data) => { const endTime = performance.now(); const responseTime = endTime - startTime; console.log(`Time taken for response: ${responseTime} ms`); - // Extract the reply. All modes (including the MCP toggle, which now - // shares the standard chat endpoint) return `data.resp[...]`; the - // `data.reply` fallback covers older servers' MCP-shaped payloads. + // Extract the reply. The chat endpoints return `data.resp[model]`; + // the `data.reply` fallback covers older servers' alternate payload + // shape. const modelResponse = data.resp ? data.resp[selectedModel] : data.reply; let responseText = ''; @@ -673,7 +666,6 @@ async function handleChatResponse(question, promptMode = false, useStreaming = t question, promptMode, useRAG, - useMCP, selectedModel ); attachValidateButtonIfClaims(actionButtons, {