From 5f5ae32753c9f52b34e814edbddbf3e8192321aa Mon Sep 17 00:00:00 2001 From: Zhizhen He Date: Mon, 19 Oct 2026 23:42:39 +0800 Subject: [PATCH] set-background-opacity: Reject invalid numeric arguments Return ParseFloat errors instead of silently treating malformed input as zero opacity. Add a payload-creation regression and changelog entry. --- docs/changelog.rst | 3 +++ tools/cmd/at/set_background_opacity.go | 2 +- tools/cmd/at/set_background_opacity_test.go | 16 ++++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 tools/cmd/at/set_background_opacity_test.go diff --git a/docs/changelog.rst b/docs/changelog.rst index 5d71710b5..a5d57cf30 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -257,6 +257,9 @@ Detailed list of changes - Remote control: Fix ``kitten @ action --match`` ignoring the match and running the action on the active window (:iss:`10672`) +- Remote control: Fix ``kitten @ set-background-opacity`` treating invalid + numeric arguments as zero opacity instead of reporting an error + - ssh kitten: Fix hanging when re-using a shared connection whose connection to the server has silently died, for example, after a network change or suspend. Now the kitten detects this and reconnects (:iss:`10691`) diff --git a/tools/cmd/at/set_background_opacity.go b/tools/cmd/at/set_background_opacity.go index fa67e8d69..c7a38b588 100644 --- a/tools/cmd/at/set_background_opacity.go +++ b/tools/cmd/at/set_background_opacity.go @@ -7,7 +7,7 @@ import "strconv" func parse_opacity(arg string) (float64, error) { ans, err := strconv.ParseFloat(arg, 64) if err != nil { - return 0, nil + return 0, err } return max(0, min(ans, 1)), nil } diff --git a/tools/cmd/at/set_background_opacity_test.go b/tools/cmd/at/set_background_opacity_test.go new file mode 100644 index 000000000..e809d1260 --- /dev/null +++ b/tools/cmd/at/set_background_opacity_test.go @@ -0,0 +1,16 @@ +// License: GPLv3 Copyright: 2026, kitty contributors + +package at + +import ( + "testing" + + "github.com/kovidgoyal/kitty/tools/utils" +) + +func TestSetBackgroundOpacityRejectsInvalidNumber(t *testing.T) { + io_data := rc_io_data{rc: &utils.RemoteControlCmd{}} + if err := create_payload_set_background_opacity(&io_data, nil, []string{"oops"}); err == nil { + t.Fatalf("set-background-opacity accepted an invalid number: %#v", io_data.rc.Payload) + } +}