From 8461b92f08755d4ca2a152e803f315cf0cdb16ab Mon Sep 17 00:00:00 2001 From: Jannik Streidl Date: Fri, 1 Mar 2024 21:18:17 +0100 Subject: [PATCH 1/3] show chat in browser title + scroll to bottom --- src/routes/(app)/+page.svelte | 16 +++++++++++++++- src/routes/(app)/c/[id]/+page.svelte | 14 ++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/routes/(app)/+page.svelte b/src/routes/(app)/+page.svelte index 581db7c0..c35b6cd8 100644 --- a/src/routes/(app)/+page.svelte +++ b/src/routes/(app)/+page.svelte @@ -14,6 +14,7 @@ chats, chatId, config, + WEBUI_NAME, tags as _tags } from '$lib/stores'; import { copyToClipboard, splitStream } from '$lib/utils'; @@ -38,7 +39,6 @@ import { RAGTemplate } from '$lib/utils/rag'; import { LITELLM_API_BASE_URL, OPENAI_API_BASE_URL } from '$lib/constants'; import { WEBUI_BASE_URL } from '$lib/constants'; - let stopResponseFlag = false; let autoScroll = true; let processing = ''; @@ -69,6 +69,7 @@ let tags = []; let title = ''; + let pageTitle = WEBUI_NAME; let prompt = ''; let files = []; let messages = []; @@ -77,6 +78,13 @@ currentId: null }; + $: if (title) { + const trimmedTitle = title.length > 30 ? `${title.slice(0, 30)}...` : title; + pageTitle = `${trimmedTitle} | ${$WEBUI_NAME}`; + } else { + pageTitle = $WEBUI_NAME; + } + $: if (history.currentId !== null) { let _messages = []; @@ -809,6 +817,12 @@ }; + + + {pageTitle} + + +
0} {initNewChat} {tags} {addTag} {deleteTag} />
diff --git a/src/routes/(app)/c/[id]/+page.svelte b/src/routes/(app)/c/[id]/+page.svelte index 32af2b17..bd449652 100644 --- a/src/routes/(app)/c/[id]/+page.svelte +++ b/src/routes/(app)/c/[id]/+page.svelte @@ -14,6 +14,7 @@ chats, chatId, config, + WEBUI_NAME, tags as _tags } from '$lib/stores'; import { copyToClipboard, splitStream, convertMessagesToHistory } from '$lib/utils'; @@ -71,6 +72,7 @@ let tags = []; let title = ''; + let pageTitle = WEBUI_NAME; let prompt = ''; let files = []; @@ -80,6 +82,13 @@ currentId: null }; + $: if (title) { + const trimmedTitle = title.length > 30 ? `${title.slice(0, 30)}...` : title; + pageTitle = `${trimmedTitle} | ${$WEBUI_NAME}`; + } else { + pageTitle = $WEBUI_NAME; + } + $: if (history.currentId !== null) { let _messages = []; @@ -100,6 +109,7 @@ await tick(); loaded = true; + window.setTimeout(() => scrollToBottom(), 0); const chatInput = document.getElementById('chat-textarea'); chatInput?.focus(); } else { @@ -823,6 +833,10 @@ }); + + {pageTitle} + + {#if loaded}
Date: Fri, 1 Mar 2024 22:35:08 -0800 Subject: [PATCH 2/3] refac --- src/routes/(app)/+page.svelte | 12 +++--------- src/routes/(app)/c/[id]/+page.svelte | 14 +++++--------- 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/src/routes/(app)/+page.svelte b/src/routes/(app)/+page.svelte index c35b6cd8..e345e2be 100644 --- a/src/routes/(app)/+page.svelte +++ b/src/routes/(app)/+page.svelte @@ -69,7 +69,6 @@ let tags = []; let title = ''; - let pageTitle = WEBUI_NAME; let prompt = ''; let files = []; let messages = []; @@ -78,13 +77,6 @@ currentId: null }; - $: if (title) { - const trimmedTitle = title.length > 30 ? `${title.slice(0, 30)}...` : title; - pageTitle = `${trimmedTitle} | ${$WEBUI_NAME}`; - } else { - pageTitle = $WEBUI_NAME; - } - $: if (history.currentId !== null) { let _messages = []; @@ -819,7 +811,9 @@ - {pageTitle} + {title + ? `${title.length > 30 ? `${title.slice(0, 30)}...` : title} | ${$WEBUI_NAME}` + : `${$WEBUI_NAME}`} diff --git a/src/routes/(app)/c/[id]/+page.svelte b/src/routes/(app)/c/[id]/+page.svelte index bd449652..8448339f 100644 --- a/src/routes/(app)/c/[id]/+page.svelte +++ b/src/routes/(app)/c/[id]/+page.svelte @@ -72,7 +72,6 @@ let tags = []; let title = ''; - let pageTitle = WEBUI_NAME; let prompt = ''; let files = []; @@ -82,13 +81,6 @@ currentId: null }; - $: if (title) { - const trimmedTitle = title.length > 30 ? `${title.slice(0, 30)}...` : title; - pageTitle = `${trimmedTitle} | ${$WEBUI_NAME}`; - } else { - pageTitle = $WEBUI_NAME; - } - $: if (history.currentId !== null) { let _messages = []; @@ -834,7 +826,11 @@ - {pageTitle} + + {title + ? `${title.length > 30 ? `${title.slice(0, 30)}...` : title} | ${$WEBUI_NAME}` + : `${$WEBUI_NAME}`} + {#if loaded} From 78d9c469a2792a82500105abd7c004dedac0905b Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Fri, 1 Mar 2024 22:38:04 -0800 Subject: [PATCH 3/3] feat: title for all routes --- src/routes/(app)/admin/+page.svelte | 8 +++++++- src/routes/(app)/documents/+page.svelte | 8 +++++++- src/routes/(app)/modelfiles/+page.svelte | 8 +++++++- src/routes/(app)/prompts/+page.svelte | 8 +++++++- src/routes/auth/+page.svelte | 6 ++++++ 5 files changed, 34 insertions(+), 4 deletions(-) diff --git a/src/routes/(app)/admin/+page.svelte b/src/routes/(app)/admin/+page.svelte index b1169709..32234b03 100644 --- a/src/routes/(app)/admin/+page.svelte +++ b/src/routes/(app)/admin/+page.svelte @@ -1,6 +1,6 @@ + + + {`Admin Panel | ${$WEBUI_NAME}`} + + + {#key selectedUser} + + + {`Documents | ${$WEBUI_NAME}`} + + + {#if dragged}
+ + + {`Modelfiles | ${$WEBUI_NAME}`} + + +
diff --git a/src/routes/(app)/prompts/+page.svelte b/src/routes/(app)/prompts/+page.svelte index 784c8693..6f0bc0e1 100644 --- a/src/routes/(app)/prompts/+page.svelte +++ b/src/routes/(app)/prompts/+page.svelte @@ -4,7 +4,7 @@ const { saveAs } = fileSaver; import { onMount } from 'svelte'; - import { prompts } from '$lib/stores'; + import { WEBUI_NAME, prompts } from '$lib/stores'; import { createNewPrompt, deletePromptByCommand, getPrompts } from '$lib/apis/prompts'; import { error } from '@sveltejs/kit'; import { goto } from '$app/navigation'; @@ -36,6 +36,12 @@ }; + + + {`Prompts | ${$WEBUI_NAME}`} + + +
diff --git a/src/routes/auth/+page.svelte b/src/routes/auth/+page.svelte index 30c5a93e..a2237794 100644 --- a/src/routes/auth/+page.svelte +++ b/src/routes/auth/+page.svelte @@ -57,6 +57,12 @@ }); + + + {`${$WEBUI_NAME}`} + + + {#if loaded}