Skip to content

[FEATURE]: Copy Button doesn't work in HTTP - Use document.execCommand("copy") as fallback #14803

@Hashory

Description

@Hashory

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Image

Currently, the Copy button does not work in http environments because the navigator.clipboard API requires a secure context (https or localhost).

Many opencode users likely run the application in self-hosted http contexts, so this limits usability.

Although document.execCommand("copy") is deprecated, it is still supported by many browsers and works in http enviroments.
I propose implementing execCommand as a fallback when navigator.clipboard is unavalible.

Sample Code

const content = "copy content";

// Check if clipboard API is available
if (navigator.clipboard && navigator.clipboard.writeText) {
  navigator.clipboard.writeText(content);
} else {
  // Fallback for HTTP / older browsers
  const textarea = document.createElement("textarea");
  textarea.value = content;
  document.body.appendChild(textarea);
  textarea.select();
  document.execCommand("copy");
  document.body.removeChild(textarea);
}

Metadata

Metadata

Assignees

Labels

discussionUsed for feature requests, proposals, ideas, etc. Open discussionwebRelates to opencode on web / desktop

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