Skip to content

Bug Report: TUI "Copied to clipboard" toast cannot be disabled #21542

Closed

Description

@1353604736

Description

Bug Report: TUI "Copied to clipboard" toast cannot be disabled

Summary

The OpenCode TUI shows a "Copied to clipboard" toast notification whenever text is selected in the terminal, even when the OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT environment variable is set. This creates a duplicate copy experience when using terminals like PowerShell that already have built-in copy-on-select functionality.

Environment

  • Operating System: Windows (PowerShell)
  • OpenCode Version: Latest
  • Terminal: PowerShell (with built-in copy-on-select)

Description

PowerShell and other modern terminals provide built-in copy-on-select functionality. When using OpenCode TUI, selecting text triggers an additional copy operation and displays a "Copied to clipboard" toast notification in the top-right corner. This results in:

  1. Duplicate copying (both PowerShell and TUI copy to clipboard)
  2. Unwanted toast notifications that clutter the UI
  3. Poor user experience for users who prefer terminal-native copy behavior

Expected Behavior

When OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT=1 is set, the TUI should:

  • Not perform any copy operations on text selection
  • Not display "Copied to clipboard" toast notifications
  • Allow the terminal's native copy-on-select behavior to work exclusively

Actual Behavior

The environment variable OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT=1 only partially works:

  • Keyboard and mouse event copy behavior is disabled
  • However, the onCopySelection callback still triggers and shows the toast notification

Root Cause Analysis

The issue is in packages/opencode/src/cli/cmd/tui/app.tsx at lines 336-344 1 :

renderer.console.onCopySelection = async (text: string) => {
  if (!text || text.length === 0) return

  await Clipboard.copy(text)
    .then(() => toast.show({ message: "Copied to clipboard", variant: "info" }))
    .catch(toast.error)

  renderer.clearSelection()
}

This callback doesn't check the OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT flag before executing, unlike other parts of the codebase that do check this flag 2 .

Steps to Reproduce

  1. Open PowerShell terminal
  2. Set environment variable: $env:OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT=1
  3. Start OpenCode TUI: opencode tui
  4. Select any text in the terminal
  5. Observe that "Copied to clipboard" toast still appears in top-right corner

Suggested Fix

Add environment variable check to the onCopySelection callback:

renderer.console.onCopySelection = async (text: string) => {
  if (!text || text.length === 0) return
  if (Flag.OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT) return // Add this line

  await Clipboard.copy(text)
    .then(() => toast.show({ message: "Copied to clipboard", variant: "info" }))
    .catch(toast.error)

  renderer.clearSelection()
}

Impact

This issue affects all users using terminals with built-in copy-on-select functionality (PowerShell, Windows Terminal, etc.) and creates a frustrating duplicate copy experience.

Additional Context

The environment variable OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT is intended to provide Windows Terminal-like behavior where:

  • Ctrl+C copies and dismisses selection
  • Esc dismisses selection
  • Other key input dismisses selection and is passed through

However, due to this bug, the toast notification still appears even when this mode is enabled.

Notes

  • This is a code-level issue that cannot be worked around through configuration
  • The fix is straightforward and involves adding one line to check the environment variable
  • Similar environment variable checks are already implemented elsewhere in the codebase

How to submit this issue:

  1. Go to github.com/anomalyco/opencode/issues
  2. Click "New issue"
  3. Choose "Bug report" template
  4. Copy and paste the content above into the issue description
  5. Fill in any additional required fields
  6. Submit the issue

Wiki pages you might want to explore:

Citations

Plugins

No response

OpenCode version

No response

Steps to reproduce

No response

Screenshot and/or share link

No response

Operating System

No response

Terminal

No response

Activity

  1. added
    opentuiThis relates to changes in v1.0, now that opencode uses opentui
    on Apr 8, 2026
  2. github-actions commented on Apr 8, 2026

    @github-actions
    Contributor

    This issue doesn't fully meet our contributing guidelines.

    What needs to be fixed:

    • The required template fields (OpenCode version, Steps to reproduce, Operating System, Terminal) are all left as "No response" — please fill these in with real values
    • The issue body contains AI-generated instructions ("How to submit this issue", wiki references) that should be removed before submitting
    • The description is AI-generated with an overly verbose, structured format; please replace it with a concise, human-written description of the actual problem

    Please edit this issue to address the above within 2 hours, or it will be automatically closed.


    This issue might be a duplicate of existing issues. Please check:

    If you believe this was flagged incorrectly, please let a maintainer know.

  3. lee-b commented on May 16, 2026

    @lee-b

    It's not duplicating on Linux; it's disabling. The copy to clipboard doesn't actually occur, but the terminal selection is cleared, so no copying is then possible :/

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingneeds:complianceThis means the issue will auto-close after 2 hours.opentuiThis relates to changes in v1.0, now that opencode uses opentuiwindows

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions