From ba69c751ca0ec489604bedfa4041fc71a49e304c Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek <tim@openwebui.com> Date: Sat, 10 May 2025 22:12:36 +0400 Subject: [PATCH] refac: temporary chat behaviour --- src/lib/components/chat/Chat.svelte | 46 ++++++++++++++++------------- src/routes/(app)/+layout.svelte | 2 +- 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/src/lib/components/chat/Chat.svelte b/src/lib/components/chat/Chat.svelte index 5d11ce940..defeaf9cf 100644 --- a/src/lib/components/chat/Chat.svelte +++ b/src/lib/components/chat/Chat.svelte @@ -155,12 +155,14 @@ localStorage.getItem(`chat-input${chatIdProp ? `-${chatIdProp}` : ''}`) ); - prompt = input.prompt; - files = input.files; - selectedToolIds = input.selectedToolIds; - webSearchEnabled = input.webSearchEnabled; - imageGenerationEnabled = input.imageGenerationEnabled; - codeInterpreterEnabled = input.codeInterpreterEnabled; + if (!$temporaryChatEnabled) { + prompt = input.prompt; + files = input.files; + selectedToolIds = input.selectedToolIds; + webSearchEnabled = input.webSearchEnabled; + imageGenerationEnabled = input.imageGenerationEnabled; + codeInterpreterEnabled = input.codeInterpreterEnabled; + } } catch (e) {} } @@ -419,25 +421,27 @@ } if (localStorage.getItem(`chat-input${chatIdProp ? `-${chatIdProp}` : ''}`)) { + prompt = ''; + files = []; + selectedToolIds = []; + webSearchEnabled = false; + imageGenerationEnabled = false; + codeInterpreterEnabled = false; + try { const input = JSON.parse( localStorage.getItem(`chat-input${chatIdProp ? `-${chatIdProp}` : ''}`) ); - console.log('chat-input', input); - prompt = input.prompt; - files = input.files; - selectedToolIds = input.selectedToolIds; - webSearchEnabled = input.webSearchEnabled; - imageGenerationEnabled = input.imageGenerationEnabled; - codeInterpreterEnabled = input.codeInterpreterEnabled; - } catch (e) { - prompt = ''; - files = []; - selectedToolIds = []; - webSearchEnabled = false; - imageGenerationEnabled = false; - codeInterpreterEnabled = false; - } + + if (!$temporaryChatEnabled) { + prompt = input.prompt; + files = input.files; + selectedToolIds = input.selectedToolIds; + webSearchEnabled = input.webSearchEnabled; + imageGenerationEnabled = input.imageGenerationEnabled; + codeInterpreterEnabled = input.codeInterpreterEnabled; + } + } catch (e) {} } if (!chatIdProp) { diff --git a/src/routes/(app)/+layout.svelte b/src/routes/(app)/+layout.svelte index 104f92e27..a09afd4ce 100644 --- a/src/routes/(app)/+layout.svelte +++ b/src/routes/(app)/+layout.svelte @@ -196,7 +196,7 @@ showChangelog.set($settings?.version !== $config.version); } - if ($user?.permissions?.chat?.temporary ?? true) { + if ($user?.role === 'admin' || ($user?.permissions?.chat?.temporary ?? true)) { if ($page.url.searchParams.get('temporary-chat') === 'true') { temporaryChatEnabled.set(true); }