"default" session and background shell leaked on szn new-session -s <name>runServerDaemon pre-creates "default" and spawns an extra shell even when the startup command was new-sessionSeverity: HIGH
Status: ✅ RESOLVED
Files: src/main.zig:302-318, src/main.zig:480-534, src/cmd/cmd.zig:51-74
When no server is running and the user invokes szn new-session -s work (or szn new -s work):
main.zig:302-318 auto-starts the daemon via forkAndStartServer, which runs runServerDaemon.runServerDaemon (src/main.zig:480) unconditionally creates a session named "default" (initial_session_id = 0) with an unspawned pane (pty == null).runServerDaemon then runs 16 event-loop ticks (src/main.zig:511-513) so initial client commands can be processed before spawning the default shell.new-session -s work. cmdNewSession (src/cmd/cmd.zig:51-74) creates a second session named "work" (id == 1), calls server.setupPane(session, pane) (spawning a shell in "work"), and swaps "work" to server.sessions.items[0] while "default" moves to server.sessions.items[1].src/main.zig:518-534, runServerDaemon searches server.sessions.items for s.id == initial_session_id (0), finds "default" at items[1], sees pane.pty == null, and spawns a second login shell inside "default".As a result, every cold start via szn new-session leaks an unwanted "default" session and a live background shell process.
In runServerDaemon (src/main.zig:518-534), if another session was created and made active during the startup ticks while the pre-created "default" session (initial_session_id) still has an unspawned initial pane (windows.items.len == 1 and panes.items.len == 1 and pane.pty == null), destroy the unused "default" session instead of spawning a shell in it (or have cmdNewSession reuse the unspawned initial "default" session by renaming and configuring it when pty == null).