Skip to content

Commit 9e2aa9b

Browse files
juliusmarmingecodex
andcommitted
fix(web): suppress markdown title tooltips in user messages
Co-authored-by: codex <[email protected]>
1 parent 6a9a0e8 commit 9e2aa9b

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

‎apps/web/src/components/ChatMarkdown.tsx‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1625,7 +1625,7 @@ function ChatMarkdown({
16251625
/>
16261626
);
16271627
},
1628-
a({ node, href, children, ...props }) {
1628+
a({ node, href, children, title: _title, ...props }) {
16291629
const normalizedHref = href ? normalizeMarkdownLinkHrefKey(href) : "";
16301630
const fileLinkMeta = normalizedHref ? markdownFileLinkMetaByHref.get(normalizedHref) : null;
16311631
if (!fileLinkMeta) {
@@ -1710,6 +1710,9 @@ function ChatMarkdown({
17101710
props.className,
17111711
);
17121712
},
1713+
img({ node: _node, title: _title, ...props }) {
1714+
return <img {...props} />;
1715+
},
17131716
code({ node, children, className, ...props }) {
17141717
if (node?.properties?.dataInlineCode != null) {
17151718
const codeText = nodeToPlainText(children);

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,25 @@ describe("MessagesTimeline", () => {
524524
expect(markup).toContain("&lt;root&gt;&lt;child enabled=&quot;true&quot; /&gt;&lt;/root&gt;");
525525
});
526526

527+
it("does not render markdown title attributes in user messages", async () => {
528+
const { MessagesTimeline } = await import("./MessagesTimeline");
529+
const markup = renderToStaticMarkup(
530+
<MessagesTimeline
531+
{...buildProps()}
532+
timelineEntries={[
533+
buildUserTimelineEntry(
534+
'[link](https://example.com "link tip") ![image](https://example.com/image.png "image tip")',
535+
),
536+
]}
537+
/>,
538+
);
539+
540+
expect(markup).toContain('href="https://example.com"');
541+
expect(markup).toContain('src="https://example.com/image.png"');
542+
expect(markup).not.toContain('title="link tip"');
543+
expect(markup).not.toContain('title="image tip"');
544+
});
545+
527546
it("renders unsafe user HTML as inert source text", async () => {
528547
const { MessagesTimeline } = await import("./MessagesTimeline");
529548
const markup = renderToStaticMarkup(

0 commit comments

Comments
 (0)