File: src/tty/tty_key.zig:63 (decode), src/server/server.zig:1199 (encode)
Severity: CRITICAL
Status: ✅ FIXED (user-reported)
When running coding agents such as Antigravity-CLI inside szn, pressing Ctrl+J (supposed to insert a newline without sending the message) sends the message instead. Ctrl+J is completely indistinguishable from Enter.
szn enables only bracketed paste (2004) + SGR mouse on the outer terminal — no kitty keyboard protocol push — so legacy raw bytes always arrive:
// src/tty/tty_key.zig:63
if (byte == 0x0a or byte == 0x0d) return Event{ .key = .{ .special = .{ .key = .enter } } };
Ctrl+J is byte 0x0A (LF); Enter is 0x0D (CR). Both decode to .enter, which
the server forwards to the pane pty as "\r":
// src/server/server.zig:1199
.enter => pane.writeInput("\r") catch ...
The agent receives \r = Enter = send message. tmux forwards these bytes
verbatim; szn’s decode→re-encode round-trip destroys the distinction.
Split LF from CR. The forward path already encodes ctrl-chars correctly
(code & 0x1F at server.zig:1167-1173 yields 0x0A, byte-exact passthrough):
if (byte == 0x0d) return Event{ .key = .{ .special = .{ .key = .enter } } };
if (byte == 0x0a) return Event{ .key = .{ .char = .{ .code = 'J', .mod = .{ .ctrl = true } } } };
(Equivalently: delete 0x0a from line 63 — the generic < 0x20 path below it
already produces ctrl+'J' via byte | 0x40.)
Update the ground enter test and add tests: feed(0x0a) yields
.char.code == 'J' with .mod.ctrl; end-to-end writeKeyToPty(ctrl+J) writes
a single 0x0A byte to the pty.
src/tty/tty_key.zig — LF (0x0A) now decodes as .char = .{ .code = 'J',
.mod = .{ .ctrl = true } }; Enter stays CR-only. The existing forward path
(code & 0x1F) already emits byte-exact 0x0A.
Tests: ground LF is Ctrl+J not Enter — bug #349 (tty_key.zig);
processInput forwards Ctrl+J as LF byte, Enter as CR — bug #349
(server.zig end-to-end via fake pty pipe).