dnd kitten: remove empty-payload EOF QueueDnDData calls for thumbnails

The empty-payload second QueueDnDData call in set_drag_image() and
set_drag_image_text() triggered base64_decode_stream on an already-
completed (padded) stream, which returns failure. This caused cancel_drag
→ drag_free_offer to run, destroying all drag state before drag_start
was called from t=P:x=-1. As a result, drag_remote_file_data found no
item with requested_remote_files set and aborted with EINVAL.

The empty EOF call was never needed: drag_add_image only accumulates
decoded bytes; the actual image processing happens later in drag_start.
This mirrors the same fix already applied to the MIME pre-send path.

Agent-Logs-Url: https://github.com/kovidgoyal/kitty/sessions/8bb89dc9-fd72-41c5-892b-2a15c658b313

Co-authored-by: kovidgoyal <1308621+kovidgoyal@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-05-09 15:55:04 +00:00 committed by GitHub
parent b9a8784f74
commit 9214bae00a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -116,10 +116,7 @@ func (dnd *dnd) set_drag_image_text() (err error) {
if icon == "" {
icon = strings.TrimSpace("󰮐 ")
}
cmd := DC{Type: 'p', X: -1, Xp: 6, Yp: 1, Payload: []byte(icon)}
dnd.lp.QueueDnDData(cmd)
cmd.Payload = nil
dnd.lp.QueueDnDData(cmd)
dnd.lp.QueueDnDData(DC{Type: 'p', X: -1, Xp: 6, Yp: 1, Payload: []byte(icon)})
return nil
}
@ -151,12 +148,9 @@ func (dnd *dnd) set_drag_image() (err error) {
} else {
pix = imaging.AsRGBAData8(img)
}
cmd := DC{
dnd.lp.QueueDnDData(DC{
Type: 'p', X: -1, Y: utils.IfElse(num_channels == 3, 24, 32), Xp: img.Bounds().Dx(), Yp: img.Bounds().Dy(),
Payload: pix}
dnd.lp.QueueDnDData(cmd)
cmd.Payload = nil
dnd.lp.QueueDnDData(cmd)
Payload: pix})
return nil
}