Skip to content

fix(chat): preserve markdown when copying messages - #6903

Open
j15z wants to merge 1 commit into
stagingfrom
fix/chat-code-not-copied-inline
Open

fix(chat): preserve markdown when copying messages#6903
j15z wants to merge 1 commit into
stagingfrom
fix/chat-code-not-copied-inline

Conversation

@j15z

@j15z j15z commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

Summary

Copy message now copies the complete top-level orchestrator response as Markdown, including fenced code blocks and language labels. Thinking, tool calls, subagent output, and other internal structured content remain excluded.

This is the first PR in a two-part stack. #6956 adds portable workspace-resource links on top of this Markdown copy behavior.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • Other: ___________

Testing

  • 43 focused message-content and copyable-Markdown tests passed
  • apps/sim type-check passed
  • Scoped Biome checks passed

Reviewers should verify that a response with prose before and after a fenced code block pastes as the same Markdown, while thinking/tool/subagent content does not appear.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

Screenshots/Videos

Not applicable. The visible UI is unchanged; the clipboard payload is covered by focused tests.

Post-Deploy Monitoring & Validation

  • Logs/metrics: no new production logs or metrics are emitted by this client-only copy path.
  • Healthy signal: copied responses retain Markdown/code fences and contain only top-level orchestrator text.
  • Failure signal: missing visible prose/code or copied thinking, tool, or subagent content. Revert this PR if reproduced.
  • Validation window/owner: spot-check during the first 24 hours after deploy; PR author.

@vercel

vercel Bot commented Aug 20, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Aug 22, 2026 12:45am

Request Review

@cursor

cursor Bot commented Aug 20, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Clipboard UX only: no auth, persistence, or security-sensitive paths. Worst case is incomplete or overly stripped copied text.

Overview
Copying a chat reply now pastes Markdown (headings, emphasis, fenced code with language) instead of a flattened plain-text dump.

Copy is limited to top-level orchestrator text via getOrchestratorMessageText, so subagent/tool UI is omitted. Internal tags (credential, question, etc.) are stripped with the same display parsers, while literal tag-shaped text in code stays intact.

MessageActions uses useCopyToClipboard and optional getCopyContent / prepareContentForCopy hooks so mothership chat can supply that pipeline.

Reviewed by Cursor Bugbot for commit 8696252. Bugbot is set up for automated code reviews on this repo. Configure here.

@greptile-apps

greptile-apps Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR preserves Markdown when copying assistant messages and serializes visible workspace resources as portable sim: links.

  • Derives copied text from the same renderable message content used by chat rendering.
  • Refreshes workspace-file metadata when needed while retaining an immediate encoded fallback.
  • Adds a shared identifier codec and deferred clipboard support with focused regression coverage.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/home/components/mothership-chat/copyable-markdown.ts Serializes renderable chat content and workspace resources into copyable Markdown, including refreshed canonical file IDs and encoded fallback references.
packages/emcn/src/hooks/use-copy-to-clipboard.ts Adds promise-backed clipboard writes while preserving an immediate writeText fallback for browsers without the required ClipboardItem APIs.
apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/rich-markdown-editor/mention/sim-link.ts Centralizes escaping and safe URI encoding/decoding for portable mention links.
apps/sim/app/workspace/[workspaceId]/home/components/mothership-chat/mothership-chat.tsx Connects assistant-message copying to visible content extraction, workspace-file resolution, and the new Markdown serializer.

Reviews (12): Last reviewed commit: "Merge remote-tracking branch 'origin/sta..." | Re-trigger Greptile

@j15z

j15z commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator Author

@greptile

@j15z

j15z commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator Author

@cursor review

@j15z

j15z commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator Author

@greptile

@j15z

j15z commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit e066200. Configure here.

@j15z
j15z force-pushed the fix/chat-code-not-copied-inline branch from e066200 to d409b0d Compare August 20, 2026 22:58
@j15z

j15z commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator Author

@cursor review

@j15z

j15z commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator Author

@greptile

@j15z

j15z commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator Author

@greptile

@j15z

j15z commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator Author

@cursor review

@j15z

j15z commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator Author

@greptile

@j15z

j15z commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 78219f8. Configure here.

@j15z

j15z commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator Author

@greptile

@j15z

j15z commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator Author

@cursor review

@j15z

j15z commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator Author

@greptile review

@j15z

j15z commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 0ee0b5c. Configure here.

@j15z

j15z commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator Author

@greptile review

@j15z

j15z commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 851e2f0. Configure here.

@j15z

j15z commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator Author

@greptile review

@j15z

j15z commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 941f44d. Configure here.

@j15z

j15z commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator Author

@cursor review

@j15z

j15z commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator Author

@greptile review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit e0b6404. Configure here.

@j15z
j15z force-pushed the fix/chat-code-not-copied-inline branch from 94d32d9 to 8696252 Compare August 22, 2026 00:44

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 8696252. Configure here.

<MessageActions
content={message.content}
getCopyContent={getCopyContent}
hasCopyContent={Boolean(getOrchestratorMessageText(blocks, message.content).trim())}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy button ignores prepared content

Medium Severity

hasCopyContent is derived from raw orchestrator text before toCopyableMarkdown, while the click path bails out when the prepared markdown is empty. The Copy control can therefore appear for content that only yields stripable tags or unresolved non-text segments, and a click writes nothing with no feedback.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 8696252. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant