From 13898e73f2317cc7765a3f1467026cab450e34da Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 5 May 2026 10:33:11 +0000 Subject: [PATCH] Implement --exit-on flag for dnd kitten Agent-Logs-Url: https://github.com/kovidgoyal/kitty/sessions/b6835902-79c3-4d14-9761-8633073db808 Co-authored-by: kovidgoyal <1308621+kovidgoyal@users.noreply.github.com> --- kittens/dnd/drag.go | 4 ++++ kittens/dnd/drop.go | 3 +++ kittens/dnd/main.go | 15 ++++++++++++++- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/kittens/dnd/drag.go b/kittens/dnd/drag.go index a61898142..84382bb5e 100644 --- a/kittens/dnd/drag.go +++ b/kittens/dnd/drag.go @@ -227,7 +227,11 @@ func (dnd *dnd) on_drag_event(x, y, operation, Y int) (err error) { case 3: dnd.drag_status.dropped = true case 4: + was_dropped := dnd.drag_status.dropped dnd.reset_drag() + if was_dropped && dnd.has_exit_on("drag-finish") { + dnd.lp.Quit(0) + } case 5: if err = dnd.handle_data_request(y, Y == 1); err != nil { return err diff --git a/kittens/dnd/drop.go b/kittens/dnd/drop.go index 7cdb2458b..3fddb0900 100644 --- a/kittens/dnd/drop.go +++ b/kittens/dnd/drop.go @@ -467,6 +467,9 @@ func (dnd *dnd) end_drop(success bool) { } } dnd.reset_drop() + if success && dnd.has_exit_on("drop-finish") { + dnd.lp.Quit(0) + } } func (dnd *dnd) all_drop_data_received() (err error) { diff --git a/kittens/dnd/main.go b/kittens/dnd/main.go index 213f04f28..529db397d 100644 --- a/kittens/dnd/main.go +++ b/kittens/dnd/main.go @@ -103,6 +103,15 @@ func (dnd *dnd) send_test_response(payload string) { dnd.lp.DebugPrintln(payload) } +func (dnd *dnd) has_exit_on(event string) bool { + for _, e := range strings.Split(dnd.opts.ExitOn, ",") { + if strings.TrimSpace(e) == event { + return true + } + } + return false +} + func (dnd *dnd) setup_base_dir(base_dir string) (err error) { if dnd.drop_output_dir != nil { dnd.drop_output_dir.Close() @@ -281,7 +290,11 @@ func (dnd *dnd) run_loop() (err error) { return dnd.drop_confirm(true) } } - if e.MatchesPressOrRepeat("ctrl+c") || e.MatchesPressOrRepeat("esc") { + if e.MatchesPressOrRepeat("ctrl+c") { + dnd.lp.Quit(0) + return + } + if e.MatchesPressOrRepeat("esc") && dnd.has_exit_on("esc-key") { dnd.lp.Quit(0) return }