From ef8268feee28ae943958049bf3bbab4bda99c0ea Mon Sep 17 00:00:00 2001 From: franitel Date: Sun, 14 Jun 2026 22:56:56 +0200 Subject: [PATCH] fix(ui): render thinking/reasoning block content as markdown (#24611) * fix(ui): render thinking/reasoning block content as markdown * feat(ui): add toggle setting for thinking block markdown rendering --- .../ChatMessageAgenticContent.svelte | 21 +++++++++++++------ tools/ui/src/lib/constants/settings-keys.ts | 1 + .../ui/src/lib/constants/settings-registry.ts | 12 +++++++++++ 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/tools/ui/src/lib/components/app/chat/ChatMessages/ChatMessageAgenticContent.svelte b/tools/ui/src/lib/components/app/chat/ChatMessages/ChatMessageAgenticContent.svelte index e21dff993f..07b0489cc3 100644 --- a/tools/ui/src/lib/components/app/chat/ChatMessages/ChatMessageAgenticContent.svelte +++ b/tools/ui/src/lib/components/app/chat/ChatMessages/ChatMessageAgenticContent.svelte @@ -56,6 +56,7 @@ const showToolCallInProgress = $derived(config().showToolCallInProgress as boolean); const showThoughtInProgress = $derived(config().showThoughtInProgress as boolean); + const renderThinkingAsMarkdown = $derived(config().renderThinkingAsMarkdown as boolean); const hasReasoningError = $derived( isLastAssistantMessage ? !!agenticLastError(message.convId) : false @@ -316,9 +317,13 @@ onToggle={() => toggleExpanded(index, section)} >
-
- {section.content} -
+ {#if renderThinkingAsMarkdown} + + {:else} +
+ {section.content} +
+ {/if}
{:else if section.type === AgenticSectionType.REASONING_PENDING} @@ -336,9 +341,13 @@ onToggle={() => toggleExpanded(index, section)} >
-
- {section.content} -
+ {#if renderThinkingAsMarkdown} + + {:else} +
+ {section.content} +
+ {/if}
{/if} diff --git a/tools/ui/src/lib/constants/settings-keys.ts b/tools/ui/src/lib/constants/settings-keys.ts index eea28b3409..a3046caa93 100644 --- a/tools/ui/src/lib/constants/settings-keys.ts +++ b/tools/ui/src/lib/constants/settings-keys.ts @@ -33,6 +33,7 @@ export const SETTINGS_KEYS = { SHOW_MODEL_TAGS: 'showModelTags', SHOW_BUILD_VERSION: 'showBuildVersion', SHOW_SYSTEM_MESSAGE: 'showSystemMessage', + RENDER_THINKING_AS_MARKDOWN: 'renderThinkingAsMarkdown', // Sampling TEMPERATURE: 'temperature', DYNATEMP_RANGE: 'dynatemp_range', diff --git a/tools/ui/src/lib/constants/settings-registry.ts b/tools/ui/src/lib/constants/settings-registry.ts index f3f1829753..37161c8e32 100644 --- a/tools/ui/src/lib/constants/settings-registry.ts +++ b/tools/ui/src/lib/constants/settings-registry.ts @@ -282,6 +282,18 @@ const SETTINGS_REGISTRY: Record = { paramType: SyncableParameterType.BOOLEAN } }, + { + key: SETTINGS_KEYS.RENDER_THINKING_AS_MARKDOWN, + label: 'Render thinking as Markdown', + help: 'Render the reasoning/thinking block content as formatted Markdown instead of plain text.', + defaultValue: true, + type: SettingsFieldType.CHECKBOX, + section: SETTINGS_SECTION_SLUGS.DISPLAY, + sync: { + serverKey: SETTINGS_KEYS.RENDER_THINKING_AS_MARKDOWN, + paramType: SyncableParameterType.BOOLEAN + } + }, { key: SETTINGS_KEYS.FULL_HEIGHT_CODE_BLOCKS, label: 'Use full height code blocks',