fix(tui): omit NUL characters in clipboard writes - #44959
Closed
fQwQf wants to merge 1 commit into
Closed
Conversation
Host clipboards reject NUL characters, so /copy failed entirely when a transcript contained a NUL byte from shell output (anomalyco#44198). Strip NULs in the clipboard adapter so the copy succeeds without them.
Contributor
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
Contributor
|
The following comment was made by an LLM, it may be inaccurate: Based on the search results, I found two related PRs that appear to address the same issue:
Both of these PRs are tackling the same problem as PR #44959 (your current PR): removing NUL characters from clipboard writes in the TUI to fix the clipboard paste issue. These are likely duplicate attempts to fix the same underlying issue (#44198). |
Author
|
Closing as duplicate of #44197, which implements the same fix and was opened earlier. Verified the approach works on GNOME Terminal / Wayland with the native host clipboard backend. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Issue for this PR
Closes #44198
Type of change
What does this PR do?
Shell tool output often contains NUL bytes, and the host clipboard rejects text containing NUL characters, so
/copyfailed entirely with "Failed to copy session transcript".This strips NUL characters in the clipboard adapter (
packages/tui/src/clipboard.ts) before the text reaches OpenTUI, so one stray byte no longer fails the whole copy — the rest of the transcript is copied as-is, which is the behavior requested in the issue.How did you verify your code works?
Added a regression test in
packages/tui/test/clipboard.test.ts: writing"a\0b\0"through the adapter now passes"ab"to the clipboard service.tsc/typecheck and oxlint pass.Reviewer repro:
Before: error toast, clipboard unchanged. After: copy succeeds, pasted text
is
abc.Screenshots / recordings
N/A
Checklist