Skip to content

Commit 2bd4d8a

Browse files
allozaurliparetejas
authored andcommitted
webui: Add setting to have full height Code Blocks in Chat Messages (ggml-org#19829)
1 parent 624d596 commit 2bd4d8a

5 files changed

Lines changed: 27 additions & 1 deletion

File tree

tools/server/public/index.html.gz

1.38 KB
Binary file not shown.

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,11 @@
114114
label: 'Render user content as Markdown',
115115
type: SettingsFieldType.CHECKBOX
116116
},
117+
{
118+
key: SETTINGS_KEYS.FULL_HEIGHT_CODE_BLOCKS,
119+
label: 'Use full height code blocks',
120+
type: SettingsFieldType.CHECKBOX
121+
},
117122
{
118123
key: SETTINGS_KEYS.DISABLE_AUTO_SCROLL,
119124
label: 'Disable automatic scroll',

tools/server/webui/src/lib/components/app/content/MarkdownContent.svelte

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
import { ActionIconsCodeBlock, DialogCodePreview } from '$lib/components/app';
3939
import { createAutoScrollController } from '$lib/hooks/use-auto-scroll.svelte';
4040
import type { DatabaseMessageExtra } from '$lib/types/database';
41+
import { config } from '$lib/stores/settings.svelte';
42+
import { SETTINGS_KEYS } from '$lib/constants/settings-keys';
4143
4244
interface Props {
4345
attachments?: DatabaseMessageExtra[];
@@ -593,7 +595,12 @@
593595
});
594596
</script>
595597

596-
<div bind:this={containerRef} class={className}>
598+
<div
599+
bind:this={containerRef}
600+
class="{className}{config()[SETTINGS_KEYS.FULL_HEIGHT_CODE_BLOCKS]
601+
? ' full-height-code-blocks'
602+
: ''}"
603+
>
597604
{#each renderedBlocks as block (block.id)}
598605
<div class="markdown-block" data-block-id={block.id}>
599606
<!-- eslint-disable-next-line no-at-html-tags -->
@@ -914,6 +921,16 @@
914921
line-height: 1.3;
915922
}
916923
924+
.full-height-code-blocks :global(.code-block-wrapper) {
925+
max-height: none;
926+
}
927+
928+
.full-height-code-blocks :global(.code-block-scroll-container),
929+
.full-height-code-blocks .streaming-code-scroll-container {
930+
max-height: none;
931+
overflow-y: visible;
932+
}
933+
917934
div :global(.code-block-header) {
918935
display: flex;
919936
justify-content: space-between;

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export const SETTING_CONFIG_DEFAULT: Record<string, string | number | boolean> =
2222
alwaysShowSidebarOnDesktop: false,
2323
autoShowSidebarOnNewChat: true,
2424
autoMicOnEmpty: false,
25+
fullHeightCodeBlocks: false,
2526
// make sure these default values are in sync with `common.h`
2627
samplers: 'top_k;typ_p;top_p;min_p;temperature',
2728
backend_sampling: false,
@@ -113,6 +114,8 @@ export const SETTING_CONFIG_INFO: Record<string, string> = {
113114
'Automatically show sidebar when starting a new chat. Disable to keep the sidebar hidden until you click on it.',
114115
autoMicOnEmpty:
115116
'Automatically show microphone button instead of send button when textarea is empty for models with audio modality support.',
117+
fullHeightCodeBlocks:
118+
'Always display code blocks at their full natural height, overriding any height limits.',
116119
pyInterpreterEnabled:
117120
'Enable Python interpreter using Pyodide. Allows running Python code in markdown code blocks.',
118121
enableContinueGeneration:

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export const SETTINGS_KEYS = {
2323
DISABLE_AUTO_SCROLL: 'disableAutoScroll',
2424
ALWAYS_SHOW_SIDEBAR_ON_DESKTOP: 'alwaysShowSidebarOnDesktop',
2525
AUTO_SHOW_SIDEBAR_ON_NEW_CHAT: 'autoShowSidebarOnNewChat',
26+
FULL_HEIGHT_CODE_BLOCKS: 'fullHeightCodeBlocks',
2627
// Sampling
2728
TEMPERATURE: 'temperature',
2829
DYNATEMP_RANGE: 'dynatemp_range',

0 commit comments

Comments
 (0)