fix: keep an open chat's tools when clicking a folder name (#30376)

Clicking a folder name in the sidebar while a chat was open switched that chat to the folder's default model for a moment before the page changed. That reset its tools and skills to the folder model's set and saved them as the chat's draft, so on returning to the chat the folder model's tools were shown and sent with the next message. The same happened to a chat just started from the home page.

The folder's default model is now only applied while the chat has no messages yet, the same rule new chats already follow when a folder page opens. Folder pages, new chats in a folder and editing a folder's default model behave as before.

Verified in a browser against a mock upstream: on dev the next request after the folder click carried the folder model's tool_ids and skill_ids; with the fix it carries the chat's own model's set, for both an existing chat and one started from the home page.

Fixes #30226
This commit is contained in:
Classic298 2026-09-22 22:47:09 +02:00 • committed by GitHub
parent d603b57995
commit 15f350b417
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1593,7 +1593,12 @@
const selectedFolderSubscribe = selectedFolder.subscribe(async (folder) => {
await tick();
if (folder?.data?.model_ids && !equal(selectedModels, folder.data.model_ids)) {
// Folder default models apply to new chats only.
if (
!history.currentId &&
folder?.data?.model_ids &&
!equal(selectedModels, folder.data.model_ids)
) {
selectedModels = folder.data.model_ids;
console.log('Set selectedModels from folder data:', selectedModels);