Skip to content

Commit 1dd2e50

Browse files
committed
fix: render system prompt as md in nonediting mode
1 parent dbd4ba2 commit 1dd2e50

1 file changed

Lines changed: 20 additions & 3 deletions

File tree

examples/playground-react/client/components/SystemPrompt.jsx

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import { useState, useEffect, useRef } from 'react';
55
import { useApp } from '../context';
66
import { FaChevronDown, FaChevronUp } from 'react-icons/fa';
7+
import { renderMarkdown } from '../utils';
78

89
export function SystemPrompt() {
910
const {
@@ -166,9 +167,25 @@ export function SystemPrompt() {
166167
autoFocus
167168
rows={4}
168169
/>
170+
) : systemMsg?.text?.trim() ? (
171+
<div
172+
className="system-prompt-pinned-display"
173+
onClick={startEdit}
174+
onKeyDown={(e) => {
175+
if (e.key === 'Enter' || e.key === ' ') {
176+
e.preventDefault();
177+
startEdit();
178+
}
179+
}}
180+
tabIndex={4}
181+
role="button"
182+
style={{ cursor: 'pointer' }}
183+
aria-label="Edit system prompt"
184+
dangerouslySetInnerHTML={{ __html: renderMarkdown(systemMsg.text) }}
185+
/>
169186
) : (
170-
<div
171-
className="system-prompt-pinned-display"
187+
<div
188+
className="system-prompt-pinned-display system-prompt-empty"
172189
onClick={startEdit}
173190
onKeyDown={(e) => {
174191
if (e.key === 'Enter' || e.key === ' ') {
@@ -181,7 +198,7 @@ export function SystemPrompt() {
181198
style={{ cursor: 'pointer' }}
182199
aria-label="Edit system prompt"
183200
>
184-
{systemMsg?.text || <em style={{ color: '#999' }}>Click to add system prompt...</em>}
201+
Click to add system prompt...
185202
</div>
186203
)}
187204
</div>

0 commit comments

Comments
 (0)