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 From 0742955e2cb52d644fb868b21865149d2a6438f8 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Mon, 23 Nov 2026 15:55:44 -0300 Subject: help: `pardes help ` prints what `Help ` shows (one function writes both, core/Output.zig `writeWordHelp`: the builtin's row, its whole documentation, its keys, argument, what it acts on and its `pardes do` line), and the manual's glossary prints each word's whole documentation under it (the sinks of the one table, `registry.doc`: the user's "the CLI as living documentation, like 9P, maybe sharing the source with different sinks"): `pardes help ` read the word's line of /commands, a session's or a core made here, and printed its first sentence; now a builtin of this build is answered from the table with no tree asked (runtime/main.zig `help`), the name as the registry takes it (`pardes help index` stays the tree's file), and an addon's word, which only a session knows, as before from /commands; `pardes help`, `pardes words` and /commands keep one line a word, the summary; docs/typ/style.typ's `builtin-entry` prints `text`, a paragraph a line, where it printed `doc` (the summary); tests: test/process/cli.zig's help case (`pardes help Newcol`: its row and `acts on: the session (over 9P, the root ctl)`; `pardes help Save`: `from a shell: pardes do Save [ARG]`; `pardes help Diff`: its second paragraph's `Diff `); process-test (cli: help) 1/1, core-test (docs/typ) 9/9, Debug tui; the book builds in the change that regenerates builtins-gui.json (its words need `text` too) Co-Authored-By: Claude Opus Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- docs/typ/style.typ | 6 ++++-- runtime/main.zig | 6 ++++++ test/process/cli.zig | 8 ++++++-- 3 files changed, 16 insertions(+), 4 deletions(-) (limited to 'runtime') diff --git a/docs/typ/style.typ b/docs/typ/style.typ index bf005c63..1b172dc8 100644 --- a/docs/typ/style.typ +++ b/docs/typ/style.typ @@ -188,7 +188,8 @@ /// Every builtin of either build, written by `zig build builtins-json` /// from the registry and the Help rows (core/builtins_json.zig), a file per /// build: name, leader, also (Help's other shortcuts), arg, scope, setting, -/// choices, doc, and for a shipped addon's word its addon first. Merged here, each with `platforms`: "both", "tui" (the +/// choices, doc (its summary), text (its whole documentation, a line a +/// paragraph), and for a shipped addon's word its addon first. Merged here, each with `platforms`: "both", "tui" (the /// terminal only) or "gui" (the window only). #let builtin-data = { let tui = json("builtins-tui.json") @@ -426,7 +427,8 @@ #if "addon" in b [#emph[the #raw(b.addon) addon's] · ] #if keys.len() > 0 [#keys.join([, ]) · ] #if b.choices != none [#raw(b.choices.replace(", ", "|")) · ] else if b.arg [takes an argument · ] - #prose(b.doc) + // its whole documentation (`text`), a paragraph a line, as Help shows it + #b.text.split("\n").map(prose).join(parbreak()) ] /// The glossary: everyday words first, then the groups, then internals, diff --git a/runtime/main.zig b/runtime/main.zig index 5cdf5ee0..8558e25f 100644 --- a/runtime/main.zig +++ b/runtime/main.zig @@ -879,6 +879,12 @@ fn help(init: std.process.Init, out: *std.Io.Writer, args: []const []const u8, s writeLeaf(out, c) catch {}; return 0; } + // A builtin of this build: what `Help ` shows, its whole + // documentation (builtins.registry.doc) and what the list does not say. + if (std.meta.stringToEnum(pardes.builtins.registry.Builtin(), what)) |b| { + pardes.panes.Output.writeWordHelp(out, b) catch {}; + return 0; + } const t = readTree(init, session); const commands = t.read(arena, "commands") catch ""; if (Word.find(commands, what)) |w| { diff --git a/test/process/cli.zig b/test/process/cli.zig index 083ba368..bf3716a8 100644 --- a/test/process/cli.zig +++ b/test/process/cli.zig @@ -52,8 +52,12 @@ fn helpOffline(gpa: std.mem.Allocator, exe: [:0]const u8) !void { try expectRan(try pardes(a, exe, root, &.{ "help", "attach" }), 0, "\n pardes attach box:notes ", "help attach"); try expectRan(try pardes(a, exe, root, &.{ "help", "new" }), 0, " --detach[=NAME]", "help new"); try expectRan(try pardes(a, exe, root, &.{ "help", "fs" }), 0, "usage: fs ls [PATH]", "help fs"); - try expectRan(try pardes(a, exe, root, &.{ "help", "Newcol" }), 0, "Newcol (the root ctl; SPC c n; column)", "help Newcol"); - try expectRan(try pardes(a, exe, root, &.{ "help", "Save" }), 0, "pardes do Save", "help Save"); + // A builtin: what `Help ` shows, its whole documentation. + const newcol = try pardes(a, exe, root, &.{ "help", "Newcol" }); + try expectRan(newcol, 0, "SPC c n Newcol", "help Newcol"); + try expectRan(newcol, 0, "\nacts on: the session (over 9P, the root ctl)\n", "help Newcol"); + try expectRan(try pardes(a, exe, root, &.{ "help", "Save" }), 0, "\nfrom a shell: pardes do Save [ARG]\n", "help Save"); + try expectRan(try pardes(a, exe, root, &.{ "help", "Diff" }), 0, "`Diff `", "help Diff"); try expectRan(try pardes(a, exe, root, &.{ "help", "pane/3/addr" }), 0, "pane// name body tag", "help pane/3/addr"); try expectRan(try pardes(a, exe, root, &.{ "help", "nowhere" }), 1, "is not a command, a builtin", "help nowhere"); const all = try pardes(a, exe, root, &.{ "help", "--all" }); -- cgit v1.3