mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-14 21:35:19 +00:00
feat: temp chat as default
This commit is contained in:
parent
ba972ecd52
commit
19e82ace23
5 changed files with 43 additions and 41 deletions
|
|
@ -742,6 +742,15 @@
|
||||||
await temporaryChatEnabled.set(true);
|
await temporaryChatEnabled.set(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($settings?.temporaryChatByDefault ?? false) {
|
||||||
|
if ($temporaryChatEnabled === false) {
|
||||||
|
await temporaryChatEnabled.set(true);
|
||||||
|
} else {
|
||||||
|
// if set to null set to false; refer to temp chat toggle click handler
|
||||||
|
await temporaryChatEnabled.set(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const availableModels = $models
|
const availableModels = $models
|
||||||
.filter((m) => !(m?.info?.meta?.hidden ?? false))
|
.filter((m) => !(m?.info?.meta?.hidden ?? false))
|
||||||
.map((m) => m.id);
|
.map((m) => m.id);
|
||||||
|
|
|
||||||
|
|
@ -45,8 +45,6 @@
|
||||||
export let searchEnabled = true;
|
export let searchEnabled = true;
|
||||||
export let searchPlaceholder = $i18n.t('Search a model');
|
export let searchPlaceholder = $i18n.t('Search a model');
|
||||||
|
|
||||||
export let showTemporaryChatControl = false;
|
|
||||||
|
|
||||||
export let items: {
|
export let items: {
|
||||||
label: string;
|
label: string;
|
||||||
value: string;
|
value: string;
|
||||||
|
|
@ -314,7 +312,7 @@
|
||||||
...$MODEL_DOWNLOAD_POOL
|
...$MODEL_DOWNLOAD_POOL
|
||||||
});
|
});
|
||||||
await deleteModel(localStorage.token, model);
|
await deleteModel(localStorage.token, model);
|
||||||
toast.success($i18n.t("{{model}} download has been canceled", { model: model }));
|
toast.success($i18n.t('{{model}} download has been canceled', { model: model }));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -619,42 +617,7 @@
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{#if showTemporaryChatControl}
|
<div class="mb-3"></div>
|
||||||
<div class="flex items-center mx-2 mt-1 mb-2">
|
|
||||||
<DropdownMenu.Item
|
|
||||||
class="flex justify-between w-full font-medium line-clamp-1 select-none items-center rounded-button py-2 px-3 text-sm text-gray-700 dark:text-gray-100 outline-hidden transition-all duration-75 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-lg cursor-pointer data-highlighted:bg-muted"
|
|
||||||
on:click={async () => {
|
|
||||||
temporaryChatEnabled.set(!$temporaryChatEnabled);
|
|
||||||
await goto('/');
|
|
||||||
const newChatButton = document.getElementById('new-chat-button');
|
|
||||||
setTimeout(() => {
|
|
||||||
newChatButton?.click();
|
|
||||||
}, 0);
|
|
||||||
|
|
||||||
// add 'temporary-chat=true' to the URL
|
|
||||||
if ($temporaryChatEnabled) {
|
|
||||||
history.replaceState(null, '', '?temporary-chat=true');
|
|
||||||
} else {
|
|
||||||
history.replaceState(null, '', location.pathname);
|
|
||||||
}
|
|
||||||
|
|
||||||
show = false;
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div class="flex gap-2.5 items-center">
|
|
||||||
<ChatBubbleOval className="size-4" strokeWidth="2.5" />
|
|
||||||
|
|
||||||
{$i18n.t(`Temporary Chat`)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<Switch state={$temporaryChatEnabled} />
|
|
||||||
</div>
|
|
||||||
</DropdownMenu.Item>
|
|
||||||
</div>
|
|
||||||
{:else}
|
|
||||||
<div class="mb-3"></div>
|
|
||||||
{/if}
|
|
||||||
|
|
||||||
<div class="hidden w-[42rem]" />
|
<div class="hidden w-[42rem]" />
|
||||||
<div class="hidden w-[32rem]" />
|
<div class="hidden w-[32rem]" />
|
||||||
|
|
|
||||||
|
|
@ -115,8 +115,15 @@
|
||||||
class="flex cursor-pointer px-2 py-2 rounded-xl hover:bg-gray-50 dark:hover:bg-gray-850 transition"
|
class="flex cursor-pointer px-2 py-2 rounded-xl hover:bg-gray-50 dark:hover:bg-gray-850 transition"
|
||||||
id="temporary-chat-button"
|
id="temporary-chat-button"
|
||||||
on:click={async () => {
|
on:click={async () => {
|
||||||
temporaryChatEnabled.set(!$temporaryChatEnabled);
|
if (($settings?.temporaryChatByDefault ?? false) && $temporaryChatEnabled) {
|
||||||
|
// for proper initNewChat handling
|
||||||
|
temporaryChatEnabled.set(null);
|
||||||
|
} else {
|
||||||
|
temporaryChatEnabled.set(!$temporaryChatEnabled);
|
||||||
|
}
|
||||||
|
|
||||||
await goto('/');
|
await goto('/');
|
||||||
|
|
||||||
// add 'temporary-chat=true' to the URL
|
// add 'temporary-chat=true' to the URL
|
||||||
if ($temporaryChatEnabled) {
|
if ($temporaryChatEnabled) {
|
||||||
window.history.replaceState(null, '', '?temporary-chat=true');
|
window.history.replaceState(null, '', '?temporary-chat=true');
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,7 @@
|
||||||
let ctrlEnterToSend = false;
|
let ctrlEnterToSend = false;
|
||||||
let copyFormatted = false;
|
let copyFormatted = false;
|
||||||
|
|
||||||
|
let temporaryChatByDefault = false;
|
||||||
let chatFadeStreamingText = true;
|
let chatFadeStreamingText = true;
|
||||||
let collapseCodeBlocks = false;
|
let collapseCodeBlocks = false;
|
||||||
let expandDetails = false;
|
let expandDetails = false;
|
||||||
|
|
@ -215,6 +216,8 @@
|
||||||
widescreenMode = $settings?.widescreenMode ?? false;
|
widescreenMode = $settings?.widescreenMode ?? false;
|
||||||
splitLargeChunks = $settings?.splitLargeChunks ?? false;
|
splitLargeChunks = $settings?.splitLargeChunks ?? false;
|
||||||
scrollOnBranchChange = $settings?.scrollOnBranchChange ?? true;
|
scrollOnBranchChange = $settings?.scrollOnBranchChange ?? true;
|
||||||
|
|
||||||
|
temporaryChatByDefault = $settings?.temporaryChatByDefault ?? false;
|
||||||
chatDirection = $settings?.chatDirection ?? 'auto';
|
chatDirection = $settings?.chatDirection ?? 'auto';
|
||||||
userLocation = $settings?.userLocation ?? false;
|
userLocation = $settings?.userLocation ?? false;
|
||||||
|
|
||||||
|
|
@ -580,6 +583,25 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<div class=" py-0.5 flex w-full justify-between">
|
||||||
|
<div id="temp-chat-default-label" class=" self-center text-xs">
|
||||||
|
{$i18n.t('Temporary Chat by Default')}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex items-center gap-2 p-1">
|
||||||
|
<Switch
|
||||||
|
ariaLabelledbyId="temp-chat-default-label"
|
||||||
|
tooltip={true}
|
||||||
|
bind:state={temporaryChatByDefault}
|
||||||
|
on:change={() => {
|
||||||
|
saveSettings({ temporaryChatByDefault });
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<div class=" py-0.5 flex w-full justify-between">
|
<div class=" py-0.5 flex w-full justify-between">
|
||||||
<div id="fade-streaming-label" class=" self-center text-xs">
|
<div id="fade-streaming-label" class=" self-center text-xs">
|
||||||
|
|
|
||||||
|
|
@ -289,7 +289,8 @@
|
||||||
<div class="m-auto pb-44 flex flex-col justify-center">
|
<div class="m-auto pb-44 flex flex-col justify-center">
|
||||||
<div class="max-w-md">
|
<div class="max-w-md">
|
||||||
<div class="text-center dark:text-white text-2xl font-medium z-50">
|
<div class="text-center dark:text-white text-2xl font-medium z-50">
|
||||||
{$i18n.t('Important Update')}<br /> {$i18n.t('Action Required for Chat Log Storage')}
|
{$i18n.t('Important Update')}<br />
|
||||||
|
{$i18n.t('Action Required for Chat Log Storage')}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class=" mt-4 text-center text-sm dark:text-gray-200 w-full">
|
<div class=" mt-4 text-center text-sm dark:text-gray-200 w-full">
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue