Skip to content

Commit ce0a7e3

Browse files
committed
Added new width constants to implement the responsive chat width feature
1 parent dc0ba44 commit ce0a7e3

File tree

6 files changed

+36
-9
lines changed

6 files changed

+36
-9
lines changed

tools/server/webui/src/lib/components/app/chat/ChatForm/ChatForm.svelte

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
ChatFormHelperText,
88
ChatFormTextarea
99
} from '$lib/components/app';
10+
import { MAX_WIDTH_CLASSES, DEFAULT_MAX_WIDTH_CLASS } from '$lib/constants/width-classes';
1011
import { INPUT_CLASSES } from '$lib/constants/input-classes';
1112
import { config } from '$lib/stores/settings.svelte';
1213
import { FileTypeCategory, MimeTypeApplication } from '$lib/enums/files';
@@ -62,6 +63,9 @@
6263
let previousIsLoading = $state(isLoading);
6364
let recordingSupported = $state(false);
6465
let textareaRef: ChatFormTextarea | undefined = $state(undefined);
66+
let maxWidthClass = $derived(
67+
currentConfig.responsiveChatWidth ? MAX_WIDTH_CLASSES : DEFAULT_MAX_WIDTH_CLASS
68+
);
6569
6670
function getAcceptStringForFileType(fileType: FileTypeCategory): string {
6771
switch (fileType) {
@@ -230,7 +234,7 @@
230234

231235
<form
232236
onsubmit={handleSubmit}
233-
class="{INPUT_CLASSES} border-radius-bottom-none mx-auto max-w-[48rem] overflow-hidden rounded-3xl backdrop-blur-md {className}"
237+
class="{INPUT_CLASSES} border-radius-bottom-none mx-auto {maxWidthClass} overflow-hidden rounded-3xl backdrop-blur-md {className}"
234238
>
235239
<ChatAttachmentsList
236240
bind:uploadedFiles

tools/server/webui/src/lib/components/app/chat/ChatMessages/ChatMessageAssistant.svelte

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import { modelName as serverModelName } from '$lib/stores/server.svelte';
2424
import { copyToClipboard } from '$lib/utils/copy';
2525
import type { ApiChatCompletionToolCall } from '$lib/types/api';
26+
import { MAX_WIDTH_CLASSES, DEFAULT_MAX_WIDTH_CLASS } from '$lib/constants/width-classes';
2627
2728
interface Props {
2829
class?: string;
@@ -100,6 +101,10 @@
100101
101102
return serverModel;
102103
});
104+
105+
let maxWidthClass = $derived(
106+
config().responsiveChatWidth ? MAX_WIDTH_CLASSES : DEFAULT_MAX_WIDTH_CLASS
107+
);
103108
104109
function handleCopyModel() {
105110
const model = displayedModel();
@@ -174,7 +179,7 @@
174179
{/if}
175180

176181
{#if message?.role === 'assistant' && isLoading() && !message?.content?.trim()}
177-
<div class="mt-6 w-full max-w-[48rem]" in:fade>
182+
<div class="mt-6 w-full {maxWidthClass}" in:fade>
178183
<div class="processing-container">
179184
<span class="processing-text">
180185
{processingState.getProcessingMessage()}
@@ -220,7 +225,7 @@
220225
</div>
221226
{:else if message.role === 'assistant'}
222227
{#if config().disableReasoningFormat}
223-
<pre class="raw-output">{messageContent || ''}</pre>
228+
<pre class="raw-output {maxWidthClass}">{messageContent || ''}</pre>
224229
{:else}
225230
<MarkdownContent content={messageContent || ''} />
226231
{/if}
@@ -375,7 +380,6 @@
375380
376381
.raw-output {
377382
width: 100%;
378-
max-width: 48rem;
379383
margin-top: 1.5rem;
380384
padding: 1rem 1.25rem;
381385
border-radius: 1rem;

tools/server/webui/src/lib/components/app/chat/ChatMessages/ChatMessages.svelte

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
editAssistantMessage,
1010
regenerateMessageWithBranching
1111
} from '$lib/stores/chat.svelte';
12+
import { config } from '$lib/stores/settings.svelte';
1213
import { getMessageSiblings } from '$lib/utils/branching';
14+
import { MAX_WIDTH_CLASSES, DEFAULT_MAX_WIDTH_CLASS } from '$lib/constants/width-classes';
1315
1416
interface Props {
1517
class?: string;
@@ -21,6 +23,10 @@
2123
2224
let allConversationMessages = $state<DatabaseMessage[]>([]);
2325
26+
let maxWidthClass = $derived(
27+
config().responsiveChatWidth ? MAX_WIDTH_CLASSES : DEFAULT_MAX_WIDTH_CLASS
28+
);
29+
2430
function refreshAllMessages() {
2531
const conversation = activeConversation();
2632
@@ -103,7 +109,7 @@
103109
<div class="flex h-full flex-col space-y-10 pt-16 md:pt-24 {className}" style="height: auto; ">
104110
{#each displayMessages as { message, siblingInfo } (message.id)}
105111
<ChatMessage
106-
class="mx-auto w-full max-w-[48rem]"
112+
class="mx-auto w-full {maxWidthClass}"
107113
{message}
108114
{siblingInfo}
109115
onDelete={handleDeleteMessage}

tools/server/webui/src/lib/components/app/chat/ChatProcessingInfo.svelte

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@
44
import { slotsService } from '$lib/services/slots';
55
import { isLoading, activeMessages, activeConversation } from '$lib/stores/chat.svelte';
66
import { config } from '$lib/stores/settings.svelte';
7+
import { MAX_WIDTH_CLASSES, DEFAULT_MAX_WIDTH_CLASS } from '$lib/constants/width-classes';
78
89
const processingState = useProcessingState();
910
1011
let isCurrentConversationLoading = $derived(isLoading());
1112
let processingDetails = $derived(processingState.getProcessingDetails());
1213
let showSlotsInfo = $derived(isCurrentConversationLoading || config().keepStatsVisible);
14+
let maxWidthClass = $derived(
15+
config().responsiveChatWidth ? MAX_WIDTH_CLASSES : DEFAULT_MAX_WIDTH_CLASS
16+
);
1317
1418
// Track loading state reactively by checking if conversation ID is in loading conversations array
1519
$effect(() => {
@@ -77,7 +81,7 @@
7781
</script>
7882

7983
<div class="chat-processing-info-container pointer-events-none" class:visible={showSlotsInfo}>
80-
<div class="chat-processing-info-content">
84+
<div class="chat-processing-info-content {maxWidthClass}">
8185
{#each processingDetails as detail (detail)}
8286
<span class="chat-processing-info-detail pointer-events-auto">{detail}</span>
8387
{/each}
@@ -108,7 +112,6 @@
108112
align-items: center;
109113
gap: 1rem;
110114
justify-content: center;
111-
max-width: 48rem;
112115
margin: 0 auto;
113116
}
114117

tools/server/webui/src/lib/components/app/chat/ChatScreen/ChatScreen.svelte

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
ConfirmationDialog
1515
} from '$lib/components/app';
1616
import * as AlertDialog from '$lib/components/ui/alert-dialog';
17+
import { config } from '$lib/stores/settings.svelte';
18+
import { MAX_WIDTH_CLASSES, DEFAULT_MAX_WIDTH_CLASS } from '$lib/constants/width-classes';
1719
import {
1820
AUTO_SCROLL_AT_BOTTOM_THRESHOLD,
1921
AUTO_SCROLL_INTERVAL,
@@ -85,6 +87,10 @@
8587
8688
let isCurrentConversationLoading = $derived(isLoading());
8789
90+
let maxWidthClass = $derived(
91+
config().responsiveChatWidth ? MAX_WIDTH_CLASSES : DEFAULT_MAX_WIDTH_CLASS
92+
);
93+
8894
async function handleDeleteConfirm() {
8995
const conversation = activeConversation();
9096
if (conversation) {
@@ -302,7 +308,7 @@
302308
<ChatProcessingInfo />
303309

304310
{#if serverWarning()}
305-
<ChatScreenWarning class="pointer-events-auto mx-auto max-w-[48rem] px-4" />
311+
<ChatScreenWarning class="pointer-events-auto mx-auto {maxWidthClass} px-4" />
306312
{/if}
307313

308314
<div class="conversation-chat-form pointer-events-auto rounded-t-3xl pb-4">
@@ -333,7 +339,7 @@
333339
ondrop={handleDrop}
334340
role="main"
335341
>
336-
<div class="w-full max-w-[48rem] px-4">
342+
<div class="w-full {maxWidthClass} px-4">
337343
<div class="mb-8 text-center" in:fade={{ duration: 300 }}>
338344
<h1 class="mb-2 text-3xl font-semibold tracking-tight">llama.cpp</h1>
339345

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export const MAX_WIDTH_CLASSES =
2+
'max-w-[48rem] md:max-w-[60rem] min-[1920px]:max-w-[80rem] min-[2560px]:max-w-[120rem]';
3+
4+
export const DEFAULT_MAX_WIDTH_CLASS = 'max-w-[48rem]';

0 commit comments

Comments
 (0)