- commit
- bdbf795
- parent
- 87f89de
- author
- Eric Bower
- date
- 2026-04-05 20:27:13 -0400 EDT
chore(leader): init cmd only resize if leader
1 files changed,
+24,
-17
+24,
-17
1@@ -642,12 +642,6 @@ const Daemon = struct {
2 payload: []const u8,
3 ) !void {
4 if (payload.len != @sizeOf(ipc.Resize)) return;
5- // no leader is set so set one
6- if (self.leader_client_fd == null) {
7- self.leader_client_fd = client.socket_fd;
8- }
9-
10- const resize = std.mem.bytesToValue(ipc.Resize, payload);
11
12 // Serialize terminal state BEFORE resize to capture correct cursor position.
13 // Resizing triggers reflow which can move the cursor, and the shell's
14@@ -673,19 +667,32 @@ const Daemon = struct {
15 }
16 }
17
18- var ws: cross.c.struct_winsize = .{
19- .ws_row = resize.rows,
20- .ws_col = resize.cols,
21- .ws_xpixel = 0,
22- .ws_ypixel = 0,
23- };
24- _ = cross.c.ioctl(pty_fd, cross.c.TIOCSWINSZ, &ws);
25- try term.resize(self.alloc, resize.cols, resize.rows);
26+ // no leader is set so set one
27+ if (self.leader_client_fd == null) {
28+ std.log.info(
29+ "setting new leader session={s} client_fd={d}",
30+ .{ self.session_name, client.socket_fd },
31+ );
32+ self.leader_client_fd = client.socket_fd;
33+ }
34
35- // Mark that we've had a client init, so subsequent clients get terminal state
36- self.has_had_client = true;
37+ // only resize if leader
38+ if (self.leader_client_fd == client.socket_fd) {
39+ const resize = std.mem.bytesToValue(ipc.Resize, payload);
40+ var ws: cross.c.struct_winsize = .{
41+ .ws_row = resize.rows,
42+ .ws_col = resize.cols,
43+ .ws_xpixel = 0,
44+ .ws_ypixel = 0,
45+ };
46+ _ = cross.c.ioctl(pty_fd, cross.c.TIOCSWINSZ, &ws);
47+ try term.resize(self.alloc, resize.cols, resize.rows);
48+
49+ // Mark that we've had a client init, so subsequent clients get terminal state
50+ self.has_had_client = true;
51
52- std.log.debug("init resize rows={d} cols={d}", .{ resize.rows, resize.cols });
53+ std.log.debug("init resize rows={d} cols={d}", .{ resize.rows, resize.cols });
54+ }
55 }
56
57 pub fn handleResize(