Commit bdbf795
Eric Bower
·
2026-04-05 20:27:13 -0400 EDT
parent 87f89de
chore(leader): init cmd only resize if leader
1 files changed,
+24,
-17
+24,
-17
| ... | ... | @@ -642,12 +642,6 @@ const Daemon = struct { | |
| 642 | 642 | payload: []const u8, | |
| 643 | 643 | ) !void { | |
| 644 | 644 | if (payload.len != @sizeOf(ipc.Resize)) return; | |
| 645 | - | // no leader is set so set one | |
| 646 | - | if (self.leader_client_fd == null) { | |
| 647 | - | self.leader_client_fd = client.socket_fd; | |
| 648 | - | } | |
| 649 | - | ||
| 650 | - | const resize = std.mem.bytesToValue(ipc.Resize, payload); | |
| 651 | 645 | ||
| 652 | 646 | // Serialize terminal state BEFORE resize to capture correct cursor position. | |
| 653 | 647 | // Resizing triggers reflow which can move the cursor, and the shell's |
| ... | ... | @@ -673,19 +667,32 @@ const Daemon = struct { | |
| 673 | 667 | } | |
| 674 | 668 | } | |
| 675 | 669 | ||
| 676 | - | var ws: cross.c.struct_winsize = .{ | |
| 677 | - | .ws_row = resize.rows, | |
| 678 | - | .ws_col = resize.cols, | |
| 679 | - | .ws_xpixel = 0, | |
| 680 | - | .ws_ypixel = 0, | |
| 681 | - | }; | |
| 682 | - | _ = cross.c.ioctl(pty_fd, cross.c.TIOCSWINSZ, &ws); | |
| 683 | - | try term.resize(self.alloc, resize.cols, resize.rows); | |
| 670 | + | // no leader is set so set one | |
| 671 | + | if (self.leader_client_fd == null) { | |
| 672 | + | std.log.info( | |
| 673 | + | "setting new leader session={s} client_fd={d}", | |
| 674 | + | .{ self.session_name, client.socket_fd }, | |
| 675 | + | ); | |
| 676 | + | self.leader_client_fd = client.socket_fd; | |
| 677 | + | } | |
| 684 | 678 | ||
| 685 | - | // Mark that we've had a client init, so subsequent clients get terminal state | |
| 686 | - | self.has_had_client = true; | |
| 679 | + | // only resize if leader | |
| 680 | + | if (self.leader_client_fd == client.socket_fd) { | |
| 681 | + | const resize = std.mem.bytesToValue(ipc.Resize, payload); | |
| 682 | + | var ws: cross.c.struct_winsize = .{ | |
| 683 | + | .ws_row = resize.rows, | |
| 684 | + | .ws_col = resize.cols, | |
| 685 | + | .ws_xpixel = 0, | |
| 686 | + | .ws_ypixel = 0, | |
| 687 | + | }; | |
| 688 | + | _ = cross.c.ioctl(pty_fd, cross.c.TIOCSWINSZ, &ws); | |
| 689 | + | try term.resize(self.alloc, resize.cols, resize.rows); | |
| 690 | + | ||
| 691 | + | // Mark that we've had a client init, so subsequent clients get terminal state | |
| 692 | + | self.has_had_client = true; | |
| 687 | 693 | ||
| 688 | - | std.log.debug("init resize rows={d} cols={d}", .{ resize.rows, resize.cols }); | |
| 694 | + | std.log.debug("init resize rows={d} cols={d}", .{ resize.rows, resize.cols }); | |
| 695 | + | } | |
| 689 | 696 | } | |
| 690 | 697 | ||
| 691 | 698 | pub fn handleResize( |