Skip to content

fix(ui): code block copy button overlaps message-level copy action (#69605) - #69634

Closed
longle325 wants to merge 3 commits into
openclaw:mainfrom
longle325:fix/issue-69605
Closed

longle325 wants to merge 3 commits into
openclaw:mainfrom
longle325:fix/issue-69605

Conversation

@longle325

@longle325 longle325 commented Apr 21, 2026 •

Copy link
Copy Markdown

Summary

Fixes #69605

In the Control UI webchat, clicking the copy button on a code block copies the entire assistant message instead of just the code block content.

Root Cause

The .chat-bubble-actions (containing the "Copy as markdown" button) is positioned absolutely at top: 6px; right: 8px of .chat-bubble. The CSS rule .chat-bubble.has-copy { padding-right: 70px; } was designed to create space for these actions, but the has-copy class was never applied to the .chat-bubble element.

Without this padding, the code block header (with its own "Copy" button) extends to the right edge of the bubble, directly under the .chat-bubble-actions. When the user clicks what appears to be the code block copy button in the overlapping area, the click hits the message-level "Copy as markdown" button instead, copying the entire message.

Changes

  • Apply the existing has-copy class to .chat-bubble when canCopyMarkdown or canExpand is true, activating the padding-right: 70px rule and preventing the overlap between code block content and the floating action bar

Testing

  • pnpm test ui/src/ui/chat/ passes (165 tests across 14 files)
  • pnpm test ui/src/ui/markdown.test.ts passes (63 tests)
  • pnpm tsgo:prod (typecheck) passes
  • pnpm lint:core passes (0 errors)

AI Disclosure

This pull request was created with AI assistance using OpenCode. The code was reviewed and verified by a human contributor before submission. Every line of the change has been understood and can be explained by the contributor.

…ap (openclaw#69605)

The .chat-bubble-actions (containing 'Copy as markdown' button) is
positioned absolutely at the top-right of the chat bubble. The CSS rule
.chat-bubble.has-copy adds padding-right: 70px to prevent content from
overlapping the action bar, but the has-copy class was never applied to
the chat bubble element.

Without this padding, the code block header (with its own 'Copy'
button) extends to the right edge of the bubble, directly under the
absolutely-positioned .chat-bubble-actions. When the user clicks what
looks like the code block copy button in the overlapping area, the
click hits the message-level 'Copy as markdown' button instead, copying
the entire message rather than just the code block content.

Apply the existing has-copy class when canCopyMarkdown or canExpand is
true, activating the padding-right rule and preventing the overlap.

Co-authored-by: AI Assistant <[email protected]>
@longle325
longle325 marked this pull request as ready for review April 21, 2026 09:03
@greptile-apps

greptile-apps Bot commented Apr 21, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a click-target overlap bug where the code block's "Copy" button was being obscured by the message-level "Copy as markdown" floating action bar. The single-line fix applies the pre-existing has-copy class to .chat-bubble under exactly the same condition (canCopyMarkdown || canExpand) that the floating action bar is rendered, activating the already-written padding-right: 70px CSS rule and eliminating the overlap.

Confidence Score: 5/5

Safe to merge — one-line targeted fix with correct logic and passing tests.

The change is minimal and directly closes the described gap. The condition mirrors the existing render condition for the floating action bar, so the class is applied precisely when needed. No regressions are expected; all tests pass.

No files require special attention.

Reviews (1): Last reviewed commit: "fix(ui): apply has-copy class to prevent..." | Re-trigger Greptile

@prtags

prtags Bot commented Apr 21, 2026 •

Copy link
Copy Markdown

Related work from PRtags group major-octopus-wnlz

Title: Open PR duplicate: code block copy overlap in Control UI

Number Title
#69634* fix(ui): code block copy button overlaps message-level copy action (#69605)
#69635 fix(ui): preserve raw code text in code-block copy button
#69689 fix(ui): reserve bubble space for code block copy (#69605)

* This PR

This was referenced Apr 26, 2026
@clawsweeper

clawsweeper Bot commented Apr 28, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for the context here. I did a careful shell check against current main, and this is already implemented.

This PR can close because its unique layout fix is already present on current main with focused coverage; the broader linked clipboard issue can continue through its separate open follow-up.

So I’m closing this as already implemented rather than keeping a duplicate issue open.

Review details

Best possible solution:

Keep the current-main layout implementation and let the remaining code-block clipboard-text behavior continue through the canonical linked issue and follow-up PR.

Do we have a high-confidence way to reproduce the issue?

No current-main failing reproduction remains from source inspection: the former missing has-copy condition is now active and covered by grouped chat tests. I did not run a live browser session in this read-only review.

Is this the best way to solve the issue?

Yes. The current-main solution uses the existing .chat-bubble.has-copy CSS contract under the same condition that renders .chat-bubble-actions, which is the narrowest maintainable fix for this PR's overlap scope.

Security review:

Security review cleared: The PR diff only changes a Control UI class-list expression and introduces no dependency, workflow, permission, secret, package, or code-execution surface.

What I checked:

  • Current main applies the spacing class: renderGroupedMessage now computes hasActions = canCopyMarkdown || canExpand and includes hasActions ? "has-copy" : "" in the chat bubble class list. (ui/src/ui/chat/grouped-render.ts:1448, 58bfefbad3e3)
  • CSS layout contract exists on main: .chat-bubble.has-copy reserves padding-right: 70px, while .chat-bubble-actions is absolutely positioned at the top right of the bubble. (ui/src/styles/chat/grouped.css:241, 58bfefbad3e3)
  • Focused current-main coverage: The grouped renderer test now asserts assistant bubbles with message actions get has-copy and user bubbles do not. (ui/src/ui/chat/grouped-render.test.ts:484, 58bfefbad3e3)
  • PR diff is now redundant: The live PR diff only adds the same has-copy class under the message-action condition, which current main already contains. (ui/src/ui/chat/grouped-render.ts:1211, b0a3945c92bd)
  • Git-history provenance: git blame and git log -S identify d00e9eba65dd3bba39023117ebfee1746159b8cb as the current-main proof commit for the implemented has-copy line in the checked-out history. (ui/src/ui/chat/grouped-render.ts:1448, d00e9eba65dd)
  • Current-main-only release provenance: git tag --contains d00e9eba65dd3bba39023117ebfee1746159b8cb returned no containing release tag, and the latest GitHub release is v2026.5.7 published on 2026-05-07, before the proof commit timestamp. (d00e9eba65dd)

Likely related people:

  • Peter Steinberger: The checked-out history blames the implemented has-copy class line and related chat files to the current-main proof commit authored by Peter Steinberger. (role: current-main proof commit author; confidence: high; commits: d00e9eba65dd; files: ui/src/ui/chat/grouped-render.ts, ui/src/styles/chat/grouped.css, ui/src/ui/chat/grouped-render.test.ts)
  • jjjojoj: Local commit history ties jjjojoj to the .chat-bubble.has-copy padding rule and the later 70px adjustment that this PR relies on. (role: introduced related layout guard behavior; confidence: high; commits: a55d45de3cd5, c1c1c0f35143; files: ui/src/styles/chat/grouped.css)
  • Val Alexander: Recent history shows substantive nearby work in the affected grouped renderer and Control UI chat surface. (role: recent Control UI/chat contributor; confidence: medium; commits: 1cf68b9243aa, 388270ffce55; files: ui/src/ui/chat/grouped-render.ts, ui/src/styles/chat/grouped.css, ui/src/ui/views/chat.ts)

Codex review notes: model gpt-5.5, reasoning high; reviewed against 58bfefbad3e3; fix evidence: commit d00e9eba65dd, main fix timestamp 2026-05-13T14:45:34+01:00.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Web UI copy button copies entire message instead of code block content

1 participant