[BUG] Mods: prompt.edit does not fire for a paste collapsed into [Pasted text #n]
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report
- [x] I am using the latest version of Claude Code
What's Wrong?
The mod API documents prompt.edit as firing "when the person edits the main prompt box: a key the editor took as an edit, or a paste", with inputText holding "the typed or pasted text".
A paste the editor keeps inline does fire it. A paste the editor collapses into a placeholder such as [Pasted text #1 +29 lines] fires no prompt.edit at all, so a mod cannot see the pasted text before the prompt is sent. $.prompt.read() returns only the placeholder.
What Should Happen?
A collapsed paste fires prompt.edit with the full pasted text in inputText, as the documentation describes, or the API offers another way to read the content behind a [Pasted text #n] placeholder before submit.
Error Messages/Logs
prompt.edit events logged by a mod during one session (one JSON object per event):
{"inputLen":7,"boxText":"one\ntwo"} <- 2-line paste, kept inline: fires
{"key":{"key":"u","ctrl":true},"inputLen":0,...} <- Ctrl+U clearing the box
<- 30-line paste, collapsed: nothing
{"key":{"key":"u","ctrl":true},"inputLen":0,...}
<- 1200-character one-line paste, collapsed: nothing
Steps to Reproduce
- Load a mod whose hooks module logs every
prompt.edit, for example:
``tsx${await $.session.cwd()}/edit-${Date.now()}.json
on('prompt.edit', async ($, e, next) => {
const box = await next(e)
await $.fs.write(, JSON.stringify({ key: e.key, inputLen: e.inputText.length, boxText: box.text.slice(0, 60) }))``
return box
})
- Paste two short lines: an event is logged with the pasted text.
- Paste 30 lines: the box shows
[Pasted text #1 +29 lines]and no event is logged. - Paste one 1200-character line: the box shows
[Pasted text #2]and no event is logged.
Claude Model
Not model related.
Is this a regression?
I don't know
Claude Code Version
2.1.293 (Claude Code); the same on 2.1.292.
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
Windows Terminal and a ConPTY session with bracketed paste; PowerShell 7.
Additional Information
Found while building a mod that previews collapsed pasted text above the prompt (related request: #23134). The current workaround reads the system clipboard when a new placeholder appears, which fails for pastes over SSH.