{hunk.lines.map((line, lineIdx) => {
- const html = highlighted?.[lineCursor];
+ const html = highlighted.lines?.[lineCursor];
lineCursor += 1;
return (
= ({ diff, filePath }) => {
{line.lineNumber || ''}
-
+
);
@@ -106,7 +118,11 @@ export const WritePreview: React.FC
= ({ content, filePath })
{lineIdx + 1}
-
+
))}
diff --git a/packages/ui/src/components/chat/markdown/markdown-worker.ts b/packages/ui/src/components/chat/markdown/markdown-worker.ts
index ab5b6eb6..2feb270a 100644
--- a/packages/ui/src/components/chat/markdown/markdown-worker.ts
+++ b/packages/ui/src/components/chat/markdown/markdown-worker.ts
@@ -167,6 +167,12 @@ export const highlightLinesInWorker = async (code: string, lang: string): Promis
return result?.type === 'highlightLines' ? result.lines : null;
};
+/** Return an already-tokenized line result without scheduling a worker request. */
+export const getCachedHighlightedLines = (code: string, lang: string): string[] | null => {
+ const cached = resultCache.get(cacheKeyFor('highlightLines', lang, code));
+ return cached?.type === 'highlightLines' ? cached.lines : null;
+};
+
/**
* Tokenize `code` with the given resolved TextMate theme and return per-line
* styled runs with offsets — for building CodeMirror decorations that match the
diff --git a/packages/ui/src/components/chat/message/parts/VirtualizedCodeBlock.tsx b/packages/ui/src/components/chat/message/parts/VirtualizedCodeBlock.tsx
index 5ef116d7..fcc29517 100644
--- a/packages/ui/src/components/chat/message/parts/VirtualizedCodeBlock.tsx
+++ b/packages/ui/src/components/chat/message/parts/VirtualizedCodeBlock.tsx
@@ -54,7 +54,8 @@ export const VirtualizedCodeBlock: React.FC