Skip to content

[FEATURE] Add copy button to code blocks in assistant messages (#363)#365

Merged
imDarshanGK merged 8 commits into
imDarshanGK:mainfrom
adikulkarni006:feature/copy-code-block
Jun 10, 2026
Merged

[FEATURE] Add copy button to code blocks in assistant messages (#363)#365
imDarshanGK merged 8 commits into
imDarshanGK:mainfrom
adikulkarni006:feature/copy-code-block

Conversation

@adikulkarni006

Copy link
Copy Markdown
Collaborator

Closes #363

Adds a copy button (📋) to every code block in assistant responses.

  • Button appears on hover.
  • Copies code to clipboard.
  • Shows "✓ Copied!" feedback.

Files changed:

  • frontend/src/components/CodeBlockWithCopy.jsx (new)
  • frontend/src/components/ChatWindow.jsx (parse + render)

Ready for review.

@adikulkarni006 adikulkarni006 requested a review from Copilot June 9, 2026 10:56
@vercel

vercel Bot commented Jun 9, 2026

Copy link
Copy Markdown

@adikulkarni006 is attempting to deploy a commit to the Darshan's projects Team on Vercel.

A member of the Team first needs to authorize it.

Copilot AI 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.

Pull request overview

This PR adds a UI affordance for copying fenced code blocks from assistant messages, by parsing assistant message content for triple-backtick code fences and rendering them with a dedicated “copy” control. It also introduces additional message-selection and per-message export functionality (plus a new backend export endpoint), which expands the PR scope beyond the linked feature request.

Changes:

  • Added CodeBlockWithCopy React component to render code blocks with a hover/focus copy button and “Copied!” feedback.
  • Updated ChatWindow to parse assistant messages for fenced code blocks and render those blocks via CodeBlockWithCopy.
  • Added new “export selected messages” UI and a new backend POST /api/export/messages route to export arbitrary message subsets.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 10 comments.

File Description
frontend/src/components/CodeBlockWithCopy.jsx New component for rendering a code block with a copy-to-clipboard button.
frontend/src/components/ChatWindow.jsx Adds parsing/rendering of code fences; adds message selection and export UI/requests.
backend/routes/export.py Adds a new /messages export endpoint to support exporting selected messages.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread backend/routes/export.py
Comment thread backend/routes/export.py
Comment thread backend/routes/export.py
Comment thread backend/routes/export.py
Comment thread frontend/src/components/ChatWindow.jsx
Comment thread frontend/src/components/ChatWindow.jsx Outdated
Comment thread frontend/src/components/ChatWindow.jsx
Comment thread frontend/src/components/ChatWindow.jsx
Comment thread frontend/src/components/ChatWindow.jsx
Comment thread frontend/src/components/CodeBlockWithCopy.jsx
@imDarshanGK

Copy link
Copy Markdown
Owner

@adikulkarni006 CI failing

@adikulkarni006

Copy link
Copy Markdown
Collaborator Author

i do right👀

@adikulkarni006

Copy link
Copy Markdown
Collaborator Author

@imDarshanGK All Copilot comments resolved. CI is green (Vercel failure is authorization – not a blocker). Please merge when ready. Thanks!

@adikulkarni006 adikulkarni006 added SSoC26 Part of Social Summer of Code 2026 python Hard Larger or more advanced changes and removed Hard Larger or more advanced changes labels Jun 9, 2026
@imDarshanGK imDarshanGK added Hard Larger or more advanced changes and removed Advanced labels Jun 9, 2026
imDarshanGK
imDarshanGK previously approved these changes Jun 9, 2026
@imDarshanGK

Copy link
Copy Markdown
Owner

@adikulkarni006 Resolve conflicts

@imDarshanGK imDarshanGK removed the python label Jun 9, 2026
@adikulkarni006

Copy link
Copy Markdown
Collaborator Author

@imDarshanGK All conflicts resolved, CI is green (Vercel is just authorization). Please review and approve again so we can merge. Thanks!

@imDarshanGK

Copy link
Copy Markdown
Owner

@adikulkarni006 resolve conflicts

@imDarshanGK imDarshanGK merged commit fd64be9 into imDarshanGK:main Jun 10, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Hard Larger or more advanced changes SSoC26 Part of Social Summer of Code 2026

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Add "Copy code block" button to code snippets in assistant responses

3 participants