Skip to content

Text selection stops working after copy-on-select triggers #14420

@EliasHanken

Description

@EliasHanken

Description

After selecting text by click-dragging (copy-on-select mode on Linux/macOS), the text is copied and the toast notification shows correctly. However, immediately trying to select more text often fails -- the selection doesn't start. You have to wait a bit before text selection works again.

The root cause is in Selection.copy() (selection.ts): it calls renderer.clearSelection() synchronously inside the onMouseUp handler, which runs during @opentui's processMouseEvent event bubbling -- before finishSelection() gets to execute. This nullifies currentSelection before the renderer can properly complete its selection lifecycle (setting isDragging=false, emitting the selection event), leaving stale internal state that blocks subsequent selections.

Plugins

None

OpenCode version

latest (dev)

Steps to reproduce

  1. Open OpenCode TUI on Linux or macOS (copy-on-select is enabled by default)
  2. Click-drag to select some text -- it copies and shows "Copied to clipboard" toast
  3. Immediately try to click-drag to select more text
  4. The selection often doesn't start on the first attempt
  5. Wait a moment, then try again -- it works

Operating System

Linux

Terminal

Various (not terminal-specific)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions