repos / zmx

session persistence for terminal processes
git clone https://github.com/neurosnap/zmx.git

commit
9e8f01e
parent
b8c162e
author
Eric Bower
date
2025-12-22 20:38:25 -0500 EST
fix: first attach, resize first
1 files changed,  +9, -9
M src/main.zig
+9, -9
 1@@ -177,6 +177,15 @@ const Daemon = struct {
 2 
 3         const resize = std.mem.bytesToValue(ipc.Resize, payload);
 4 
 5+        var ws: c.struct_winsize = .{
 6+            .ws_row = resize.rows,
 7+            .ws_col = resize.cols,
 8+            .ws_xpixel = 0,
 9+            .ws_ypixel = 0,
10+        };
11+        _ = c.ioctl(pty_fd, c.TIOCSWINSZ, &ws);
12+        try term.resize(self.alloc, resize.cols, resize.rows);
13+
14         // Serialize terminal state BEFORE resize to capture correct cursor position.
15         // Resizing triggers reflow which can move the cursor, and the shell's
16         // SIGWINCH-triggered redraw will run after our snapshot is sent.
17@@ -195,15 +204,6 @@ const Daemon = struct {
18             }
19         }
20 
21-        var ws: c.struct_winsize = .{
22-            .ws_row = resize.rows,
23-            .ws_col = resize.cols,
24-            .ws_xpixel = 0,
25-            .ws_ypixel = 0,
26-        };
27-        _ = c.ioctl(pty_fd, c.TIOCSWINSZ, &ws);
28-        try term.resize(self.alloc, resize.cols, resize.rows);
29-
30         // Mark that we've had a client init, so subsequent clients get terminal state
31         self.has_had_client = true;
32