GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(ui): Add copy button for code blocks in mothership by TheodoreSpeaks · Pull Request #4033 · simstudioai/sim

Conversation

@TheodoreSpeaks

@TheodoreSpeaks TheodoreSpeaks commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Add copy button for any code blocks in mothership. Makes it easier to copy code blocks.

Type of Change

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

Testing

Tested locally with different code block types.

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

image

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

greptile-apps[bot] reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@TheodoreSpeaks
Add copy button for code blocks in mothership
e079c82
@vercel

vercel Bot commented Apr 8, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

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 Apr 8, 2026 3:25am

Request Review

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@TheodoreSpeaks

TheodoreSpeaks commented Apr 8, 2026

Copy link
Copy Markdown
Contributor Author

@BugBot review

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@cursor

cursor Bot commented Apr 8, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

PR Summary

Low Risk
Low risk UI-only change that adds client-side clipboard copying to rendered markdown code blocks; main risk is minor UX issues if navigator.clipboard is unavailable or denied.

Overview
Adds a reusable CopyCodeButton that copies code to the clipboard and shows a temporary success state.

Updates both chat markdown renderers (markdown-renderer.tsx and chat-content.tsx) to display this button in code block headers, and introduces a shared extractTextContent utility to reliably derive plain text from React node code content.

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

cursor[bot]
cursor Bot reviewed Apr 8, 2026
View reviewed changes

@cursor cursor Bot left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

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 and found 2 potential issues.

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 e079c82. Configure here.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread apps/sim/app/chat/components/message/components/markdown-renderer.tsx Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread apps/sim/app/chat/components/message/components/markdown-renderer.tsx Resolved

Uh oh!

There was an error while loading. Please reload this page.

@TheodoreSpeaks
Move to shared copy code button
0413d87
@vercel
vercel Bot temporarily deployed to Preview April 8, 2026 02:49 Inactive
@TheodoreSpeaks
Handle react node case for copy
c386595
@vercel
vercel Bot temporarily deployed to Preview April 8, 2026 02:57 Inactive
@TheodoreSpeaks
TheodoreSpeaks marked this pull request as ready for review April 8, 2026 03:01
@greptile-apps

greptile-apps Bot commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds a reusable CopyCodeButton component and wires it into both the public chat markdown renderer (markdown-renderer.tsx) and the workspace chat content renderer (chat-content.tsx), giving users a one-click way to copy fenced code blocks.

Key findings:

  • P1 — Unhandled clipboard Promise (copy-code-button.tsx): navigator.clipboard.writeText(code) is not awaited. setCopied(true) fires unconditionally, so the "✓ Copied" indicator appears even when the write fails (e.g. browser permissions denied, page not focused).
  • P2 — Invisible hover state (chat-content.tsx): The CopyCodeButton receives hover:bg-[var(--surface-4)], which is the same token used by its parent container, so the hover effect produces no visible change.
  • P2 — extractTextContent duplicated across two files: An identical helper is now defined independently in both markdown-renderer.tsx and chat-content.tsx. Per project guidelines, shared helpers needed by 2+ files should be extracted into a shared utils.ts.
  • P2 — setTimeout not cleaned up on unmount: The timer handle is discarded; clearing it in a useEffect cleanup would prevent the state update from firing after the component unmounts.

Confidence Score: 4/5

Safe to merge after fixing the unhandled clipboard Promise, which causes a misleading success indicator on write failure.

One P1 issue: the clipboard write is not awaited, so the copy-success UI fires regardless of whether the write actually succeeded. This is a real, reproducible behaviour defect on the primary user path of the feature. The remaining findings are P2 quality/style items that do not block correctness.

apps/sim/components/ui/copy-code-button.tsx — fix async clipboard handling before merging.

Vulnerabilities

No security concerns identified. The clipboard write uses the standard navigator.clipboard.writeText API with user-supplied code content that is already rendered on-screen. No injection vectors, credential exposure, or auth-boundary issues were found.

Important Files Changed

Filename Overview
apps/sim/components/ui/copy-code-button.tsx New shared copy-button component; clipboard write is not awaited causing the success indicator to fire even on failure, and the setTimeout is not cleaned up on unmount.
apps/sim/app/chat/components/message/components/markdown-renderer.tsx Adds CopyCodeButton to chat code blocks and introduces extractTextContent helper, which is now duplicated with the identical function in chat-content.tsx.
apps/sim/app/workspace/[workspaceId]/home/components/message-content/components/chat-content/chat-content.tsx Adds CopyCodeButton to workspace chat code blocks; hover background token matches container background, making hover feedback invisible.

Sequence Diagram

sequenceDiagram
    participant User
    participant CopyCodeButton
    participant Clipboard as navigator.clipboard
    participant Timer as setTimeout

    User->>CopyCodeButton: click
    CopyCodeButton->>Clipboard: writeText(code) [Promise, not awaited]
    CopyCodeButton->>CopyCodeButton: setCopied(true) [fires immediately, regardless of result]
    CopyCodeButton->>Timer: setTimeout(setCopied(false), 2000)
    Note over Clipboard: Write may succeed or fail silently
    Timer-->>CopyCodeButton: setCopied(false) after 2s
    Note over CopyCodeButton: If component unmounts before 2s,<br/>timer fires on unmounted component
Loading

Reviews (1): Last reviewed commit: "Handle react node case for copy" | Re-trigger Greptile

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

greptile-apps[bot]
greptile-apps Bot reviewed Apr 8, 2026
View reviewed changes
Comment thread apps/sim/components/ui/copy-code-button.tsx Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread ...space/[workspaceId]/home/components/message-content/components/chat-content/chat-content.tsx Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread apps/sim/app/chat/components/message/components/markdown-renderer.tsx Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread apps/sim/components/ui/copy-code-button.tsx Resolved

Uh oh!

There was an error while loading. Please reload this page.

@TheodoreSpeaks @claude
fix(copy-button): address PR review feedback
cf9de44
- Await clipboard write and clear timeout on unmount in CopyCodeButton
- Fix hover bg color matching container bg (surface-4 -> surface-5)
- Extract extractTextContent to shared util at lib/core/utils/react-node-text.ts

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@vercel
vercel Bot temporarily deployed to Preview April 8, 2026 03:22 Inactive
@TheodoreSpeaks
Fix lint
6ed3bcc
@vercel
vercel Bot temporarily deployed to Preview April 8, 2026 03:25 Inactive
@TheodoreSpeaks
TheodoreSpeaks merged commit 6f9f336 into staging Apr 8, 2026
12 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@TheodoreSpeaks
TheodoreSpeaks deleted the feat/copy-button branch April 8, 2026 03:33
@waleedlatif1 waleedlatif1 mentioned this pull request Apr 8, 2026
v0.6.30: slack trigger enhancements, secrets performance, polling refactors, drag resources in mothership #4038
Merged

This branch was previously deployed

1 inactive deployment
Preview — 6ed3bcc1 Deployed Apr 8, 2026 by vercel[bot]
View deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@greptile-apps greptile-apps[bot] greptile-apps[bot] left review comments
@cursor cursor[bot] cursor[bot] left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@TheodoreSpeaks
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.