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
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
- 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+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:
- 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
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_SELECTenvironment variable is set. This creates a duplicate copy experience when using terminals like PowerShell that already have built-in copy-on-select functionality.Environment
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:
Expected Behavior
When
OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT=1is set, the TUI should:Actual Behavior
The environment variable
OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT=1only partially works:onCopySelectioncallback still triggers and shows the toast notificationRoot Cause Analysis
The issue is in
packages/opencode/src/cli/cmd/tui/app.tsxat lines 336-344 1 :This callback doesn't check the
OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECTflag before executing, unlike other parts of the codebase that do check this flag 2 .Steps to Reproduce
$env:OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT=1opencode tuiSuggested Fix
Add environment variable check to the
onCopySelectioncallback: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_SELECTis intended to provide Windows Terminal-like behavior where:Ctrl+Ccopies and dismisses selectionEscdismisses selectionHowever, due to this bug, the toast notification still appears even when this mode is enabled.
Notes
How to submit this 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