From 7dbcaa13cc3bebd5470ce1ac3f5e112357564063 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Mon, 23 Nov 2026 09:37:41 -0300 Subject: upgrade: the test that an Upgrade's outcome is said in every view: runtime/upgrade.zig:449 (`load`'s end) set "Upgrade: now ..." or "... it goes on as ..." at `p.view().active`, the live view at the dump, the one whose input came last before the Upgrade's step, not the one that asked (the pair round's `--with-pair --upgrade` ReleaseSafe to Debug 1 of 3: the message on pane 5, a pane of client f's view, which the session's /screen does not show); the unit test (two views, the second's keyboard on a New pane of its own and its input last, dumped and loaded as an upgrade loads it: each view's pane at its keyboard must say "Upgrade: now pardes ") fails at upgrade.zig:493 (logs/t7-upgrade-unfixed.log); and test/daemon.py's refused-upgrade row (two replica clients, the Upgrade written over 9P to the shell's pane) now waits for each client's own screen to say "Upgrade: the new build" Co-Authored-By: Claude Opus Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- runtime/upgrade.zig | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'runtime') diff --git a/runtime/upgrade.zig b/runtime/upgrade.zig index f59117ee..2fa910aa 100644 --- a/runtime/upgrade.zig +++ b/runtime/upgrade.zig @@ -463,6 +463,40 @@ pub fn load(gpa: std.mem.Allocator, core_gpa: std.mem.Allocator, opts: pardes.Op } } +test "an upgrade's outcome is said in every view, at the pane its keyboard is on, whichever view's input came last" { + const gpa = std.testing.allocator; + const p = try pardes.Pardes.init(gpa, .{ .tty_only = true }); + defer p.deinit(); + _ = try p.setTestFile("before the upgrade\n"); + const asked = p.view().active; + // A second client's view, its keyboard on a pane of its own, the input + // that came last its own (as a client's keys before an Upgrade over 9P). + const k = p.openView() orelse return error.NoView; + p.toView(k); + try std.testing.expect(p.executeBuiltinLine(p.view().active, "New")); + try std.testing.expect(p.view().active != asked); + const bytes = try pardes.dump.byteDump(p); + defer gpa.free(bytes); + var tmp = std.testing.tmpDir(.{}); + defer tmp.cleanup(); + try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "pardes-upgrade-1.dump", .data = bytes }); + var dir_buf: [4096]u8 = undefined; + const dir = dir_buf[0..try tmp.dir.realPath(std.testing.io, &dir_buf)]; + var text_buf: [4300]u8 = undefined; + var rec = try Record.decode(try std.fmt.bufPrint(&text_buf, "link -1\nstub -1\nold -1\nwindow 0\nexe /x/pardes\ndump {s}/pardes-upgrade-1.dump\n", .{dir})); + const q = try load(gpa, gpa, .{ .tty_only = true }, &rec); + defer q.deinit(); + try std.testing.expect(!rec.fresh); + var seen: usize = 0; + for (q.views) |v| if (v) |view| { + const pane = q.panes[view.active].?; + try std.testing.expect(std.mem.startsWith(u8, pane.msg[0..pane.msg_len], "Upgrade: now pardes ")); + seen += 1; + }; + try std.testing.expectEqual(@as(usize, 2), seen); + try std.testing.expect(q.views[0].?.active != q.views[k.index()].?.active); +} + 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 }; rec.addPty(3, 1234, 11); -- cgit v1.3 From e22d77e95959a5babdc3eb693d0da317c1fae1b5 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Mon, 23 Nov 2026 09:51:44 -0300 Subject: upgrade: an Upgrade's outcome is the session's news: `tellEveryView` says it at each open view's keyboard pane, a pane two views share once (the coordinator's ruling: every view that has a frontend reads it on its own screen), where `load` said it at the live view alone, the one whose input came last before the Upgrade's step; the test of the change before passes (Debug, 8/8 of the filter) Co-Authored-By: Claude Opus Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- runtime/upgrade.zig | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'runtime') diff --git a/runtime/upgrade.zig b/runtime/upgrade.zig index 2fa910aa..e7b6553a 100644 --- a/runtime/upgrade.zig +++ b/runtime/upgrade.zig @@ -436,7 +436,7 @@ pub fn load(gpa: std.mem.Allocator, core_gpa: std.mem.Allocator, opts: pardes.Op // keep its blocks for as long as this session runs. if (rec.old >= 0) _ = libc.close(rec.old); rec.old = -1; - p.setMessage(.at(p.view().active), if (rec.refused.len > 0) + tellEveryView(p, if (rec.refused.len > 0) std.fmt.bufPrint(&buf, "Upgrade: the new build could not load this session ({s}); it goes on as {s}", .{ rec.refused[0..@min(rec.refused.len, 200)], version_line }) catch "Upgrade: the new build could not load this session; it goes on as before" else "Upgrade: now " ++ version_line); @@ -463,6 +463,18 @@ pub fn load(gpa: std.mem.Allocator, core_gpa: std.mem.Allocator, opts: pardes.Op } } +/// An Upgrade is the session's news, not the asking view's: said in every +/// view at the pane its keyboard is on (each client reads it on its own +/// screen), a pane two views are on once; the live view is only the one +/// whose input came last before the dump. +fn tellEveryView(p: *pardes.Pardes, text: []const u8) void { + var told: [pardes.MAX_PANES]bool = @splat(false); + for (p.views) |v| if (v) |view| if (!told[view.active]) { + told[view.active] = true; + p.setMessage(.at(view.active), text); + }; +} + test "an upgrade's outcome is said in every view, at the pane its keyboard is on, whichever view's input came last" { const gpa = std.testing.allocator; const p = try pardes.Pardes.init(gpa, .{ .tty_only = true }); -- cgit v1.3