Add copy button to copy the full assistant message in Studio Code - #4113
Merged
Conversation
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Collaborator
📊 Performance Test ResultsComparing e0be115 vs trunk app-size
site-editor
site-startup
Results are median values from multiple test runs. Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff) |
| .userEditSendButton:hover { | ||
| background-color: var(--color-frame-theme-hover); | ||
| align-items: center; | ||
| /* Cancel the icon-centering inset of the 1.75rem button so the 16px icon |
Contributor
There was a problem hiding this comment.
I am not sure this comment is needed, but it can be kept if you find it useful
| role: 'assistant', | ||
| content: [ { type: 'text', text } ], | ||
| }, | ||
| } as unknown as SessionEntry; |
Contributor
There was a problem hiding this comment.
I think we can avoid using as unknown as in tests by doing something like:
index.test.tsx
index faace818e..01674c1ed 100644
--- a/apps/studio/src/components/studio-code-session/conversation/index.test.tsx
+++ b/apps/studio/src/components/studio-code-session/conversation/index.test.tsx
@@ -25,15 +25,17 @@ vi.mock( '@wordpress/ui', () => ( {
Icon: () => null,
} ) );
-function customEntry( customType: string, data: unknown ): SessionEntry {
+function mockEntry( partial: Record< string, unknown > ): SessionEntry {
return {
- type: 'custom',
id: Math.random().toString( 36 ).slice( 2 ),
parentId: null,
timestamp: '2026-06-19T00:00:00.000Z',
- customType,
- data,
- } as unknown as SessionEntry;
+ ...partial,
+ } as SessionEntry;
+}
+
+function customEntry( customType: string, data: unknown ): SessionEntry {
+ return mockEntry( { type: 'custom', customType, data } );
}
function question( q: string, options: string[] ): SessionEntry {
@@ -48,11 +50,9 @@ function answer( text: string ): SessionEntry {
}
function assistantToolCallEntry( name: string ): SessionEntry {
- return {
+ return mockEntry( {
type: 'message',
id: `assistant-${ name }`,
- parentId: null,
- timestamp: '2026-06-19T00:00:00.000Z',
message: {
role: 'assistant',
content: [
@@ -64,21 +64,20 @@ function assistantToolCallEntry( name: string ): SessionEntry {
},
],
},
- } as unknown as SessionEntry;
+ } );
}
function toolResultEntry( text: string ): SessionEntry {
- return {
+ return mockEntry( {
type: 'message',
id: 'tool-result',
- parentId: null,
timestamp: '2026-06-19T00:00:01.000Z',
message: {
role: 'toolResult',
toolCallId: 'tool-call-1',
content: [ { type: 'text', text } ],
},
- } as unknown as SessionEntry;
+ } );
}
describe( 'entriesToRenderItems – persisted picked answers', () => {
@@ -279,24 +278,20 @@ describe( 'Conversation – assistant message copy button', () => {
} );
function assistantTextEntry( text: string ): SessionEntry {
- return {
+ return mockEntry( {
type: 'message',
id: `assistant-text-${ text }`,
- parentId: null,
- timestamp: '2026-06-19T00:00:00.000Z',
message: {
role: 'assistant',
content: [ { type: 'text', text } ],
},
- } as unknown as SessionEntry;
+ } );
}
function assistantMultiBlockEntry(): SessionEntry {
- return {
+ return mockEntry( {
type: 'message',
id: 'assistant-multi-block',
- parentId: null,
- timestamp: '2026-06-19T00:00:00.000Z',
message: {
role: 'assistant',
katinthehatsite
left a comment
Contributor
There was a problem hiding this comment.
In terms of the functionality, I think it works well. I left some comments regarding code improvements
…e-button # Conflicts: # apps/studio/src/components/studio-code-session/conversation/index.test.tsx # apps/studio/src/components/studio-code-session/conversation/style.module.css
shaunandrews
added a commit
that referenced
this pull request
Jul 10, 2026
Reconciles the July 6–10 trunk sync: adopts trunk's productionized screenshot/theme tooling (#3982/#4097), grafts the copy-button (#4113), edit-message (#4094), and inline chat artifacts into the redesigned conversation views, keeps the merged Connector surface over trunk's menu-action wiring (#4085), and keeps the blueprint-selector deletion.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Related issues
How AI was used in this PR
Proposed Changes
Testing Instructions
copy-message.mp4
Pre-merge Checklist