Commit 918076a63 for llama.cpp
commit 918076a6354c647304c33ca12ee71f80de1c91ae
Author: Emanuil Rusev <hello@erusev.com>
Date: Tue Nov 17 17:17:46 2026 +0200
ui: turn the live markdown preview off by default (#32469)
As discussed in #31955, the live preview is now opt-in. With it on, the editor renders blocks as widgets, and moving the cursor down from the first line of a prompt with a few blocks (a heading, a list, a code block) jumps to the last line; with it off, the cursor moves one line at a time. Users with a saved config keep their current value, since the full config is stored in localStorage.
The message input also gets spellcheck, autocorrect and autocapitalize back. CodeMirror turns them off by default, so they were off with the preview on or off; the former textarea and contenteditable inputs had the browser's defaults.
diff --git a/ui/apps/chat/src/lib/components/app/chat/ChatForm/ChatFormInput/ChatFormInput.svelte b/ui/apps/chat/src/lib/components/app/chat/ChatForm/ChatFormInput/ChatFormInput.svelte
index 7b9bc3b43..06a456a41 100644
--- a/ui/apps/chat/src/lib/components/app/chat/ChatForm/ChatFormInput/ChatFormInput.svelte
+++ b/ui/apps/chat/src/lib/components/app/chat/ChatForm/ChatFormInput/ChatFormInput.svelte
@@ -41,7 +41,7 @@
let editor: MarkdownEditor | undefined = $state();
let box: HTMLDivElement | undefined = $state();
- let livePreview = $derived(settingsStore.config[SETTINGS_KEYS.LIVE_MARKDOWN_PREVIEW] !== false);
+ let livePreview = $derived(settingsStore.config[SETTINGS_KEYS.LIVE_MARKDOWN_PREVIEW] === true);
// Rendered mention badges label paths by these, so the blocks render again on a change
let renderKey = $derived(
@@ -76,6 +76,13 @@
return event.defaultPrevented;
}
+ }),
+ // CodeMirror turns spellcheck, autocorrect and autocapitalize off for code; the
+ // message input is prose, so it gets a textarea's defaults back
+ EditorView.contentAttributes.of({
+ autocapitalize: 'on',
+ autocorrect: 'on',
+ spellcheck: 'true'
})
];
diff --git a/ui/apps/chat/src/lib/constants/settings.constants.ts b/ui/apps/chat/src/lib/constants/settings.constants.ts
index 56f167abf..669ccd6ec 100644
--- a/ui/apps/chat/src/lib/constants/settings.constants.ts
+++ b/ui/apps/chat/src/lib/constants/settings.constants.ts
@@ -126,7 +126,7 @@ export const SETTINGS_REGISTRY: SettingsSectionEntry[] = [
type: SettingsFieldType.CHECKBOX
},
{
- defaultValue: true,
+ defaultValue: false,
help: 'Render the markdown in the message input as you write it: every line but the one you are on shows as it will look in the conversation. When disabled, the input shows the plain markdown text.',
key: SETTINGS_KEYS.LIVE_MARKDOWN_PREVIEW,
label: 'Live markdown preview in the message input',
diff --git a/ui/apps/chat/tests/client/chat-form-input.svelte.test.ts b/ui/apps/chat/tests/client/chat-form-input.svelte.test.ts
index 4278d364a..d271c30e4 100644
--- a/ui/apps/chat/tests/client/chat-form-input.svelte.test.ts
+++ b/ui/apps/chat/tests/client/chat-form-input.svelte.test.ts
@@ -1,6 +1,6 @@
-// Guards the chat form input contract: a live-preview markdown editor whose value
-// stays the exact markdown source, with mention links shown as badges while their
-// block is edited and every block rendered once the editor loses focus. The form's
+// Guards the chat form input contract: a markdown editor whose value stays the exact
+// markdown source, with mention links shown as badges while their block is edited and,
+// with the live preview setting on, every block rendered once the editor loses focus. The form's
// key and paste handlers run first and win when they handle the event.
import { EditorView } from '@codemirror/view';
@@ -80,20 +80,24 @@ describe('ChatFormInput', () => {
expect(editor.state.doc.toString()).toBe('a ');
});
- it('renders every block like a chat message once blurred', async () => {
- const screen = render(ChatFormInput, { value: '# Title\n\nSome **bold** text' });
- const editor = editorIn(screen.container);
+ it('renders every block like a chat message once blurred, with the live preview on', async () => {
+ settingsStore.updateConfig(SETTINGS_KEYS.LIVE_MARKDOWN_PREVIEW, true);
- editor.contentDOM.blur();
- await vi.waitFor(() => {
- expect(screen.container.querySelector('.cm-md-block h1')?.textContent).toBe('Title');
- expect(screen.container.querySelector('.cm-md-block strong')?.textContent).toBe('bold');
- });
- });
+ try {
+ const screen = render(ChatFormInput, { value: '# Title\n\nSome **bold** text' });
+ const editor = editorIn(screen.container);
- it('shows the plain markdown, with mention badges, while the live preview setting is off', async () => {
- settingsStore.updateConfig(SETTINGS_KEYS.LIVE_MARKDOWN_PREVIEW, false);
+ editor.contentDOM.blur();
+ await vi.waitFor(() => {
+ expect(screen.container.querySelector('.cm-md-block h1')?.textContent).toBe('Title');
+ expect(screen.container.querySelector('.cm-md-block strong')?.textContent).toBe('bold');
+ });
+ } finally {
+ settingsStore.updateConfig(SETTINGS_KEYS.LIVE_MARKDOWN_PREVIEW, false);
+ }
+ });
+ it('shows the plain markdown, with mention badges, by default', async () => {
try {
const screen = render(ChatFormInput, { value: `# Title\n\nsee ${MENTION}` });
const editor = editorIn(screen.container);
@@ -114,10 +118,19 @@ describe('ChatFormInput', () => {
expect(screen.container.querySelector('.cm-md-block h1')?.textContent).toBe('Title')
);
} finally {
- settingsStore.updateConfig(SETTINGS_KEYS.LIVE_MARKDOWN_PREVIEW, true);
+ settingsStore.updateConfig(SETTINGS_KEYS.LIVE_MARKDOWN_PREVIEW, false);
}
});
+ it('spellchecks, autocorrects and autocapitalizes like a textarea', () => {
+ const screen = render(ChatFormInput, { value: '' });
+ const content = editorIn(screen.container).contentDOM;
+
+ expect(content.getAttribute('spellcheck')).toBe('true');
+ expect(content.getAttribute('autocorrect')).toBe('on');
+ expect(content.getAttribute('autocapitalize')).toBe('on');
+ });
+
it('lets the form handle a key first and keeps it from the editor', async () => {
const onKeydown = vi.fn((event: KeyboardEvent) => {
if (event.key === 'Enter') event.preventDefault();