ESC k window titlesSeverity: HIGH
Status: ✅ RESOLVED
Files:
When launching programs such as vith from a shell inside szn, the window title briefly shows vith (or the document title), then reverts back to Python after ~500 ms:
vith sends OSC 0 (\x1b]0;vith\x07) and ESC k (\x1bkvith\x1b\).vith.Python.Server.renderToDisplayClient, the automatic window rename loop ran every 500 ms:
if (proc_res) |proc_name_val| {
if (proc_name_val.len > 0 and !std.mem.eql(u8, win.name, proc_name_val)) {
win.setName(proc_name_val);
win.setLastForegroundName(proc_name_val);
On macOS, pty.getProcessNameByPgid calls Darwin’s proc_name(), returning "Python" (which reflects the kernel’s immutable p_comm field). Even though vith had set win.name to "vith", !std.mem.eql(u8, "vith", "Python") evaluated to true. Auto-rename treated this as a process name change and clobbered win.name back to "Python".
ESC k screen rename sequence:
Because szn exports TERM=tmux-256color, applications also emit \x1bk<title>\x1b\. In advanceEsc, 'k' was not handled, resetting the parser to .ground and writing raw title bytes to the terminal grid.Window:
Added has_custom_title: bool = false to Window. When windowTitleCallback receives a non-empty title (from OSC 0/2 or ESC k), it sets win.has_custom_title = true. If given an empty title (\x1b]0;\x07 or \x1bk\x1b\), it clears has_custom_title and restores last_foreground_name.renderToDisplayClient, auto-rename tracks whether the foreground process actually changed (!std.mem.eql(u8, win.last_foreground_name, proc_name_val)). When a foreground process change occurs (e.g. vith exits back to zsh), has_custom_title is cleared and win.name reverts to the shell. While the same process runs, has_custom_title protects the application’s title.ESC k support:
In src/input.zig advanceEsc, 'k' transitions into osc_string pre-filled with "0;", routing ESC k <title> ST to the existing title callback and preventing escape bytes from leaking into the screen.input.test.ESC k window rename sequence invokes title callback — bug #563window.test.auto-rename avoids freeing name_buf and avoids aliased double-free — bug #358 (extended to verify custom title set & empty title clear)server.server.test.automatic rename preserves custom title and restores on process exit — bug #563