From b7a657de105e6870b3533beb3af1b487403f2a52 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 17 Oct 2026 10:15:49 +0530 Subject: [PATCH] Fix ls --self and --output-format being ignored in remote_control mappings The Python implementation of message_to_kitty did not forward these options in the payload, so they only worked via kitten @. --- docs/changelog.rst | 3 +++ kitty/rc/ls.py | 8 +++++++- kitty_tests/remote_control.py | 14 ++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index fc0bedd8c..48eda02b6 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -500,6 +500,9 @@ Detailed list of changes - Remote control: Fix ``set-enabled-layouts --configured`` not updating the default layouts for new tabs when used in a :ac:`remote_control` mapping. +- Remote control: Fix ``ls --self`` and ``ls --output-format`` being ignored + when used in a :ac:`remote_control` mapping. + 0.49.2 [2026-10-01] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/kitty/rc/ls.py b/kitty/rc/ls.py index 918faa244..4a98a5695 100644 --- a/kitty/rc/ls.py +++ b/kitty/rc/ls.py @@ -58,7 +58,13 @@ Output in JSON or kitty session format ) def message_to_kitty(self, global_opts: RCOptions, opts: 'CLIOptions', args: ArgsType) -> PayloadType: - return {'all_env_vars': opts.all_env_vars, 'match': opts.match, 'match_tab': opts.match_tab} + return { + 'all_env_vars': opts.all_env_vars, + 'match': opts.match, + 'match_tab': opts.match_tab, + 'self': opts.self, + 'output_format': opts.output_format, + } def response_from_kitty(self, boss: Boss, window: Window | None, payload_get: PayloadGetType) -> ResponseType: tab_filter: Callable[[Tab], bool] | None = None diff --git a/kitty_tests/remote_control.py b/kitty_tests/remote_control.py index 4fc4a8a31..c3d9cd127 100644 --- a/kitty_tests/remote_control.py +++ b/kitty_tests/remote_control.py @@ -51,6 +51,20 @@ class TestRemoteControl(BaseTest): boss.active_tab.set_enabled_layouts.assert_called_once_with(['stack']) self.ae(options.enabled_layouts, ['stack'] if configured else ['tall']) + def test_ls_self_and_output_format(self): + from kitty.boss import Boss as KittyBoss + + self_window = Mock() + boss = Mock(list_os_windows=Mock(return_value=[]), serialize_state_as_session=Mock(return_value=['a', 'b'])) + self.ae(KittyBoss.call_remote_control(boss, None, ('ls', '--output-format', 'session')), 'a\nb') + boss.list_os_windows.assert_not_called() + + KittyBoss.call_remote_control(boss, self_window, ('ls', '--self')) + window_filter = boss.list_os_windows.call_args.args[2] + self.assertIsNotNone(window_filter) + self.assertTrue(window_filter(self_window)) + self.assertFalse(window_filter(Mock())) + def test_set_os_window_title_command_is_registered(self): self.assertIn('set_os_window_title', all_command_names()) self.ae(command_for_name('set-os-window-title').name, 'set-os-window-title')