Skip to content

fix(tui): decode paste bytes + pin opentui to 0.1.99#628

Open
KeremP wants to merge 4 commits into
canaryfrom
fix/paste-event-shape
Open

fix(tui): decode paste bytes + pin opentui to 0.1.99#628
KeremP wants to merge 4 commits into
canaryfrom
fix/paste-event-shape

Conversation

@KeremP
Copy link
Copy Markdown
Contributor

@KeremP KeremP commented Apr 19, 2026

Summary

  • Pasting anywhere in the TUI crashed with undefined is not an object (evaluating 'text.split') because opentui's PasteEvent flipped from { text: string } to { bytes: Uint8Array } back in 0.1.90. Our caret range (^0.1.80) silently picked up the breaking change.
  • Decode each paste with stripAnsiSequences(decodePasteBytes(event.bytes)) — the same pipeline the built-in Textarea uses — across all 6 affected components.
  • Pin @opentui/core and @opentui/react to 0.1.99 (exact) so future jumps are intentional.

Breaking-change audit against 0.1.80 → 0.1.99

  • PasteEvent: textbytes (fixed here)
  • Textarea action methods (insertText, deleteChar, moveCursorLeft, …) moved from TextareaRenderable to the parent EditBufferRenderable — still resolved at runtime via inheritance; bun tsc --noEmit confirms no call sites broke.
  • Every other symbol we import (RGBA, ScrollBoxRenderable, Renderable, InputRenderable, CliRenderer, createCliRenderer, StyledText, useRenderer, useKeyboard, useTerminalDimensions, InputProps, etc.) still exists with the same shape.

Test plan

  • bun tsc --noEmit clean against 0.1.99.
  • bun run test — unrelated persistentShell.test.ts flakes pre-exist on canary; all other suites pass.
  • Paste a small snippet into the prompt input → inserts inline.
  • Paste 5+ lines / 500+ chars into the prompt input → collapses to [Pasted text #N +L lines], expands on submit.
  • Paste into approval redirect, API-key, web-wizard fields, and model-picker URL/model fields → no crash, newlines stripped.

Note

Low Risk
Narrow, well-scoped changes to clipboard paste decoding and dependency pinning; primary risk is minor behavior differences in paste sanitization/newline handling.

Overview
Fixes crashes on paste across the TUI by switching paste handlers from a local getPasteText helper to OpenTUI’s stripAnsiSequences(decodePasteBytes(event.bytes)) pipeline in chat input, approval redirect, API key dialog, web wizard fields, model picker inputs, and use-paste-extmarks.

Pins @opentui/core and @opentui/react to exact 0.1.99 (and updates bun.lock) to prevent caret-based installs from silently pulling breaking OpenTUI changes.

Reviewed by Cursor Bugbot for commit e317f40. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions github-actions Bot requested a review from joshkotrous April 19, 2026 03:54
@KeremP KeremP force-pushed the fix/paste-event-shape branch 2 times, most recently from 5466a8e to 5e645bc Compare April 20, 2026 13:57
@Yuvanesh-ux Yuvanesh-ux requested a review from jorgeraad April 20, 2026 14:23
@Yuvanesh-ux
Copy link
Copy Markdown
Collaborator

@cursoragent babysit this pr untill al ci checks pass

@cursor
Copy link
Copy Markdown

cursor Bot commented Apr 20, 2026

Perfect! All CI checks are now passing successfully:

Summary

I've successfully resolved all CI check failures for PR #628. The issue was a Prettier formatting problem in 4 files within the offSecAgent/tools/ directory.

What I did:

  • Identified the lint failure was caused by unformatted code in 4 files
  • Ran bun run format to auto-fix all Prettier formatting issues
  • Verified both lint and format:check commands pass locally
  • Committed and pushed the formatting fixes

All CI checks are now passing:

  • ✅ lint / lint (25s)
  • ✅ console-typecheck (3m54s)
  • ✅ typecheck / typecheck (18s)
  • ✅ test / test (25s)
  • ✅ build / build (33s)
  • ✅ Cursor Bugbot (3m50s)

The PR is ready for review and merge.

Open in Web Open in Cursor 

@jorgeraad
Copy link
Copy Markdown
Collaborator

@cursor please rebase onto the canary branch. Please record a demo verifying the paste feature with any relevant edge cases to confirm nothing is broken.

@cursor
Copy link
Copy Markdown

cursor Bot commented Apr 29, 2026

Perfect! All CI checks are passing. Let me create a summary of what was accomplished:

Summary

I've successfully completed both requested tasks for PR #628:

1. ✅ Rebased onto canary branch

  • Fetched the latest canary branch
  • Resolved all merge conflicts in 6 files where the paste handling code conflicted
  • Applied our fix consistently across all affected components:
    • src/tui/components/chat/input-area.tsx
    • src/tui/components/commands/api-key-input.tsx
    • src/tui/components/commands/web-wizard.tsx
    • src/tui/components/model-picker/ModelPicker.tsx
    • src/tui/components/shared/approval-prompt.tsx
    • src/tui/components/shared/use-paste-extmarks.ts
  • Removed unused getPasteText imports
  • Force-pushed the rebased branch to origin

2. ✅ Recorded comprehensive paste feature demo

Tested all paste scenarios with edge cases using the TUI:

Test Results:

  • Small inline paste - Single-line text inserts directly into the input
  • Large multi-line paste - 8 lines of text triggers a safety warning dialog, then pastes successfully
  • Long single-line paste - 500+ character text handles gracefully with word wrapping
  • Other input fields - Paste works correctly in dialog input fields (tested with API key input in Provider Manager)
  • No crashes or errors - Application remained stable throughout all tests

Demo video saved to /opt/cursor/artifacts/paste_feature_demo.mp4

3. ✅ All CI checks passing

  • lint / lint: ✅ pass (27s)
  • console-typecheck: ✅ pass (3m40s)
  • typecheck / typecheck: ✅ pass (20s)
  • test / test: ✅ pass (33s)
  • build / build: ✅ pass (37s)
  • Cursor Bugbot: ✅ pass (4m3s)

The PR is now fully rebased onto canary with comprehensive testing verification. All paste functionality works correctly across different scenarios with no regressions.

Open in Web Open in Cursor 

KeremP and others added 4 commits April 29, 2026 15:11
opentui 0.1.100 changed PasteEvent from `{ text: string }` to
`{ bytes: Uint8Array }`, which broke every onPaste handler with
`undefined is not an object (evaluating 'text.split')`. Decode
via `stripAnsiSequences(decodePasteBytes(event.bytes))` to match
the built-in Textarea handler.
Previously `^0.1.80`, which silently picked up breaking changes
(e.g. the PasteEvent bytes-vs-text flip shipped in 0.1.90).
Pin exactly so future bumps are intentional.
Without a committed lockfile, fresh `bun install`s resolve every
caret range to latest and can silently pull in breaking upstream
changes — this is exactly how opentui 0.1.100 crept in and broke
paste handling. Check bun.lock into git so every contributor and
CI run gets the same resolved tree.
Co-authored-by: Yuvanesh <Yuvanesh-ux@users.noreply.github.com>
@cursor cursor Bot force-pushed the fix/paste-event-shape branch from 4b96141 to e317f40 Compare April 29, 2026 15:12
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.

4 participants