Repository navigation
fix(web): preserve Mermaid source when copying selected text - #16249
NikitaMGrimm wants to merge 2 commits into
Conversation
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — This is a small, well-contained clipboard bug fix that preserves Mermaid source while keeping structured context exports limited to actually selected chips. The production changes are localized to existing chat rendering and copy handling, with targeted regression coverage and no product-default or static-analysis configuration changes. You can add or adjust custom eligibility rules. Learn more. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe change adds an exported Markdown code-block serializer and uses it to preserve Mermaid source in clipboard payloads for selections within rendered diagrams. The copied-Markdown scan excludes Mermaid elements when identifying structured context records. ChangesMermaid Clipboard
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Sequence Diagram(s)sequenceDiagram
participant MermaidDiagram
participant DOMSelection
participant chatMarkdownClipboardPayload
MermaidDiagram->>chatMarkdownClipboardPayload: store serialized Mermaid Markdown
DOMSelection->>chatMarkdownClipboardPayload: provide selected range
chatMarkdownClipboardPayload->>MermaidDiagram: read stored Markdown source
Suggested reviewers: Merge Risk: ⚪ Minimal · up to Mermaid source remains available for copying without being treated as a context record. No issue identified here requires a change before merging. Security Architecture ReviewSecurity architecture risk: ⚪ Minimal · up to Copying a selected diagram now preserves its source without granting additional access or automatically attaching related context. No material security risk was found in the changed behavior. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
Note 🤖 gpt-6.1-sol responding on behalf of NikitaMGrimm Verified the structured-context concern and fixed it in 7c7a2d1. The user-message copy handler now excludes Mermaid source overrides when choosing context records; the source still copies as fenced Markdown. The regression failed before the fix and now confirms that an image link hidden in a Mermaid comment exports no image record unless its chip is selected. All 115 tests across the timeline and clipboard suites, web typecheck, and targeted lint/format checks passed (existing lint warnings only). |
|
Note Written by Hi! We are cleaning up open PRs, and this one does not say which model or harness was used to create it. If this change is really important, we recommend rebuilding the PR with a newer model and noting the model and harness in the PR description. |
|
Note Written by Reopening, this was closed by mistake. Sorry for the noise! |
Dismissing prior approval to re-evaluate 7c7a2d1
Problem
Selecting prose across a rendered Mermaid diagram drops the diagram from copied Markdown in assistant and sent-user messages. Drag from the text above a diagram to the text below it, copy, and paste: only the prose remains.
Change
Give rendered diagrams the existing Markdown copy override containing fenced Mermaid source. Crossing selections preserve the selected surrounding prose; selections wholly inside a diagram copy its complete source. Partial “Show code” selections remain partial. Diagram-source links are excluded when choosing structured context records to export.
Scope and approval
Submitted under the very small, focused obvious-bug exception: the established selection-to-Markdown workflow loses rendered message content. The fix stays in the shared web/desktop renderer and adds no dependency or setting. No prior maintainer approval is claimed.
Verification
Previously recorded on this PR head; not rerun in this audit:
vp test run apps/web/src/components/chat/MessagesTimeline.test.tsx apps/web/src/markdown-clipboard.mermaid.test.ts apps/web/src/markdown-clipboard.test.ts: passed. Regressions cover crossing, inside, start/end-inside selections, source backticks, partial source-view copying, and exporting an image record only when its chip is selected, even when its link appears in a Mermaid comment.Dragging from a diagram label still does not start a text selection. Packaged Electron and native mobile were not exercised.
Before is left; after is right. The recording copies the first three blocks of an expanded user message, leaving its final instruction unselected.
mermaid-selection-copy-before-after.mp4
Note
🤖 Agent assistance: gpt-6.1-sol via Codex