From 81722918384cb56608a2ab26ca03059b3a811758 Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Fri, 16 Oct 2026 01:00:34 +0200 Subject: [PATCH] fix: OAuth MCP tool is not enabled after login when the model has default tools (#32488) Enabling an OAuth MCP tool from the Integrations menu sends the user through the OAuth login and back to a new chat, where the tool should be on. When the selected model had tools of its own enabled by default, the tool came back switched off, so it had to be enabled a second time. Now it stays on, together with the model's own tools. For the same reason, a link like `/?tools=my_tool` opened with such a model ignored the listed tools, and now turns them on. Fixes #32476 --- src/lib/components/chat/Chat.svelte | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/lib/components/chat/Chat.svelte b/src/lib/components/chat/Chat.svelte index 9ccae09188..4883c4a219 100644 --- a/src/lib/components/chat/Chat.svelte +++ b/src/lib/components/chat/Chat.svelte @@ -1071,10 +1071,12 @@ lastTerminalSkillSelector = $selectedTerminalId; } - let settingDefaults = false; + let settingDefaults: Promise | null = null; const setDefaults = async () => { - if (settingDefaults) return; - settingDefaults = true; + // Concurrent callers must wait, or the earlier run overwrites what they write afterwards + if (settingDefaults) return settingDefaults; + let resolveDefaults = () => {}; + settingDefaults = new Promise((resolve) => (resolveDefaults = resolve)); try { if (!$tools) { @@ -1217,7 +1219,8 @@ } } } finally { - settingDefaults = false; + settingDefaults = null; + resolveDefaults(); } };