Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(webview): show copy button in web clients #7310

Merged
merged 3 commits into from
Mar 4, 2025
Merged

Conversation

abeatrix
Copy link
Contributor

@abeatrix abeatrix commented Mar 4, 2025

CLOSE https://linear.app/sourcegraph/issue/CODY-5193/cody-web-copy-button-is-missing-for-code-blocks

This commit refactors the UI for code blocks in chat messages to improve the placement of action buttons (copy, apply, insert) and fixes the issue where copy button is not showing up on web.

The cause of the issue is due to the logic where actionsContainer will only be displayed when previewContainer is available, a regression from #7217.

The fix is to always append available actionsContainer, but also insert the previewContainer before that when available.

Key changes:

  • Modified CSS styles in ChatMessageContent.module.css to adjust padding, borders, and background colors for code blocks and buttons.
  • Updated ChatMessageContent.tsx to insert the preview container (containing file info) before the code block and the actions container after the code block.
  • Updated create-buttons.ts to use the default buttonsContainer style instead of buttonsContainerTransparent for both preview and action button containers.

Test plan

Run Cody Web and confirmed the copy button is now showing up:

image

Added storybook to cover this component:

image

This commit refactors the UI for code blocks in chat messages to improve the placement of action buttons (copy, apply, insert) and fixes the issue where copy button is not showing up on web.

The cause of the issue is due to the logic where actionsContainer will only be displayed when previewContainer is available, a regression from #7217.

The fix is to always append available actionsContainer, but also insert the previewContainer before that when available.

Key changes:

- Modified CSS styles in `ChatMessageContent.module.css` to adjust padding, borders, and background colors for code blocks and buttons.
- Updated `ChatMessageContent.tsx` to insert the preview container (containing file info) before the code block and the actions container after the code block.
- Updated `create-buttons.ts` to use the default `buttonsContainer` style instead of `buttonsContainerTransparent` for both preview and action button containers.

## Test Plan

Added storybook to cover this component
@abeatrix abeatrix requested review from julialeex and a team March 4, 2025 11:09
Copy link
Contributor

@julialeex julialeex left a comment

Choose a reason for hiding this comment

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

Thanks for fixing the regression!
Suggestions:

  1. When I was looking at the history messages there's an empty container rendered at the top. Can we remove that? Screenshot 2025-03-04 at 7 37 51 AM
  2. The original UI doesn't now have the line around the container, can we remove the border line?
Screenshot 2025-03-04 at 7 38 07 AM

This commit refactors the code block action button layout in chat messages to improve the visual appearance.

Key changes:

- Modified `create-buttons.ts` to use `previewContainer` and `actionsContainer` for better clarity and separation of concerns.
- Updated `ChatMessageContent.module.css` to remove the top border from the code block action buttons.
@abeatrix abeatrix requested a review from julialeex March 4, 2025 16:11
@abeatrix abeatrix enabled auto-merge (squash) March 4, 2025 16:11
@abeatrix abeatrix merged commit 0b00474 into main Mar 4, 2025
21 of 22 checks passed
@abeatrix abeatrix deleted the bee/fix-codeblock-web branch March 4, 2025 16:29
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.

2 participants