Fix some responses from terminal sometimes leaking into shell on after kitten exit

Always do a roundtrip at kitten exit, except for special purpose
kittens. This slows down exit by one round trip time (capped at 2
seconds), however it ensures that we never get terminal response leak.

Fixes #9839
This commit is contained in:
Kovid Goyal
2026-04-10 15:14:38 +05:30
parent 4982173d3a
commit 5e158f90a7
12 changed files with 121 additions and 99 deletions

View File

@@ -145,7 +145,12 @@ class Callbacks:
self.bell_count += 1
def on_da1(self) -> None:
payload = da1(get_options())
opts = None
with suppress(RuntimeError):
opts = get_options()
if opts is None:
opts = defaults
payload = da1(opts)
self.da1.append(payload)
if self.pty and self.pty.needs_da1:
self.pty.send_da1_response(payload)
@@ -331,7 +336,7 @@ class PTY:
def __init__(
self, argv=None, rows=25, columns=80, scrollback=100, cell_width=10, cell_height=20,
cwd=None, env=None, stdin_fd=None, stdout_fd=None, needs_da1=False,
cwd=None, env=None, stdin_fd=None, stdout_fd=None, needs_da1=True,
):
self.is_child = False
if isinstance(argv, str):