Skip to content

Commit 623e471

Browse files
cursor[bot]cursoragentjuliusmarminge
authored
Fix markdown highlight render stability (#2479)
Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Julius Marminge <juliusmarminge@users.noreply.github.com>
1 parent 91a03e0 commit 623e471

2 files changed

Lines changed: 30 additions & 2 deletions

File tree

apps/web/src/components/ChatMarkdown.tsx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,32 @@ function SuspenseShikiCodeBlock({
211211
);
212212
}
213213

214+
return (
215+
<UncachedShikiCodeBlock
216+
code={code}
217+
language={language}
218+
themeName={themeName}
219+
cacheKey={cacheKey}
220+
isStreaming={isStreaming}
221+
/>
222+
);
223+
}
224+
225+
interface UncachedShikiCodeBlockProps {
226+
code: string;
227+
language: string;
228+
themeName: DiffThemeName;
229+
cacheKey: string;
230+
isStreaming: boolean;
231+
}
232+
233+
function UncachedShikiCodeBlock({
234+
code,
235+
language,
236+
themeName,
237+
cacheKey,
238+
isStreaming,
239+
}: UncachedShikiCodeBlockProps) {
214240
const highlighter = use(getHighlighterPromise(language));
215241
const highlightedHtml = useMemo(() => {
216242
try {

apps/web/src/components/chat/MessagesTimeline.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ interface TimelineRowSharedState {
8787
}
8888

8989
const TimelineRowCtx = createContext<TimelineRowSharedState>(null!);
90+
const TIMELINE_LIST_HEADER = <div className="h-3 sm:h-4" />;
91+
const TIMELINE_LIST_FOOTER = <div className="h-3 sm:h-4" />;
9092

9193
// ---------------------------------------------------------------------------
9294
// Props (public API)
@@ -261,8 +263,8 @@ export const MessagesTimeline = memo(function MessagesTimeline({
261263
maintainVisibleContentPosition
262264
onScroll={handleScroll}
263265
className="h-full overflow-x-hidden overscroll-y-contain px-3 sm:px-5"
264-
ListHeaderComponent={<div className="h-3 sm:h-4" />}
265-
ListFooterComponent={<div className="h-3 sm:h-4" />}
266+
ListHeaderComponent={TIMELINE_LIST_HEADER}
267+
ListFooterComponent={TIMELINE_LIST_FOOTER}
266268
/>
267269
</TimelineRowCtx.Provider>
268270
);

0 commit comments

Comments
 (0)