Fix markdown highlight render stability (#2479)

Co-authored-by: Cursor Agent <[email protected]>
Co-authored-by: Julius Marminge <[email protected]>
This commit is contained in:
authored and GitHub committed 2026-05-04 09:38:17 -07:00
1 parent 91a03e0747
commit 623e471a02
2 files changed
+30 -2

No files matched your search

+26
View File
@@ -211,6 +211,32 @@ function SuspenseShikiCodeBlock({
);
}
return (
<UncachedShikiCodeBlock
code={code}
language={language}
themeName={themeName}
cacheKey={cacheKey}
isStreaming={isStreaming}
/>
);
}
interface UncachedShikiCodeBlockProps {
code: string;
language: string;
themeName: DiffThemeName;
cacheKey: string;
isStreaming: boolean;
}
function UncachedShikiCodeBlock({
code,
language,
themeName,
cacheKey,
isStreaming,
}: UncachedShikiCodeBlockProps) {
const highlighter = use(getHighlighterPromise(language));
const highlightedHtml = useMemo(() => {
try {
@@ -87,6 +87,8 @@ interface TimelineRowSharedState {
}
const TimelineRowCtx = createContext<TimelineRowSharedState>(null!);
const TIMELINE_LIST_HEADER = <div className="h-3 sm:h-4" />;
const TIMELINE_LIST_FOOTER = <div className="h-3 sm:h-4" />;
// ---------------------------------------------------------------------------
// Props (public API)
@@ -261,8 +263,8 @@ export const MessagesTimeline = memo(function MessagesTimeline({
maintainVisibleContentPosition
onScroll={handleScroll}
className="h-full overflow-x-hidden overscroll-y-contain px-3 sm:px-5"
ListHeaderComponent={<div className="h-3 sm:h-4" />}
ListFooterComponent={<div className="h-3 sm:h-4" />}
ListHeaderComponent={TIMELINE_LIST_HEADER}
ListFooterComponent={TIMELINE_LIST_FOOTER}
/>
</TimelineRowCtx.Provider>
);