szn

Bug 286 — cmdMoveWindow orphans the window when insert fails (OOM)

286. cmdMoveWindow orphans the window when insert fails (OOM)

File: src/cmd/cmd.zig:219–220 Severity: MEDIUM Status: ✅ FIXED — the insert now uses the session’s arena allocator (matching how session.windows is managed), and on failure the window is re-inserted at its original index so it is never orphaned. Regression test verifies no window is lost across forward/backward moves.

const w = session.windows.orderedRemove(src_idx);
session.windows.insert(server.allocator, dst_idx, w) catch return .err;

If insert fails, w has already been removed from the list and is dropped — its panes, pty fds, and child process become unreachable and can never be killed or deinit’d.