feat: temp chat as default

This commit is contained in:
Timothy Jaeryang Baek 2025-08-20 22:49:05 +04:00
parent ba972ecd52
commit 19e82ace23
5 changed files with 43 additions and 41 deletions

View file

@ -742,6 +742,15 @@
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
.filter((m) => !(m?.info?.meta?.hidden ?? false))
.map((m) => m.id);

View file

@ -45,8 +45,6 @@
export let searchEnabled = true;
export let searchPlaceholder = $i18n.t('Search a model');
export let showTemporaryChatControl = false;
export let items: {
label: string;
value: string;
@ -314,7 +312,7 @@
...$MODEL_DOWNLOAD_POOL
});
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}
</div>
{#if showTemporaryChatControl}
<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="mb-3"></div>
<div class="hidden w-[42rem]" />
<div class="hidden w-[32rem]" />

View file

@ -115,8 +115,15 @@
class="flex cursor-pointer px-2 py-2 rounded-xl hover:bg-gray-50 dark:hover:bg-gray-850 transition"
id="temporary-chat-button"
on:click={async () => {
temporaryChatEnabled.set(!$temporaryChatEnabled);
if (($settings?.temporaryChatByDefault ?? false) && $temporaryChatEnabled) {
// for proper initNewChat handling
temporaryChatEnabled.set(null);
} else {
temporaryChatEnabled.set(!$temporaryChatEnabled);
}
await goto('/');
// add 'temporary-chat=true' to the URL
if ($temporaryChatEnabled) {
window.history.replaceState(null, '', '?temporary-chat=true');

View file

@ -60,6 +60,7 @@
let ctrlEnterToSend = false;
let copyFormatted = false;
let temporaryChatByDefault = false;
let chatFadeStreamingText = true;
let collapseCodeBlocks = false;
let expandDetails = false;
@ -215,6 +216,8 @@
widescreenMode = $settings?.widescreenMode ?? false;
splitLargeChunks = $settings?.splitLargeChunks ?? false;
scrollOnBranchChange = $settings?.scrollOnBranchChange ?? true;
temporaryChatByDefault = $settings?.temporaryChatByDefault ?? false;
chatDirection = $settings?.chatDirection ?? 'auto';
userLocation = $settings?.userLocation ?? false;
@ -580,6 +583,25 @@
</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 class=" py-0.5 flex w-full justify-between">
<div id="fade-streaming-label" class=" self-center text-xs">

View file

@ -289,7 +289,8 @@
<div class="m-auto pb-44 flex flex-col justify-center">
<div class="max-w-md">
<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 class=" mt-4 text-center text-sm dark:text-gray-200 w-full">