fix(web): show minimap previews as plain text, not raw markdown #15715
Mergednikhilnigamnik(GitHub profile, opens in a new tab)merged 9 commits into
main fromrefs/pull/15715/headmerged by juliusmarminge View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:S
- apps/web/src/components/chat/timelineMinimapItems.ts lines 61 to 61OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -48,3 +48,14 @@4848 return finalAssistantText;4949 }505051+/** Drops markdown syntax so table, list, and link sources read as plain preview text. */52+function stripMarkdownForPreview(text: string) {53+ return (54+ text55+ // Code fence lines, then table delimiter rows and thematic breaks.56+ .replace(/^[ \t]*(?:```|~~~).*$/gm, "")57+ .replace(/^[ \t]*\|?[ \t]*:?-{3,}:?[ \t]*(?:\|[ \t]*:?-{3,}:?[ \t]*)*\|?[ \t]*$/gm, "")58+ // Table rows keep their cell text.59+ .replace(/^[ \t]*\|(.*?)\|?[ \t]*$/gm, (_, cells: string) => cells.replace(/\s*\|\s*/g, " "))60+ // Blockquote, heading, list, and task markers at the start of a line.61+ .replace(/^[ \t]*(?:>[ \t]*)*(?:(?:#{1,6}|[-*+]|\d+[.)])[ \t]+)?(?:\[[ xX]\][ \t]+)?/gm, "")apps/web/src/components/chat/timelineMinimapItems.ts lines 59 to 59OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -48,3 +48,12 @@4848 return finalAssistantText;4949 }505051+/** Drops markdown syntax so table, list, and link sources read as plain preview text. */52+function stripMarkdownForPreview(text: string) {53+ return (54+ text55+ // Code fence lines, then table delimiter rows and thematic breaks.56+ .replace(/^[ \t]*(?:```|~~~).*$/gm, "")57+ .replace(/^[ \t]*\|?[ \t]*:?-{3,}:?[ \t]*(?:\|[ \t]*:?-{3,}:?[ \t]*)*\|?[ \t]*$/gm, "")58+ // Table rows keep their cell text.59+ .replace(/^[ \t]*\|(.*?)\|?[ \t]*$/gm, (_, cells: string) => cells.replace(/\s*\|\s*/g, " "))apps/web/src/components/chat/timelineMinimapItems.ts line 52OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -48,3 +48,5 @@4848 return finalAssistantText;4949 }505051+/** Drops markdown syntax so table, list, and link sources read as plain preview text. */52+function stripMarkdownForPreview(text: string) {
- apps/web/src/components/chat/timelineMinimapItems.ts line 59OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -48,3 +48,12 @@4848 return finalAssistantText;4949 }505051+/** Drops markdown syntax so table, list, and link sources read as plain preview text. */52+function stripMarkdownForPreview(text: string) {53+ return (54+ text55+ // Code fence lines, then table delimiter rows and thematic breaks.56+ .replace(/^[ \t]*(?:```|~~~).*$/gm, "")57+ .replace(/^[ \t]*\|?[ \t]*:?-{3,}:?[ \t]*(?:\|[ \t]*:?-{3,}:?[ \t]*)*\|?[ \t]*$/gm, "")58+ // Table rows keep their cell text.59+ .replace(/^[ \t]*\|(.*?)\|?[ \t]*$/gm, (_, cells: string) => cells.replace(/\s*\|\s*/g, " "))
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:S
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
juliusmarminge added labelsmacroscope-review
- apps/web/src/components/chat/timelineMinimapItems.ts lines 83 to 83Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -48,3 +53,21 @@4853 return finalAssistantText;4954 }505556+const markdownPreviewParser = unified().use(remarkParse).use(remarkGfm).freeze();57+58+const INLINE_PARENT_TYPES = new Set<Nodes["type"]>([59+ "paragraph",60+ "heading",61+ "tableCell",62+ "emphasis",63+ "strong",64+ "delete",65+ "link",66+ "linkReference",67+]);68+69+function markdownNodeText(node: Nodes): string {70+ if (node.type === "html") return "";71+ if ("value" in node) return node.value;72+ if (node.type === "image" || node.type === "imageReference") return node.alt ?? "";73+ if (!("children" in node)) return "";
juliusmarminge assignedjuliusmarminge
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
juliusmarminge merged thise676509
juliusmarminge closed this
Sign in to join this conversation.


macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed