Skip to content

fix(opencode): report clipboard copy failures#27861

Open
2409324124 wants to merge 1 commit into
anomalyco:devfrom
2409324124:codex/fix-clipboard-copy-failure
Open

fix(opencode): report clipboard copy failures#27861
2409324124 wants to merge 1 commit into
anomalyco:devfrom
2409324124:codex/fix-clipboard-copy-failure

Conversation

@2409324124
Copy link
Copy Markdown

@2409324124 2409324124 commented May 16, 2026

Issue for this PR

Closes #4283

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Clipboard copy operations in the TUI could report success even when the selected backend failed. That made mouse selection copy show Copied to clipboard while the clipboard was unchanged.

This changes clipboard writes so backend failures propagate instead of being swallowed:

  • native stdin-based clipboard commands now require a successful exit code
  • osascript write failures now reject
  • clipboardy.write() failures now reject

The existing toast/error handlers can then show the real clipboard failure instead of a false success message.

How did you verify your code works?

  • Added a regression test for a failing native clipboard command.
  • Ran bun test --timeout 30000 test/cli/cmd/tui/clipboard.test.ts.
  • Ran bun run typecheck from packages/opencode.
  • Ran the pre-push hook, which completed bun turbo typecheck.
  • Manually verified on Ubuntu 24.04, Linux 6.17.0-23-generic, X11 (DISPLAY=:1, no WAYLAND_DISPLAY). With xclip, xsel, and wl-copy absent and DISPLAY= set, the patched TUI surfaces the Linux clipboard backend error instead of showing Copied to clipboard.
  • Manually verified normal copy succeeds when a clipboard backend is available.

Screenshots / recordings

N/A. This is a terminal clipboard error-handling change; the relevant behavior is covered by the regression test and manual verification above.

Checklist

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

@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. needs:title labels May 16, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Hey! Your PR title [codex] fix clipboard copy failure reporting doesn't follow conventional commit format.

Please update it to start with one of:

  • feat: or feat(scope): new feature
  • fix: or fix(scope): bug fix
  • docs: or docs(scope): documentation changes
  • chore: or chore(scope): maintenance tasks
  • refactor: or refactor(scope): code refactoring
  • test: or test(scope): adding or updating tests

Where scope is the package name (e.g., app, desktop, opencode).

See CONTRIBUTING.md for details.

@2409324124 2409324124 changed the title [codex] fix clipboard copy failure reporting fix(opencode): report clipboard copy failures May 16, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@2409324124
Copy link
Copy Markdown
Author

Manual validation details for the clipboard failure path:

Environment used for reproduction/verification:

  • OS: Ubuntu 24.04
  • Kernel: Linux 6.17.0-23-generic
  • Session: X11 (DISPLAY=:1, no WAYLAND_DISPLAY)
  • Clipboard tools absent for failure-path repro: no xclip, no xsel, no wl-copy in PATH

Validation performed:

  • Reproduced the original false-success behavior on the clipboard failure path.
  • Verified the patched TUI surfaces the real clipboard error instead of showing Copied to clipboard.
  • Verified with DISPLAY= that Clipboard.copy() rejects with the expected Linux clipboard backend error.
  • Verified normal copy succeeds when a clipboard backend is available.

Local checks run:

  • bun test --timeout 30000 test/cli/cmd/tui/clipboard.test.ts
  • bun run typecheck from packages/opencode
  • pre-push hook: bun turbo typecheck

The required GitHub checks (typecheck, unit (linux), unit (windows)) are currently waiting for maintainer workflow approval, so I cannot start those from the contributor side.

@2409324124 2409324124 marked this pull request as ready for review May 16, 2026 12:34
@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label May 16, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@chid
Copy link
Copy Markdown

chid commented May 17, 2026

I've just tested this and I think that the code works well but it doesn't show up entirely in front end (an error message). It seems to just be a red box showing.

The underlying issue still doesn't seem to be entirely fixed, and perhaps I need to test with OSC-52 compatible term but there should also be a message to notify users if that doesn't work.

#4283 isn't entirely fixed by this, I'm also running 24.04.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Copy To Clipboard is not working

2 participants