Skip to content

fix(tui): omit NUL characters in clipboard writes - #44959

Closed
fQwQf wants to merge 1 commit into
anomalyco:v2from
fQwQf:copy-nul-characters
Closed

fix(tui): omit NUL characters in clipboard writes#44959
fQwQf wants to merge 1 commit into
anomalyco:v2from
fQwQf:copy-nul-characters

Conversation

@fQwQf

Copy link
Copy Markdown

Issue for this PR

Closes#44198

Type of change

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

What does this PR do?

Shell tool output often contains NUL bytes, and the host clipboard rejects text containing NUL characters, so /copy failed 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:

printf 'a\x00b\x00c\n' > /tmp/nul.txt
# let the shell tool cat /tmp/nul.txt in a session, then run /copy

Before: error toast, clipboard unchanged. After: copy succeeds, pasted text
is abc.

Screenshots / recordings

N/A

Checklist

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

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.
@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

Copy link
Copy Markdown
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:

  1. PR fix(tui): sanitize clipboard text #44197 - fix(tui): sanitize clipboard text
  2. PR fix(tui): drop NUL characters before clipboard writes #44230 - fix(tui): drop NUL characters before clipboard writes

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).

@fQwQf

Copy link
Copy Markdown
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.

@fQwQffQwQf closed this Aug 25, 2026
@fQwQf
fQwQf deleted the copy-nul-characters branch August 25, 2026 12:24
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@fQwQf