Skip to content

feat(editor): add snippet paste dialog (alt+v)#3133

Open
EduardF1 wants to merge 1 commit into
charmbracelet:mainfrom
EduardF1:feat/snippet-paste
Open

feat(editor): add snippet paste dialog (alt+v)#3133
EduardF1 wants to merge 1 commit into
charmbracelet:mainfrom
EduardF1:feat/snippet-paste

Conversation

@EduardF1

Copy link
Copy Markdown

Summary

  • Adds a new Snippet Paste dialog triggered by Alt+V from the chat editor.
  • A full-screen overlay textarea appears where users can paste or type multi-line code.
  • Pressing Ctrl+D (done) wraps the content in a fenced code block and inserts it at the cursor in the editor; Esc cancels without inserting.
  • Adds Editor.PasteSnippet to the FullHelp key bindings so users can discover it via Ctrl+G.

Motivation

The chat editor currently handles pasted multi-line text in two ways: short pastes go directly into the textarea, and long pastes (>10 lines) become anonymous file attachments. Neither flow explicitly wraps content in code fences, which is the most common intent when a user pastes a snippet they want the model to analyse or edit.

This mirrors the Alt+V snippet-paste workflow familiar from Claude Code.

Test plan

  • Run go test ./internal/ui/dialog/... -run TestSnippet — 5 new unit tests all pass.
  • Run go test ./... — all existing tests continue to pass (pre-existing TestDispatch_BashShebang fails on Windows due to missing WSL /bin/bash; unrelated to this change).
  • Manual: open Crush, press Alt+V → overlay appears; type code → Ctrl+D → fenced code block inserted into the editor.
  • Manual: press Esc in overlay → dialog closes, nothing inserted.
  • Manual: Ctrl+G in editor → "alt+v paste snippet" appears in FullHelp.

Files changed

File Change
internal/ui/dialog/snippet.go New Snippet dialog (textarea overlay)
internal/ui/dialog/snippet_test.go 5 unit tests
internal/ui/dialog/actions.go New ActionInsertSnippet action
internal/ui/model/keys.go New Editor.PasteSnippet binding (alt+v)
internal/ui/model/ui.go Key handler + action handler + FullHelp entry

🤖 Generated with Claude Code

Adds a new snippet paste dialog (Alt+V) that lets users paste or type
multi-line code into an overlay textarea. On confirmation (Ctrl+D), the
content is wrapped in a fenced code block and inserted at the cursor in
the chat editor. Pressing Esc closes the dialog without changes.

- internal/ui/dialog/snippet.go: new Snippet dialog backed by textarea
- internal/ui/dialog/actions.go: new ActionInsertSnippet action type
- internal/ui/model/keys.go: new Editor.PasteSnippet binding (alt+v)
- internal/ui/model/ui.go: open dialog on alt+v; handle ActionInsertSnippet;
  add PasteSnippet to FullHelp bindings
- internal/ui/dialog/snippet_test.go: 5 unit tests for dialog behavior

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@charmcli

Copy link
Copy Markdown
Contributor

Thank you for your submission. We really appreciate it! Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request comment same as the below format.


I have read the Contributor License Agreement (CLA) and hereby sign the CLA.


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

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.

2 participants