Skip to content

fix(tui): handle form clipboard shortcut - #43526

Merged
kitlangton merged 2 commits into
v2from
fix-question-paste
Aug 19, 2026
Merged

kitlangton merged 2 commits into
v2from
fix-question-paste

Conversation

@kitlangton

@kitlangton kitlangton commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

What

Ctrl+V now pastes clipboard text into the standard V2 TUI form. When a configured choice is focused, the paste automatically opens Type your own answer, inserts the text, and selects that custom answer without submitting.

Before / After

Before: Bracketed terminal paste worked, but the configured prompt.paste shortcut was only owned by the normal prompt. While FORM_MODE was active, pressing Ctrl+V did nothing and Type your own answer remained unchanged.

After: The form registers prompt.paste in FORM_MODE, reads the TUI clipboard service, and routes plain text into the active form editor. Choice fields open the custom-answer row; an already-open textarea receives the text at its cursor.

How

  • packages/tui/src/routes/session/form.tsx shares custom-answer insertion between bracketed paste and clipboard-command paste.
  • Clipboard text receives the same ANSI stripping and newline normalization as terminal paste bytes.
  • The form's prompt.paste command is active only while an answer field is displayed.
  • packages/tui/test/cli/tui/form.test.tsx supplies real clipboard content and exercises Ctrl+V through the configured keymap.

Scope

  • This PR changes the standard V2 TUI form only.
  • Browser app and Mini TUI behavior are unchanged.
  • Non-text clipboard content remains ignored.

Testing

  • bun run test test/cli/tui/form.test.tsx in packages/tui (20 passed)
  • bun typecheck in packages/tui
  • Push hook full-repo typecheck (33 tasks passed)
  • Live bun run dev:live PTY verification using OS clipboard content and an actual Ctrl+V keypress

Demo

Standard V2 TUI after ctrlv-target was placed on the OS clipboard and pasted with Ctrl+V while the first configured choice was focused:

TUI form with clipboard text in Type your own answer

Flow

sequenceDiagram
  participant User
  participant Keymap
  participant Form
  participant Clipboard

  User->>Keymap: Ctrl+V
  Keymap->>Form: prompt.paste in FORM_MODE
  Form->>Clipboard: read()
  Clipboard-->>Form: text/plain
  Form->>Form: normalize and open custom answer
Loading

@kitlangton kitlangton changed the title fix(ui): paste into custom form answers fix(tui): handle form clipboard shortcut Aug 19, 2026
@kitlangton
kitlangton enabled auto-merge (squash) August 19, 2026 21:54
@kitlangton
kitlangton merged commit c4afbc4 into v2 Aug 19, 2026
9 of 10 checks passed
@kitlangton
kitlangton deleted the fix-question-paste branch August 19, 2026 22:10
jinhuang712 pushed a commit to jinhuang712/opencode that referenced this pull request Sep 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant