This commit is contained in:
Kovid Goyal 2026-10-17 11:12:49 +05:30
parent bb4a3324e7
commit 277ff7f1e1
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
3 changed files with 13 additions and 28 deletions

View file

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

View file

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

View file

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