+ {#if !($settings.saveChatHistory ?? true)}
+
+
+
Chat History is off for this browser.
+
+ When history is turned off, new chats on this browser won't appear in your history on
+ any of your devices. This setting does not sync across browsers or devices.
+
-
-
-
-
-
-
-
- {#each $chats.filter((chat) => {
- if (search === '') {
- return true;
- } else {
- let title = chat.title.toLowerCase();
-
- if (title.includes(search)) {
- return true;
- } else {
- return false;
- }
- }
- }) as chat, i}
-
-
{
- // goto(`/c/${chat.id}`);
- if (chat.id !== chatTitleEditId) {
- chatTitleEditId = null;
- chatTitle = '';
- }
-
- if (chat.id !== $chatId) {
- loadChat(chat.id);
- }
- }}
- >
-
-
+
+
{
+ saveSettings({
+ saveChatHistory: true
+ });
+ }}
+ >
+
+ Enable Chat History
+
+
+
+
+ {/if}
+
+
+
+
+ {#each $chats.filter((chat) => {
+ if (search === '') {
+ return true;
+ } else {
+ let title = chat.title.toLowerCase();
+
+ if (title.includes(search)) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+ }) as chat, i}
+
+
{
+ // goto(`/c/${chat.id}`);
+ if (chat.id !== chatTitleEditId) {
+ chatTitleEditId = null;
+ chatTitle = '';
+ }
+
+ if (chat.id !== $chatId) {
+ loadChat(chat.id);
+ }
+ }}
+ >
+
+
+
+ {#if chatTitleEditId === chat.id}
+
+ {:else}
+ {chat.title}
+ {/if}
+
-
+
+
+ {#if chat.id === $chatId}
+
{#if chatTitleEditId === chat.id}
-
+
+
{
+ editChatTitle(chat.id, chatTitle);
+ chatTitleEditId = null;
+ chatTitle = '';
+ }}
+ >
+
+
+
+
+
{
+ chatTitleEditId = null;
+ chatTitle = '';
+ }}
+ >
+
+
+
+
+
+ {:else if chatDeleteId === chat.id}
+
+
{
+ deleteChat(chat.id);
+ }}
+ >
+
+
+
+
+
{
+ chatDeleteId = null;
+ }}
+ >
+
+
+
+
+
{:else}
- {chat.title}
+
+
{
+ deleteChat(chat.id);
+ }}
+ />
+ {
+ chatTitle = chat.title;
+ chatTitleEditId = chat.id;
+ // editChatTitle(chat.id, 'a');
+ }}
+ >
+
+
+
+
+ {
+ chatDeleteId = chat.id;
+ }}
+ >
+
+
+
+
+
{/if}
-
-
-
- {#if chat.id === $chatId}
-
- {#if chatTitleEditId === chat.id}
-
-
{
- editChatTitle(chat.id, chatTitle);
- chatTitleEditId = null;
- chatTitle = '';
- }}
- >
-
-
-
-
-
{
- chatTitleEditId = null;
- chatTitle = '';
- }}
- >
-
-
-
-
-
- {:else if chatDeleteId === chat.id}
-
-
{
- deleteChat(chat.id);
- }}
- >
-
-
-
-
-
{
- chatDeleteId = null;
- }}
- >
-
-
-
-
-
- {:else}
-
-
{
- deleteChat(chat.id);
- }}
- />
- {
- chatTitle = chat.title;
- chatTitleEditId = chat.id;
- // editChatTitle(chat.id, 'a');
- }}
- >
-
-
-
-
- {
- chatDeleteId = chat.id;
- }}
- >
-
-
-
-
-
- {/if}
-
- {/if}
-
- {/each}
+ {/if}
+
+ {/each}
+
diff --git a/src/routes/(app)/+page.svelte b/src/routes/(app)/+page.svelte
index be0faef46..86bdbbea9 100644
--- a/src/routes/(app)/+page.svelte
+++ b/src/routes/(app)/+page.svelte
@@ -280,11 +280,13 @@
}
if ($chatId == _chatId) {
- chat = await updateChatById(localStorage.token, _chatId, {
- messages: messages,
- history: history
- });
- await chats.set(await getChatList(localStorage.token));
+ if ($settings.saveChatHistory ?? true) {
+ chat = await updateChatById(localStorage.token, _chatId, {
+ messages: messages,
+ history: history
+ });
+ await chats.set(await getChatList(localStorage.token));
+ }
}
} else {
if (res !== null) {
@@ -444,11 +446,13 @@
}
if ($chatId == _chatId) {
- chat = await updateChatById(localStorage.token, _chatId, {
- messages: messages,
- history: history
- });
- await chats.set(await getChatList(localStorage.token));
+ if ($settings.saveChatHistory ?? true) {
+ chat = await updateChatById(localStorage.token, _chatId, {
+ messages: messages,
+ history: history
+ });
+ await chats.set(await getChatList(localStorage.token));
+ }
}
} else {
if (res !== null) {
@@ -527,20 +531,24 @@
// Create new chat if only one message in messages
if (messages.length == 1) {
- chat = await createNewChat(localStorage.token, {
- id: $chatId,
- title: 'New Chat',
- models: selectedModels,
- system: $settings.system ?? undefined,
- options: {
- ...($settings.options ?? {})
- },
- messages: messages,
- history: history,
- timestamp: Date.now()
- });
- await chats.set(await getChatList(localStorage.token));
- await chatId.set(chat.id);
+ if ($settings.saveChatHistory ?? true) {
+ chat = await createNewChat(localStorage.token, {
+ id: $chatId,
+ title: 'New Chat',
+ models: selectedModels,
+ system: $settings.system ?? undefined,
+ options: {
+ ...($settings.options ?? {})
+ },
+ messages: messages,
+ history: history,
+ timestamp: Date.now()
+ });
+ await chats.set(await getChatList(localStorage.token));
+ await chatId.set(chat.id);
+ } else {
+ await chatId.set('local');
+ }
await tick();
}
@@ -592,8 +600,10 @@
title = _title;
}
- chat = await updateChatById(localStorage.token, _chatId, { title: _title });
- await chats.set(await getChatList(localStorage.token));
+ if ($settings.saveChatHistory ?? true) {
+ chat = await updateChatById(localStorage.token, _chatId, { title: _title });
+ await chats.set(await getChatList(localStorage.token));
+ }
};
diff --git a/src/routes/(app)/c/[id]/+page.svelte b/src/routes/(app)/c/[id]/+page.svelte
index d538b799b..341d2ff93 100644
--- a/src/routes/(app)/c/[id]/+page.svelte
+++ b/src/routes/(app)/c/[id]/+page.svelte
@@ -609,6 +609,12 @@
chat = await updateChatById(localStorage.token, _chatId, { title: _title });
await chats.set(await getChatList(localStorage.token));
};
+
+ onMount(async () => {
+ if (!($settings.saveChatHistory ?? true)) {
+ await goto('/');
+ }
+ });