Copy failures are silently swallowed — TUI shows "Copied to clipboard" even when nothing is copied
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 75/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- typescript
Hướng nghiên cứu
Đọc packages/tui/src/clipboard.ts và packages/tui/src/util/selection.ts, sau đó xem các bài kiểm thử clipboard trong packages/tui/test/clipboard.test.ts. Theo dõi cách lỗi ghi được truyền đến trình xử lý lựa chọn và cách xử lý các hàm trợ giúp clipboard không khả dụng. Hoàn thành khi thao tác ghi thất bại không còn kích hoạt thông báo thành công và có bài kiểm thử bao quát hành vi khi xảy ra lỗi.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Title: Copy failures are silently swallowed — TUI shows "Copied to clipboard" even when nothing is copied
Summary
Every clipboard write path in the TUI swallows its error, so write() always resolves. The selection handler shows the success toast on .then(), meaning the "Copied to clipboard" message appears on every copy attempt, including ones where the text never reached the clipboard.
Steps to reproduce
- On Linux, have no clipboard helper binary installed (no
wl-copy,xclip, orxsel). - Launch the TUI, select any text, press
ctrl+c(or use the copy action). - Observe: the "Copied to clipboard" toast appears.
- Paste elsewhere: the clipboard is unchanged.
Confirmed on a Wayland session with opencode 1.18.34.
Root cause
In packages/tui/src/clipboard.ts, every branch discards its failure:
// line 106 — osascript
await command("osascript", ["-e", `set the clipboard to "${escaped}"`]).catch(() => undefined)
// line 111 — native helper (wl-copy / xclip / xsel / powershell)
await command(native[0], native.slice(1), text).catch(() => undefined)
// line 116 — clipboardy fallback
await clipboardy.write(text).catch(() => undefined)
write() therefore never rejects, and the consumer in packages/tui/src/util/selection.ts treats a resolved promise as proof of success:
clipboard
?.write?.(clipboardText)
.then(() => toast.show({ message: "Copied to clipboard", variant: "info" }))
.catch(toast.error)
The .catch(toast.error) on the last line is unreachable for copy failures — that is the bug.
Note that on Linux clipboardy itself shells out to xsel/xclip, so the fallback does not rescue this case: it fails the same way, and is swallowed the same way.
Why it is confusing
The toast is a false signal. It reports intent rather than outcome, so there is no way to tell from the UI whether a copy succeeded. In my case the underlying cause was simply a missing wl-clipboard package, which took a while to track down precisely because the UI insisted the copy had worked.
Suggested fix
Two parts, both small:
- Propagate errors. Let
getCopyMethod()'s helpers reject instead of.catch(() => undefined), sowrite()rejects and the existing.catch(toast.error)inselection.ts:40fires and shows a real error. - Warn once when no clipboard mechanism exists.
copyCommand()already returnsundefinedin this situation (packages/tui/test/clipboard.test.ts:17covers exactly that case). Surfacing that at startup — or at least falling back to the OSC 52 sequence with an explicit note — would have made this self-diagnosing.
Additional consideration
writeOsc52() at the top of write() writes the escape sequence to stdout without any verification that the terminal honoured it. Many terminals do not implement OSC 52 set-clipboard, or gate it behind an allowlist. If OSC 52 is the only mechanism available, the success toast is still inaccurate.
Environment
- opencode 1.18.34
- Linux, Wayland session
- No
wl-copy,xclip, orxselinstalled
- Ngôn ngữ chính
- TypeScript
- Star
- 213k
- Fork
- 28.4k
- Merge trung bình
- 8 giờ 58 phút
- Pull request đã merge (30 ngày)
- 251
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của anomalyco/opencode
-
reproduced
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
anomalyco/opencode#56038 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
anomalyco/opencode#56002 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
app: keybinds match the produced character, so Ctrl+F and other letter shortcuts fail on non-Latin layoutsCó thể đã có người làm @ZXLyyds100 đã nhận 1 ngày trước. Đang mởreproduced
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
anomalyco/opencode#55676 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
tui: NumPad End/Home ignored under kitty keyboard protocol (Windows Terminal reports KP_END 57424)Có thể đã có người làm @argszero đã nhận 1 ngày trước. Đang mởreproduced
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
anomalyco/opencode#55533 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
anomalyco/opencode#55383 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của anomalyco/opencode
Issue tương tự
-
`cf complete zsh >> .zshrc` fails on vanilla zshCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
cloudflare/cf#340 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
Rename Madson cameraĐang mở
Độ khó 2/5 Dưới một giờ Mức phù hợp với người mới 75/100
StoDevX/AAO-React-Native#8785 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Broken links in the docsĐang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 75/100
-
bnv-manager-v2: accept_invite creates the Mailcow domain admin before the commitCó thể đã có người làm @myOmikron đã nhận hôm nay. Đang mởbug ready-for-agent
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100