From 9214bae00a5f1ab0d8d82b1ebd970a19ebbc3799 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 9 May 2026 15:55:04 +0000 Subject: [PATCH] dnd kitten: remove empty-payload EOF QueueDnDData calls for thumbnails MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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> --- kittens/dnd/drag.go | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/kittens/dnd/drag.go b/kittens/dnd/drag.go index 42021be62..5b02ee9a7 100644 --- a/kittens/dnd/drag.go +++ b/kittens/dnd/drag.go @@ -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 }