GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(tui): surface clipboard write failures instead of false success by K0nigsberg · Pull Request #51674 · anomalyco/opencode

Conversation

@K0nigsberg

@K0nigsberg K0nigsberg commented Sep 27, 2026

Copy link
Copy Markdown

Issue for this PR

Fixes #51658

Type of change

  • Bug fix

What does this PR do?

clipboard.write() swallowed every backend failure (.catch(() => undefined)), so it always resolved and the TUI reported "Copied to clipboard" even when nothing reached the clipboard — e.g. X11 without xclip/xsel installed, or terminals that ignore OSC 52 (GNOME Terminal/VTE).

Now a native-command failure falls back to clipboardy, and if that also fails write() rejects with an actionable message (install xclip or xsel (X11) or wl-clipboard (Wayland)). A bounded timeout (3s) additionally guards against clipboardy backends that neither complete nor error — the bundled xsel fallback hangs indefinitely with no display to connect to, so a plain .catch() cannot surface that as a failure. Callers already route rejections to the error toast, so the user sees the real outcome instead of a false success (or a hanging toast).

This fixes the false-success notification described in #51658 and also seen in #50208 (SSH+tmux). It does not add local-client clipboard forwarding over SSH/tmux — when only OSC 52 could reach the local machine, the user now gets an honest error instead of a lying success message.

Caller changes

  • dialog-message.tsx ("Copy"): await clipboard.write?.(text).catch(toast.error) — failures route to the existing error toast.
  • error-component.tsx ("Copy report"): the .then now passes a rejection handler that clears the copied flag instead of only ever setting it true.

ui/dialog.tsx (copySelection) and routes/session/index.tsx ("Copy last assistant message" / "Copy session transcript") already handled rejections correctly, so they needed no change.

How did you verify your code works?

Added a regression test in packages/tui/test/clipboard.test.ts: it spawns the real module with PATH/DISPLAY/WAYLAND_DISPLAY cleared and asserts write() rejects with the failure message. The test reads the subprocess's first stdout line on a bounded timer and kills the process, because clipboardy's bundled xsel fallback leaves a dangling child that keeps the subprocess alive long after write() has rejected.

  • cd packages/tui && bun test --timeout 30000 test/clipboard.test.ts — 5/5 pass (regression test completes in ~3.4s)
  • cd packages/tui && bun typecheck — clean (no errors in changed files; the lone core/src/open.ts "Cannot find module 'open'" error pre-exists on origin/dev and is unrelated to this change)

Screenshots / recordings

Not a visual change beyond which toast text appears on failure; the rejection flows through the existing error toast.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this commit

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
yida @factory-droid
fix(tui): surface clipboard write failures instead of false success
43280d1
`clipboard.write()` swallowed every backend failure with `.catch(() => undefined)`, so it always resolved and callers showed "Copied to clipboard" even when nothing reached the clipboard — e.g. X11 without xclip/xsel, or terminals that ignore OSC 52 (GNOME Terminal/VTE).

Now a native-command failure falls back to clipboardy, and if that also fails `write()` rejects with an actionable message. A bounded timeout (3s) also guards against clipboardy backends that neither complete nor error (the bundled xsel fallback hangs with no display), so the caller always sees the real outcome instead of a hanging toast.

Callers updated to route rejections to the existing error toast or a failure state:
- dialog-message "Copy": .catch(toast.error)
- error-component "Copy report": failure clears the copied flag

Fixes anomalyco#51658

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
@github-actions

github-actions Bot commented Sep 27, 2026

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@simonklee simonklee closed this Sep 27, 2026
@kvnloo kvnloo mentioned this pull request Sep 28, 2026
tip: surface clipboard write failures (#51657) kvnloo/opencode#122
Open
@K0nigsberg

K0nigsberg commented Sep 29, 2026

Copy link
Copy Markdown
Author

Hi, @simonklee

I dug a little into the previous clipboard-related PRs (#41924, #7028, #8974), and it looks like there has been some ongoing work around clipboard failures, OSC 52, SSH/tmux, and the xclip/xsel/wl-copy approach.

I also noticed the discussion around moving away from those external clipboard commands toward linking directly against the Wayland/X libraries. So I’m wondering if the direction of the codebase has changed in that area, and whether that might be part of the reason this PR was closed.

That’s just my current reading of the history though, so I may be missing some context. If that is roughly the direction you’re taking, I’d be happy to follow along and contribute to that approach instead. Is there anything in particular that would be useful to pick up?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@opencode-agent opencode-agent Bot mentioned this pull request Oct 8, 2026
Spec: truthful clipboard copy (fix #4283) + durable workspace storage #53926
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

tui: "Copied to clipboard" reported even when no backend copied

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@K0nigsberg @simonklee
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.