Repository navigation
Description
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:
- Duplicate copying (both PowerShell and TUI copy to clipboard)
- Unwanted toast notifications that clutter the UI
- 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
onCopySelectioncallback 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
- Open PowerShell terminal
- Set environment variable:
$env:OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT=1 - Start OpenCode TUI:
opencode tui - Select any text in the terminal
- 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+Ccopies and dismisses selectionEscdismisses 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:
- Go to github.com/anomalyco/opencode/issues
- Click "New issue"
- Choose "Bug report" template
- Copy and paste the content above into the issue description
- Fill in any additional required fields
- 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
github-actions commentedon Apr 8, 2026
This issue doesn't fully meet our contributing guidelines.
What needs to be fixed:
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:
OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECTnot working correctly in Windows Terminal with copy-on-selectIf you believe this was flagged incorrectly, please let a maintainer know.
lee-b commentedon May 16, 2026
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 :/