Skip to content

fix(ui): reserve bubble space for code block copy (#69605) - #69689

Closed
ly85206559 wants to merge 1 commit into
openclaw:mainfrom
ly85206559:fix/control-ui-code-block-copy-69605
Closed

ly85206559 wants to merge 1 commit into
openclaw:mainfrom
ly85206559:fix/control-ui-code-block-copy-69605

Conversation

@ly85206559

Copy link
Copy Markdown
Contributor

Summary

  • Problem: In Control UI webchat, clicking Copy on a fenced code block pasted the entire assistant Markdown instead of only the snippet ([Bug]: Web UI copy button copies entire message instead of code block content #69605).
  • Why it matters: Floating “Copy as markdown” / expand controls overlap the code-block header when both appear; mis-clicks trigger the bubble-level copy handler.
  • What changed: Apply the existing .chat-bubble.has-copy class when assistant bubbles show copy/expand actions (ui/src/ui/chat/grouped-render.ts), reserving right padding per ui/src/styles/chat/grouped.css.
  • What did NOT change: Markdown rendering, handleCodeBlockCopy, or clipboard APIs.

Change Type

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

Root Cause

  • Root cause: has-copy CSS existed for bubble actions but was never applied in renderAssistantBubble, so .chat-bubble-actions could overlap fenced code-block Copy controls; users hit “Copy as markdown” instead.
  • Missing detection / guardrail: No structural spacing when actions render.
  • Contributing context: Hover/coarse-pointer (hover: none) keeps actions always interactive on some setups, increasing overlap risk.

Regression Test Plan

  • Coverage: Unit test
  • Target: ui/src/ui/chat/grouped-render.test.ts
  • Scenario: Assistant bubble with markdown actions gets has-copy; user bubbles do not.
  • Guardrail: Locks the layout contract between bubble actions and markdown chrome.

User-visible / Behavior Changes

  • Assistant messages with copy/expand actions gain right padding so code-block Copy no longer sits under floating buttons.

Diagram

Before:
[hover bubble] -> [actions + code header overlap] -> mis-click -> full Markdown copied

After:
[hover bubble] -> [has-copy padding shifts content] -> code Copy hit target -> snippet copied

Security Impact

  • New permissions/capabilities? No
  • Secrets/tokens handling changed? No
  • New/changed network calls? No
  • Command/tool execution surface changed? No
  • Data access scope changed? No

Repro + Verification

Environment

  • OS: Windows / Linux (issue reported on Ubuntu)
  • Control UI webchat with assistant reply containing fenced code at top of bubble

Steps

  1. Open Control UI chat; get an assistant reply with a fenced code block near the top.
  2. Hover the bubble so “Copy as markdown” appears.
  3. Click the code-block Copy control.

Expected

  • Clipboard contains only the code inside the fence.

Actual (before fix)

  • Clipboard often contained the full assistant message (Markdown).

Evidence

  • pnpm test ui/src/ui/chat/grouped-render.test.ts — pass
  • pnpm check:changed — pass

Human Verification

  • Verified scenarios: unit tests + layout contract (has-copy when actions present).
  • Edge cases: user bubble without actions (no has-copy).
  • Not verified: manual browser click on physical device (CI/agent only).

Compatibility / Migration

  • Backward compatible? Yes
  • Config/env changes? No
  • Migration needed? No

Risks and Mitigations

  • Risk: Slightly narrower assistant bubble text when actions show.
    • Mitigation: Matches existing CSS intent; padding only when actions exist.

Apply has-copy on assistant bubbles when copy/expand actions show, so
floating controls do not overlap fenced code-block copy. Fixes openclaw#69605.
@greptile-apps

greptile-apps Bot commented Apr 21, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Applies the existing .has-copy CSS class to assistant chat bubbles when copy/expand actions are present, preventing the floating .chat-bubble-actions controls from overlapping fenced code-block copy buttons. The fix is a one-line addition to the bubbleClasses array in renderGroupedMessage, backed by two new unit tests that lock the layout contract.

Confidence Score: 5/5

Safe to merge — minimal, well-scoped CSS class addition with new unit test coverage.

The change is a single-line addition that applies an already-defined CSS class. The condition is correctly scoped to assistant-only messages with markdown content (mirrors the exact predicate already used to decide whether to render the actions overlay). Two new tests verify both the positive and negative cases. No logic, data flow, or security surface was touched.

No files require special attention.

Reviews (1): Last reviewed commit: "fix(ui): reserve bubble space for code b..." | 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

@ly85206559 ly85206559 closed this Apr 21, 2026
@ly85206559
ly85206559 deleted the fix/control-ui-code-block-copy-69605 branch April 21, 2026 22:56
@clawsweeper clawsweeper Bot mentioned this pull request Apr 26, 2026
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