mirror of
https://github.com/open-webui/open-webui
synced 2025-06-26 18:26:48 +00:00
feat: chat controls ui
This commit is contained in:
@@ -60,14 +60,15 @@
|
||||
import Navbar from '$lib/components/layout/Navbar.svelte';
|
||||
import CallOverlay from './MessageInput/CallOverlay.svelte';
|
||||
import { error } from '@sveltejs/kit';
|
||||
import ChatControls from './ChatControls.svelte';
|
||||
|
||||
const i18n: Writable<i18nType> = getContext('i18n');
|
||||
|
||||
export let chatIdProp = '';
|
||||
let loaded = false;
|
||||
|
||||
const eventTarget = new EventTarget();
|
||||
|
||||
let showControls = false;
|
||||
let stopResponseFlag = false;
|
||||
let autoScroll = true;
|
||||
let processing = '';
|
||||
@@ -1424,6 +1425,7 @@
|
||||
{title}
|
||||
bind:selectedModels
|
||||
bind:showModelSelector
|
||||
bind:showControls
|
||||
shareEnabled={messages.length > 0}
|
||||
{chat}
|
||||
{initNewChat}
|
||||
@@ -1460,7 +1462,9 @@
|
||||
|
||||
<div class="flex flex-col flex-auto z-10">
|
||||
<div
|
||||
class=" pb-2.5 flex flex-col justify-between w-full flex-auto overflow-auto h-0 max-w-full z-10"
|
||||
class=" pb-2.5 flex flex-col justify-between w-full flex-auto overflow-auto h-0 max-w-full z-10 scrollbar-hidden {showControls
|
||||
? 'lg:pr-[28rem]'
|
||||
: ''} "
|
||||
id="messages-container"
|
||||
bind:this={messagesContainerElement}
|
||||
on:scroll={(e) => {
|
||||
@@ -1485,26 +1489,31 @@
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<MessageInput
|
||||
bind:files
|
||||
bind:prompt
|
||||
bind:autoScroll
|
||||
bind:selectedToolIds
|
||||
bind:webSearchEnabled
|
||||
bind:atSelectedModel
|
||||
availableToolIds={selectedModelIds.reduce((a, e, i, arr) => {
|
||||
const model = $models.find((m) => m.id === e);
|
||||
if (model?.info?.meta?.toolIds ?? false) {
|
||||
return [...new Set([...a, ...model.info.meta.toolIds])];
|
||||
}
|
||||
return a;
|
||||
}, [])}
|
||||
transparentBackground={$settings?.backgroundImageUrl ?? false}
|
||||
{selectedModels}
|
||||
{messages}
|
||||
{submitPrompt}
|
||||
{stopResponse}
|
||||
/>
|
||||
|
||||
<div class={showControls ? 'lg:pr-[28rem]' : ''}>
|
||||
<MessageInput
|
||||
bind:files
|
||||
bind:prompt
|
||||
bind:autoScroll
|
||||
bind:selectedToolIds
|
||||
bind:webSearchEnabled
|
||||
bind:atSelectedModel
|
||||
availableToolIds={selectedModelIds.reduce((a, e, i, arr) => {
|
||||
const model = $models.find((m) => m.id === e);
|
||||
if (model?.info?.meta?.toolIds ?? false) {
|
||||
return [...new Set([...a, ...model.info.meta.toolIds])];
|
||||
}
|
||||
return a;
|
||||
}, [])}
|
||||
transparentBackground={$settings?.backgroundImageUrl ?? false}
|
||||
{selectedModels}
|
||||
{messages}
|
||||
{submitPrompt}
|
||||
{stopResponse}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ChatControls bind:show={showControls} />
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
61
src/lib/components/chat/ChatControls.svelte
Normal file
61
src/lib/components/chat/ChatControls.svelte
Normal file
@@ -0,0 +1,61 @@
|
||||
<script lang="ts">
|
||||
import { slide } from 'svelte/transition';
|
||||
import Modal from '../common/Modal.svelte';
|
||||
import Controls from './Controls/Controls.svelte';
|
||||
import { onMount } from 'svelte';
|
||||
|
||||
export let show = false;
|
||||
|
||||
let largeScreen = false;
|
||||
|
||||
onMount(() => {
|
||||
// listen to resize 1024px
|
||||
const mediaQuery = window.matchMedia('(min-width: 1024px)');
|
||||
|
||||
const handleMediaQuery = (e) => {
|
||||
if (e.matches) {
|
||||
largeScreen = true;
|
||||
} else {
|
||||
largeScreen = false;
|
||||
}
|
||||
};
|
||||
|
||||
mediaQuery.addEventListener('change', handleMediaQuery);
|
||||
|
||||
handleMediaQuery(mediaQuery);
|
||||
|
||||
return () => {
|
||||
mediaQuery.removeEventListener('change', handleMediaQuery);
|
||||
};
|
||||
});
|
||||
</script>
|
||||
|
||||
{#if largeScreen}
|
||||
<div
|
||||
class="fixed h-screen max-h-[100dvh] min-h-screen z-50 top-0 right-0 {show
|
||||
? 'w-[28rem]'
|
||||
: 'w-0 translate-x-[28rem] '} transition"
|
||||
>
|
||||
<div class="px-6 pt-14 pb-8 h-full">
|
||||
<div
|
||||
class=" px-5 py-4 h-full dark:bg-gray-850 border border-gray-100 dark:border-gray-800 rounded-xl shadow-lg"
|
||||
>
|
||||
<Controls
|
||||
on:close={() => {
|
||||
show = false;
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{:else}
|
||||
<Modal bind:show>
|
||||
<div class=" px-5 py-4 h-full">
|
||||
<Controls
|
||||
on:close={() => {
|
||||
show = false;
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</Modal>
|
||||
{/if}
|
||||
24
src/lib/components/chat/Controls/Controls.svelte
Normal file
24
src/lib/components/chat/Controls/Controls.svelte
Normal file
@@ -0,0 +1,24 @@
|
||||
<script>
|
||||
import { createEventDispatcher } from 'svelte';
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
import XMark from '$lib/components/icons/XMark.svelte';
|
||||
</script>
|
||||
|
||||
<div class=" dark:text-white">
|
||||
<div class="mb-2 flex justify-between items-center">
|
||||
<div class=" text-xl font-medium font-primary">Chat Controls</div>
|
||||
|
||||
<div>
|
||||
<button
|
||||
on:click={() => {
|
||||
dispatch('close');
|
||||
}}
|
||||
>
|
||||
<XMark className="size-4" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>coming soon</div>
|
||||
</div>
|
||||
@@ -34,7 +34,7 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="flex flex-col w-full items-center md:items-start">
|
||||
<div class="flex flex-col w-full items-start">
|
||||
{#each selectedModels as selectedModel, selectedModelIdx}
|
||||
<div class="flex w-full max-w-fit">
|
||||
<div class="overflow-hidden w-full">
|
||||
|
||||
Reference in New Issue
Block a user