Skip to content

fix(tui): report unverified clipboard delivery - #60055

Open
Chubercik wants to merge 4 commits into
anomalyco:devfrom
Chubercik:clipboard-delivery
Open

Chubercik wants to merge 4 commits into
anomalyco:devfrom
Chubercik:clipboard-delivery

Conversation

@Chubercik

@Chubercik Chubercik commented Oct 28, 2026 •

Copy link
Copy Markdown

Issue for this PR

Closes #59664

Type of change

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

What does this PR do?

The TUI showed "Copied to clipboard" after a mouse-selection copy even when the host clipboard write failed and the only attempted route was OSC 52. OpenTUI reports that route as terminal.status: "attempted", which only means the escape sequence was sent; it does not confirm that the terminal copied anything, but the adapter treated that as success.

ClipboardService.write() now returns "copied" only when the host clipboard confirms the write, and "attempted" when only the terminal route was tried. A small clipboardWriteToast() helper maps "attempted" to a warning toast, "Copied — delivery not confirmed", while verified host writes keep the existing success message. The toast-based copy paths (selection, session ID, transcript, message, debug info, OAuth code, URL, path, and working-directory copy) now use that helper. Host writes still take precedence, and a write with no successful or attempted route still rejects.

Using a warning instead of a hard error keeps SSH and unknown-capability terminals usable, where OSC 52 may be the only clipboard route.

How did you verify your code works?

  • Added adapter tests for host unsupported/failed plus terminal attempted, and for host-written precedence,
  • Added a selection-copy test that asserts the unverified warning,
  • Updated the session-ID integration test to accept the verified success or unverified warning depending on host clipboard availability,
  • Focused tests: 72 pass across 9 affected files,
  • bun run typecheck:tsc from packages/tui,
  • Pre-push bun run check passed 34/34.

Checklist

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

Added by the opencode bot (AI-generated).

Related: #50208, #59052

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change works. I ran the reproduction from #59664 with opencode-drive in a sandbox with no host clipboard, where the terminal ignores OSC 52. On the base, a mouse-selection copy shows "Copied to clipboard"; with this change it shows the "Copied — delivery not confirmed" warning. The changed TUI tests pass (61) and tsc -b passes in packages/tui. Every toast-based caller of ClipboardService.write() handles the new return value; dialog-message.tsx shows no toast and doesn't need changes.

Public API: unchanged. ClipboardService and clipboardWriteToast are internal to the TUI.

Two points, inline: a warning on every copy over SSH even in terminals that support OSC 52, and a session-ID test that no longer pins which toast appears.

Related: #50208, #59052

Before

After

Comment thread packages/tui/src/clipboard.ts Resolved

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both earlier points are addressed. A terminal-only write now counts as copied when the terminal reports capability: "supported", so remote sessions with OSC 52 support no longer get a warning on every copy; unknown and unsupported still warn. The session-ID test now forces the terminal route with setRendererCapabilities and expects the success toast exactly. I re-ran the #59664 reproduction, where the terminal reports unknown OSC 52 support: it still shows the warning. The clipboard, session-ID and selection tests pass, and tsc -b passes. The public API is unchanged. Nothing new to raise.

Before

After

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only new commit merges dev into the branch; the pull request's own change is the same as at my last review. I checked what came in from dev: every copy toast still goes through clipboardWriteToast, and nothing in it bypasses the change. After a fresh install, the changed packages/tui tests pass (68) and tsc -b passes. The #59664 reproduction still shows the "delivery not confirmed" warning when the terminal reports unknown OSC 52 support. The public API is unchanged. Nothing new to raise.

Before

After

This branch has not been deployed

No deployments
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.

TUI: "Copied to clipboard" toast shown even when nothing was copied (OSC52 "attempted" treated as success)

1 participant