Skip to content

[bug] Copy message button does not work on web interface #27992

@SpiritChen51

Description

@SpiritChen51

Description

On the web interface, clicking the "Copy" button on a message does not copy the content to the clipboard. This happens because navigator.clipboard.writeText() can fail in non-secure contexts (non-HTTPS) or when the clipboard API is blocked by browser permissions.

Steps to reproduce

  1. Open the OpenCode web interface
  2. Click the copy button on any message
  3. The button does not copy the content and no feedback is shown

Fix

Added a fallback using the traditional document.execCommand("copy") method via a temporary textarea element, which works even when the Clipboard API is unavailable. Also added a check to only update the "copied" state if the copy actually succeeded.

Operating System

All platforms

Terminal/Environment

Web browser

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions