Copy failures are silently swallowed — TUI shows "Copied to clipboard" even when nothing is copied
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 75/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- typescript
Direzione di ricerca
Leggi packages/tui/src/clipboard.ts e packages/tui/src/util/selection.ts, poi esamina i test degli appunti in packages/tui/test/clipboard.test.ts. Segui il percorso degli errori di scrittura fino al gestore della selezione e verifica come vengono gestite le funzioni di supporto degli appunti non disponibili. Il lavoro è completo quando le scritture non riuscite non attivano più una notifica di successo e i test coprono il comportamento in caso di errore.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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
- Lingua principale
- TypeScript
- Stelle
- 213k
- Fork
- 28.4k
- Merge medio
- 7h 22m
- PR unite (30g)
- 276
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di anomalyco/opencode
-
pending close triaging
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
anomalyco/opencode#55070 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
opencode on clean macos zsh .export path not working because it append and it fails because no ~/.zshrc fileForse già presa Una pull request collegata a questa issue è aperta o già unita. Apertareproduced
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
anomalyco/opencode#55068 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
anomalyco/opencode#54919 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
triaging
Difficoltà 2/5 1-3 ore Idoneità per principianti 73/100
anomalyco/opencode#54887 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
reproduced
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
anomalyco/opencode#54871 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di anomalyco/opencode
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
NaturalIntelligence/fast-xml-parser#890 · 1 commento ·
I maintainer di solito rispondono entro 3 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
zsviczian/obsidian-excalidraw-plugin#3000 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
pnpm/get.pnpm.io#68 ·
-
[BUG] Cloudflare KV binding 模式下 kvDriver.list() 沿用 EdgeOne 语义,字段名不匹配导致 key 格式下初始化 500 并耗尽 list 配额Forse già presa @wumingzhinu l’ha presa oggi. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
OpenListTeam/OpenList-Worker#125 ·
I maintainer di solito rispondono entro 2 giorni
-
Android (vision-camera-location): HybridLocationManager never quits its HandlerThread on disposeAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
margelo/react-native-vision-camera#4217 ·
I maintainer di solito rispondono entro 4 giorni