From bb4a3324e7557ffc95e2b5861174485cecfd65f0 Mon Sep 17 00:00:00 2001 From: Zhizhen He Date: Sat, 17 Oct 2026 13:12:22 +0800 Subject: [PATCH] Fix remote_control run with non-terminal stdin --- docs/changelog.rst | 3 +++ kitty/rc/run.py | 2 ++ kitty_tests/remote_control.py | 20 ++++++++++++++++++++ 3 files changed, 25 insertions(+) diff --git a/docs/changelog.rst b/docs/changelog.rst index 48eda02b6..b5447f142 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -503,6 +503,9 @@ Detailed list of changes - Remote control: Fix ``ls --self`` and ``ls --output-format`` being ignored when used in a :ac:`remote_control` mapping. +- Remote control: Fix ``run`` not executing commands from + :ac:`remote_control` mappings when standard input is not a terminal. + 0.49.2 [2026-10-01] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/kitty/rc/run.py b/kitty/rc/run.py index 971297c90..e39a39a78 100644 --- a/kitty/rc/run.py +++ b/kitty/rc/run.py @@ -91,6 +91,8 @@ The executed program will have privileges to run remote control commands in kitt break ret['data'] = standard_b64encode(data).decode('ascii') yield ret + ret['data'] = '' + yield ret return pipe() diff --git a/kitty_tests/remote_control.py b/kitty_tests/remote_control.py index c3d9cd127..c1b51d1f3 100644 --- a/kitty_tests/remote_control.py +++ b/kitty_tests/remote_control.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # License: GPLv3 Copyright: 2026 Kovid Goyal +import io import os import subprocess import tempfile @@ -37,6 +38,25 @@ class Boss: class TestRemoteControl(BaseTest): + def test_run_stdin_completion(self): + from kitty.boss import Boss as KittyBoss + + command = command_for_name('run') + for is_tty, data in ((False, b''), (False, b'hello'), (False, b'\x00\xff' * 4097), (True, b'')): + with self.subTest(is_tty=is_tty, size=len(data)): + stdin = Mock(buffer=io.BytesIO(data)) + stdin.isatty.return_value = is_tty + boss = Mock() + with patch('kitty.rc.run.sys.stdin', stdin), patch.object(command, 'create_async_responder'): + KittyBoss.call_remote_control(boss, None, ('run', 'cat')) + for call in boss.run_background_process.call_args_list: + call.kwargs['notify_on_death'](0, None) + + boss.run_background_process.assert_called_once() + call = boss.run_background_process.call_args + self.ae(call.args[0], ['cat']) + self.ae(call.kwargs['stdin'], data) + def test_set_enabled_layouts_configured(self): from kitty.boss import Boss as KittyBoss