Skip to content

fix(tui): surface clipboard write failures instead of false success - #41924

Open
aishangwuji wants to merge 1 commit into
anomalyco:devfrom
aishangwuji:fix-copy-on-select
Open

fix(tui): surface clipboard write failures instead of false success#41924
aishangwuji wants to merge 1 commit into
anomalyco:devfrom
aishangwuji:fix-copy-on-select

Conversation

@aishangwuji

@aishangwuji aishangwuji commented Aug 12, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #41470

Type of change

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

What does this PR do?

The TUI shows a "Copied to clipboard" toast even when the clipboard write silently failed, leaving the system clipboard empty. On Linux (e.g. Ubuntu), copy-on-select fires on mouse-up, but when no clipboard tool (wl-copy/xclip/xsel) is available or the write errors out, packages/tui/src/clipboard.ts swallowed the error with .catch(() => undefined) in both the native command and clipboardy fallback paths. write() therefore always resolved, and every caller (Selection.copy, DialogProvider.copySelection, message/session copy, etc.) showed the success toast regardless of the actual outcome.

The fix removes the error swallowing so real failures propagate to the callers' existing toast.error handlers. To make the write path unit-testable, the native/clipboardy logic was extracted into an injectable writeWith(deps, text).

How did you verify your code works?

  • Added packages/tui/test/clipboard.test.ts cases asserting writeWith rejects when the native command or the clipboardy fallback fails (these fail against the old code), plus coverage for the success path and osascript escaping.
  • bun test test/clipboard.test.ts in packages/tui: 8/8 pass.
  • bun typecheck in packages/tui: passes.

Screenshots / recordings

Not a visual change; behavior of the failure toast only.

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:issue labels Aug 12, 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.

@github-actions github-actions Bot removed needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels Aug 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

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

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.

“Copied to clipboard” doesn't work

1 participant