[PR #22858] [CLOSED] fix: folder prompt ignored in temporary chats #42521

Closed
opened 2026-04-25 14:23:52 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/22858
Author: @gambletan
Created: 3/19/2026
Status: Closed

Base: mainHead: fix/temporary-chat-folder-prompt


📝 Commits (1)

  • dd592bb fix: pass folder prompt to temporary chats

📊 Changes

3 files changed (+29 additions, -18 deletions)

View changed files

📝 backend/open_webui/main.py (+1 -0)
📝 backend/open_webui/utils/middleware.py (+22 -18)
📝 src/lib/components/chat/Chat.svelte (+6 -0)

📄 Description

Summary

  • Fixes #22772: When a folder has a custom system prompt, creating a "Temporary Chat" in that folder now correctly applies the folder's prompt.
  • The root cause was that temporary chats are not persisted to the database, so the backend's folder lookup by chat_id returned nothing. The fix captures the folder_id on the frontend when a temporary chat starts and passes it in the request payload. The backend falls back to this client-supplied folder_id when the DB lookup finds no result.
  • This also ensures folder knowledge files are attached to temporary chats, not just the system prompt.

Changes

  • src/lib/components/chat/Chat.svelte: Store temporaryChatFolderId when initializing a temporary chat inside a folder; send it as folder_id in the chat completion request.
  • backend/open_webui/main.py: Extract folder_id from the request payload into metadata.
  • backend/open_webui/utils/middleware.py: Fall back to metadata["folder_id"] when Chats.get_chat_folder_id() returns nothing (as happens with temporary chats).

Test plan

  • Create a folder with a custom system prompt (e.g., "Always respond in pirate speak")
  • Create a regular chat in that folder — verify the prompt is applied
  • Create a temporary chat in that folder — verify the prompt is now also applied
  • Create a temporary chat outside any folder — verify no regression (no folder prompt injected)
  • Create a folder with knowledge files — verify temporary chats in that folder receive the files

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/open-webui/pull/22858 **Author:** [@gambletan](https://github.com/gambletan) **Created:** 3/19/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/temporary-chat-folder-prompt` --- ### 📝 Commits (1) - [`dd592bb`](https://github.com/open-webui/open-webui/commit/dd592bb5d57f36b58639b7bf9e2c6826a6ae1666) fix: pass folder prompt to temporary chats ### 📊 Changes **3 files changed** (+29 additions, -18 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/main.py` (+1 -0) 📝 `backend/open_webui/utils/middleware.py` (+22 -18) 📝 `src/lib/components/chat/Chat.svelte` (+6 -0) </details> ### 📄 Description ## Summary - Fixes #22772: When a folder has a custom system prompt, creating a "Temporary Chat" in that folder now correctly applies the folder's prompt. - The root cause was that temporary chats are not persisted to the database, so the backend's folder lookup by `chat_id` returned nothing. The fix captures the `folder_id` on the frontend when a temporary chat starts and passes it in the request payload. The backend falls back to this client-supplied `folder_id` when the DB lookup finds no result. - This also ensures folder knowledge files are attached to temporary chats, not just the system prompt. ## Changes - **`src/lib/components/chat/Chat.svelte`**: Store `temporaryChatFolderId` when initializing a temporary chat inside a folder; send it as `folder_id` in the chat completion request. - **`backend/open_webui/main.py`**: Extract `folder_id` from the request payload into metadata. - **`backend/open_webui/utils/middleware.py`**: Fall back to `metadata["folder_id"]` when `Chats.get_chat_folder_id()` returns nothing (as happens with temporary chats). ## Test plan - [ ] Create a folder with a custom system prompt (e.g., "Always respond in pirate speak") - [ ] Create a regular chat in that folder — verify the prompt is applied - [ ] Create a temporary chat in that folder — verify the prompt is now also applied - [ ] Create a temporary chat outside any folder — verify no regression (no folder prompt injected) - [ ] Create a folder with knowledge files — verify temporary chats in that folder receive the files 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-25 14:23:52 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#42521