-
Notifications
You must be signed in to change notification settings - Fork 235
fix(webview): render expanded task header text as markdown with consistent scrollbar #1257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
155ac1c
c90f28d
0f4deba
73ed937
0842e9b
1d13c74
3811f0b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -6,12 +6,66 @@ import rehypeKatex from "rehype-katex" | |||||||||||
| import remarkMath from "remark-math" | ||||||||||||
| import remarkGfm from "remark-gfm" | ||||||||||||
|
|
||||||||||||
| import { mentionRegexGlobal } from "@roo/context-mentions" | ||||||||||||
|
|
||||||||||||
| import { vscode } from "@src/utils/vscode" | ||||||||||||
| import { type AlertType, remarkGithubAlerts } from "@src/utils/markdown" | ||||||||||||
|
|
||||||||||||
| import CodeBlock from "./CodeBlock" | ||||||||||||
| import MermaidBlock from "./MermaidBlock" | ||||||||||||
|
|
||||||||||||
| /** | ||||||||||||
| * Rehype plugin that wraps context mentions (@/path, @problems, @terminal, etc.) | ||||||||||||
| * in clickable spans matching the styling used by the collapsed Mention component. | ||||||||||||
| */ | ||||||||||||
| function rehypeMentions() { | ||||||||||||
| return (tree: any) => { | ||||||||||||
| visit(tree, "text", (node: any, index, parent) => { | ||||||||||||
| if (parent?.tagName === "span" && parent.properties?.className?.includes("mention-context-highlight")) { | ||||||||||||
| return | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| const originalValue = String(node.value) | ||||||||||||
| const matches = Array.from(originalValue.matchAll(mentionRegexGlobal)) | ||||||||||||
|
|
||||||||||||
| if (matches.length === 0) { | ||||||||||||
| return | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| const children: any[] = [] | ||||||||||||
| let lastIndex = 0 | ||||||||||||
|
|
||||||||||||
| for (const match of matches) { | ||||||||||||
| const mentionText = match[0] | ||||||||||||
| const mentionValue = match[1] ?? mentionText.slice(1) // capture group or full mention without @ | ||||||||||||
| const mentionStart = match.index! | ||||||||||||
|
|
||||||||||||
| if (mentionStart > lastIndex) { | ||||||||||||
| children.push({ type: "text", value: originalValue.slice(lastIndex, mentionStart) }) | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| children.push({ | ||||||||||||
| type: "element", | ||||||||||||
| tagName: "span", | ||||||||||||
| properties: { | ||||||||||||
| className: ["mention-context-highlight", "text-[0.9em]", "cursor-pointer"], | ||||||||||||
| onClick: () => vscode.postMessage({ type: "openMention", text: mentionValue }), | ||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win Keep the expanded task panel open after a mention click. The mention is a
Proposed fix- onClick: () => vscode.postMessage({ type: "openMention", text: mentionValue }),
+ onClick: (event: React.MouseEvent<HTMLSpanElement>) => {
+ event.stopPropagation()
+ vscode.postMessage({ type: "openMention", text: mentionValue })
+ },📝 Committable suggestion
Suggested change
📍 Affects 2 files
🤖 Prompt for AI Agents |
||||||||||||
| }, | ||||||||||||
| children: [{ type: "text", value: mentionText }], | ||||||||||||
| }) | ||||||||||||
|
|
||||||||||||
| lastIndex = mentionStart + mentionText.length | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| if (lastIndex < originalValue.length) { | ||||||||||||
| children.push({ type: "text", value: originalValue.slice(lastIndex) }) | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| parent.children.splice(index, 1, ...children) | ||||||||||||
| }) | ||||||||||||
| } | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| // Codicon glyphs used as the leading icon for each GitHub-style alert type. | ||||||||||||
| const ALERT_ICONS: Record<AlertType, string> = { | ||||||||||||
| note: "codicon-info", | ||||||||||||
|
|
@@ -415,7 +469,7 @@ const MarkdownBlock = memo(({ markdown }: MarkdownBlockProps) => { | |||||||||||
| } | ||||||||||||
| }, | ||||||||||||
| ]} | ||||||||||||
| rehypePlugins={[rehypeKatex as any]} | ||||||||||||
| rehypePlugins={[rehypeMentions, rehypeKatex as any]} | ||||||||||||
| components={components}> | ||||||||||||
| {markdown || ""} | ||||||||||||
| </ReactMarkdown> | ||||||||||||
|
|
||||||||||||
Uh oh!
There was an error while loading. Please reload this page.