From 36dab7187fa0322c728848532638d549af02f746 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Mon, 23 Nov 2026 15:14:30 -0300 Subject: upgrade: a window comes back from an Upgrade the size it had (the user's two windows went from 140 x 74 cells to 112 x 32 and from 343 columns to 193 at the 15:11 install): a window session's Upgrade is an exec, and its record said only that there was a window (runtime/upgrade.zig `Record.window`), so the new image made it the default 1120 x 720 points, or the `--geometry` it was started with (its arguments are passed again), never the size the user had given it since; now `upgradeNow` (dev/gui/gui.zig) puts the window's size in points as SDL_GetWindowSize says it then in the record, a line `size WxH` after `window 1` (`Record.size`), and the new image takes it as its `--geometry`, ahead of the one it was started with: the pair's road (a client window's PARDES_JOIN_SIZE, runtime/client.zig `execAgain`, read by the same parse), size only as the pair's (no place: an X11 window started at `+X+Y` is placed by the window manager after an Upgrade now); an older build's record has no such line (the word is passed over by a build before this one): the default, as before; a test window keeps a carried size over PARDES_TEST_COLS and ROWS; test: test/daemon.py `gui_upgrades` resizes the session's window to 100 x 30 cells (the test feed's in-band resize) before the Upgrade and reads the new image's first frame's size from its capture: on the base 1280x840 (80 x 24, the default) where it had been 1600x1050; now 1600x1050 from a build that writes the line, the default from one that does not (the record on the new process's command line says which), and upgrade.zig's record test reads the line back and an older record's none; core-test 934/1100 (166 skipped), shell-test 1142/1145 (3 skipped), gui unit-test 1739/1743 (4 skipped; its perf step's known BaselineHarnessMismatch), test/daemon.py `--upgrade --gui` between this tree's builds (Debug, unstamped and -Dstamp-commit: two semantics) 3/3 and from the installed build (62c6caf414fd) 3/3, `--upgrade` from it 1/1, plain 1/1 Co-Authored-By: Claude Opus Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- runtime/upgrade.zig | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'runtime') diff --git a/runtime/upgrade.zig b/runtime/upgrade.zig index 510c50ea..b385556c 100644 --- a/runtime/upgrade.zig +++ b/runtime/upgrade.zig @@ -134,6 +134,10 @@ pub const Record = struct { old: c_int = -1, /// A window was open (the GUI). window: bool = false, + /// Its size in points at the Upgrade, `WxH` (SDL_GetWindowSize then: the + /// user's since its start), the new window's `--geometry` (gui.zig). + /// None, an older build's record: the default. + size: ?[]const u8 = null, ptys: [pardes.MAX_PANES]Pty = undefined, nptys: usize = 0, ttys: [pardes.views.max]Tty = undefined, @@ -187,6 +191,7 @@ pub const Record = struct { /// One `word value` a line, the dump's path last (its line is all of it). pub fn encode(rec: *const Record, w: *std.Io.Writer) !void { try w.print("link {d}\nstub {d}\nold {d}\nwindow {d}\n", .{ rec.link, rec.stub, rec.old, @intFromBool(rec.window) }); + if (rec.size) |wh| try w.print("size {s}\n", .{wh}); for (rec.ptys[0..rec.nptys]) |p| try w.print("pty {d} {d} {d}\n", .{ p.pane, p.pid, p.fd }); for (rec.ttys[0..rec.nttys]) |t| try w.print("tty {d} {d} {d} {d} {x}\n", .{ t.view, t.fd, t.stub, @intFromBool(t.primary), std.mem.asBytes(&t.termios) }); if (rec.refused.len > 0) try w.print("refused {s}\n", .{rec.refused}); @@ -206,11 +211,12 @@ pub const Record = struct { const rest = line[sp + 1 ..]; var it = std.mem.tokenizeScalar(u8, rest, ' '); // A word of a later build's record is passed over. - switch (std.meta.stringToEnum(enum { link, stub, old, window, pty, tty, refused, label, state, exe, dump }, word) orelse continue) { + switch (std.meta.stringToEnum(enum { link, stub, old, window, size, pty, tty, refused, label, state, exe, dump }, word) orelse continue) { .link => rec.link = try std.fmt.parseInt(c_int, rest, 10), .stub => rec.stub = try std.fmt.parseInt(c_int, rest, 10), .old => rec.old = try std.fmt.parseInt(c_int, rest, 10), .window => rec.window = std.mem.eql(u8, rest, "1"), + .size => rec.size = rest, .pty => { if (rec.nptys == rec.ptys.len) return error.BadRecord; const pane = try std.fmt.parseInt(u8, it.next() orelse return error.BadRecord, 10); @@ -474,7 +480,7 @@ pub fn load(gpa: std.mem.Allocator, core_gpa: std.mem.Allocator, opts: pardes.Op } test "an upgrade's record reads back as it was written, and refuses one cut short" { - var rec: Record = .{ .link = 5, .stub = 7, .old = 9, .window = true, .exe = "/a b/pardes", .dump = "/home/u/.local/share/pardes/pardes.xitdb", .label = "upgrade-1", .state = .kept }; + var rec: Record = .{ .link = 5, .stub = 7, .old = 9, .window = true, .size = "1402x1488", .exe = "/a b/pardes", .dump = "/home/u/.local/share/pardes/pardes.xitdb", .label = "upgrade-1", .state = .kept }; rec.addPty(3, 1234, 11); rec.addPty(0, 99, 12); var tio: posix.termios = std.mem.zeroes(posix.termios); @@ -487,6 +493,7 @@ test "an upgrade's record reads back as it was written, and refuses one cut shor try std.testing.expectEqual(@as(c_int, 5), back.link); try std.testing.expectEqual(@as(c_int, 9), back.old); try std.testing.expect(back.window); + try std.testing.expectEqualStrings("1402x1488", back.size.?); try std.testing.expectEqual(@as(usize, 2), back.nptys); try std.testing.expectEqual(Pty{ .pane = 3, .pid = 1234, .fd = 11 }, back.ptys[0]); try std.testing.expectEqual(@as(usize, 1), back.nttys); @@ -496,11 +503,11 @@ test "an upgrade's record reads back as it was written, and refuses one cut shor try std.testing.expectEqualStrings("/home/u/.local/share/pardes/pardes.xitdb", back.dump); try std.testing.expectEqualStrings("upgrade-1", back.label); try std.testing.expectEqual(daemon.State.kept, back.state.?); - // An older build's: its dump a file, no label, no state. + // An older build's: its dump a file, no label, no state, no size. const older = try Record.decode("link 5\nexe /a\ndump /run/u/pardes-upgrade-1.dump\n"); try std.testing.expectEqualStrings("/run/u/pardes-upgrade-1.dump", older.dump); try std.testing.expectEqualStrings("", older.label); - try std.testing.expect(older.state == null); + try std.testing.expect(older.state == null and older.size == null); try std.testing.expectError(error.BadRecord, Record.decode("link 5\n")); try std.testing.expectError(error.BadRecord, Record.decode("tty 0 1 2 1 abc\ndump x\n")); } -- cgit v1.3