diff --git a/docs/changelog.rst b/docs/changelog.rst index b5447f142..9330c1c03 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -504,7 +504,8 @@ Detailed list of changes 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. + :ac:`remote_control` mappings when kitty's standard input is not a terminal. + The mapping no longer reads kitty's own standard input. 0.49.2 [2026-10-01] diff --git a/kitty/rc/run.py b/kitty/rc/run.py index e39a39a78..5dc532eff 100644 --- a/kitty/rc/run.py +++ b/kitty/rc/run.py @@ -1,7 +1,6 @@ #!/usr/bin/env python # License: GPLv3 Copyright: 2020, Kovid Goyal -import sys from base64 import standard_b64decode, standard_b64encode from typing import TYPE_CHECKING @@ -12,7 +11,6 @@ from kitty.types import AsyncResponse from .base import ( ArgsType, Boss, - CmdGenerator, ParsingOfArgsFailed, PayloadGetType, PayloadType, @@ -80,21 +78,9 @@ The executed program will have privileges to run remote control commands in kitt 'data': '', } - def pipe() -> CmdGenerator: - if sys.stdin.isatty(): - yield ret - else: - limit = 4096 - while True: - data = sys.stdin.buffer.read(limit) - if not data: - break - ret['data'] = standard_b64encode(data).decode('ascii') - yield ret - ret['data'] = '' - yield ret - - return pipe() + # This is only used for remote_control mappings, where there is no + # meaningful STDIN to forward (the kitten @ client is implemented in Go) + return ret def response_from_kitty(self, boss: Boss, window: Window | None, payload_get: PayloadGetType) -> ResponseType: import os diff --git a/kitty_tests/remote_control.py b/kitty_tests/remote_control.py index c1b51d1f3..ffc6e97f2 100644 --- a/kitty_tests/remote_control.py +++ b/kitty_tests/remote_control.py @@ -1,7 +1,6 @@ #!/usr/bin/env python # License: GPLv3 Copyright: 2026 Kovid Goyal -import io import os import subprocess import tempfile @@ -38,24 +37,23 @@ class Boss: class TestRemoteControl(BaseTest): - def test_run_stdin_completion(self): + def test_run_mapping_ignores_stdin(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)) + for is_tty in (False, True): + with self.subTest(is_tty=is_tty): + stdin = Mock() stdin.isatty.return_value = is_tty boss = Mock() - with patch('kitty.rc.run.sys.stdin', stdin), patch.object(command, 'create_async_responder'): + with patch('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.call_args.kwargs['notify_on_death'](0, None) + stdin.buffer.read.assert_not_called() 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) + self.ae(call.kwargs['stdin'], b'') def test_set_enabled_layouts_configured(self): from kitty.boss import Boss as KittyBoss