Fix remote_control run with non-terminal stdin

This commit is contained in:
Zhizhen He 2026-10-17 13:12:22 +08:00
parent b7a657de10
commit bb4a3324e7
No known key found for this signature in database
GPG key ID: B5A215D74FCFD6A7
3 changed files with 25 additions and 0 deletions

View file

@ -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]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View file

@ -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()

View file

@ -1,6 +1,7 @@
#!/usr/bin/env python
# License: GPLv3 Copyright: 2026 Kovid Goyal <kovid at kovidgoyal.net>
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