Skip to content

Commit 796c4a8

Browse files
feat: render user content as markdown option
- Add a persisted 'renderUserContentAsMarkdown' preference to the settings defaults and info metadata so the choice survives reloads like other options - Surface the new 'Render user content as Markdown' checkbox in the General section of the chat settings dialog, beneath the PDF toggle - Render user chat messages with 'MarkdownContent' when the new setting is enabled, matching assistant formatting while preserving the existing card styling otherwise - chore: update webui build output
1 parent e308efd commit 796c4a8

File tree

4 files changed

+22
-4
lines changed

4 files changed

+22
-4
lines changed

tools/server/public/index.html.gz

208 Bytes
Binary file not shown.

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

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
import { Check, X } from '@lucide/svelte';
33
import { Card } from '$lib/components/ui/card';
44
import { Button } from '$lib/components/ui/button';
5-
import { ChatAttachmentsList } from '$lib/components/app';
5+
import { ChatAttachmentsList, MarkdownContent } from '$lib/components/app';
66
import { INPUT_CLASSES } from '$lib/constants/input-classes';
7+
import { config } from '$lib/stores/settings.svelte';
78
import ChatMessageActions from './ChatMessageActions.svelte';
89
910
interface Props {
@@ -55,6 +56,7 @@
5556
5657
let isMultiline = $state(false);
5758
let messageElement: HTMLElement | undefined = $state();
59+
const currentConfig = config();
5860
5961
$effect(() => {
6062
if (!messageElement || !message.content.trim()) return;
@@ -123,9 +125,18 @@
123125
class="max-w-[80%] rounded-[1.125rem] bg-primary px-3.75 py-1.5 text-primary-foreground data-[multiline]:py-2.5"
124126
data-multiline={isMultiline ? '' : undefined}
125127
>
126-
<span bind:this={messageElement} class="text-md whitespace-pre-wrap">
127-
{message.content}
128-
</span>
128+
{#if currentConfig.renderUserContentAsMarkdown}
129+
<div bind:this={messageElement} class="text-md">
130+
<MarkdownContent
131+
class="markdown-user-content text-primary-foreground"
132+
content={message.content}
133+
/>
134+
</div>
135+
{:else}
136+
<span bind:this={messageElement} class="text-md whitespace-pre-wrap">
137+
{message.content}
138+
</span>
139+
{/if}
129140
</Card>
130141
{/if}
131142

tools/server/webui/src/lib/components/app/chat/ChatSettings/ChatSettingsDialog.svelte

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@
8080
key: 'showModelInfo',
8181
label: 'Show model information',
8282
type: 'checkbox'
83+
},
84+
{
85+
key: 'renderUserContentAsMarkdown',
86+
label: 'Render user content as Markdown',
87+
type: 'checkbox'
8388
}
8489
]
8590
},

tools/server/webui/src/lib/constants/settings-config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export const SETTING_CONFIG_DEFAULT: Record<string, string | number | boolean> =
1111
pasteLongTextToFileLen: 2500,
1212
pdfAsImage: false,
1313
showModelInfo: false,
14+
renderUserContentAsMarkdown: false,
1415
// make sure these default values are in sync with `common.h`
1516
samplers: 'top_k;typ_p;top_p;min_p;temperature',
1617
temperature: 0.8,
@@ -81,6 +82,7 @@ export const SETTING_CONFIG_INFO: Record<string, string> = {
8182
'Ask for confirmation before automatically changing conversation title when editing the first message.',
8283
pdfAsImage: 'Parse PDF as image instead of text (requires vision-capable model).',
8384
showModelInfo: 'Display the model name used to generate each message below the message content.',
85+
renderUserContentAsMarkdown: 'Render user messages using markdown formatting in the chat.',
8486
pyInterpreterEnabled:
8587
'Enable Python interpreter using Pyodide. Allows running Python code in markdown code blocks.'
8688
};

0 commit comments

Comments
 (0)