diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-25 15:05:16 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-25 15:08:19 -0300 |
| commit | 4e5f978f90db55092420a5f5f8f06fff0a5f3d07 (patch) | |
| tree | c857eea0e1dbaadecd68905ce8e7d824ab44639c | |
| parent | e77e2b16927f1cd55fa2edde44bb591c6197b2c5 (diff) | |
| parent | 2e98333b8d4ae7302eb53d7f6b0c667f371adcc5 (diff) | |
| download | pardes-4e5f978f90db55092420a5f5f8f06fff0a5f3d07.tar.gz pardes-4e5f978f90db55092420a5f5f8f06fff0a5f3d07.zip | |
walk UI M12: D1's four changes (xtvnwlpo an Edit's change holds the reading pane it changes, Trail.edited after its File.load; tqswwxlu test/daemon.py's plain row under the walk default; vlkqvktp a newer build installed is said of no pane; owxmwxxn 2e98333b8d4a the no-build-could-load outcome an error of no pane, and the upgrade row reading what the walk UI draws) merged onto M11 and the Band fix (ovooknov), resolved by meaning: no text conflict and no file in common (D1: core/edit_cmd.zig, runtime/upgrade.zig, test/daemon.py; the rest of the line touches none of them), and none reads what another stack changed: D1's rows read the notice row as F2 left it only through the session's /log and the row's lead mark, which F2's give-way keeps (a row that fits is built byte for byte as before; a cut one keeps its mark and its words before its cause's path); core-test 1108/1279 (171 skipped: 1106 + D1's two), load 1.6 to 4
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBFhdevVu48bvL9kCE
| -rw-r--r-- | core/edit_cmd.zig | 30 | ||||
| -rw-r--r-- | runtime/upgrade.zig | 55 | ||||
| -rw-r--r-- | test/daemon.py | 46 |
3 files changed, 112 insertions, 19 deletions
diff --git a/core/edit_cmd.zig b/core/edit_cmd.zig index 8fbde726..7efa98bc 100644 --- a/core/edit_cmd.zig +++ b/core/edit_cmd.zig @@ -417,6 +417,10 @@ fn commit(p: *Pardes, pd: *Pending, outputs: []const []const u8) void { return p.reportError(.at(at), "Edit", err); }; panes.File.load(p, pf, new); + // An edit, though made as a new text: a reading pane it + // changes is held (pick-ui SPEC §6.5), or a jump from it + // would step it off its unsaved text. + pardes.Trail.edited(p, pf); } } if (ops.len > 0 or f.moved) ninep_pane.setFileDot(p.settings.tab, pane, sam.moveDot(f.dot, ops)); @@ -803,3 +807,29 @@ test "e and r say a file that cannot be read as Get says it" { try testing.expect(std.mem.indexOf(u8, r.reply.ename, c[1]) != null); } } + +test "an Edit's change holds the reading pane it changes, as a typed one does: a Look from it after opens its reader, and the change stays in it" { + var tmp = testing.tmpDir(.{}); + defer tmp.cleanup(); + try tmp.dir.writeFile(testing.io, .{ .sub_path = "notes.txt", .data = "one\ntwo\nthree\n" }); + try tmp.dir.writeFile(testing.io, .{ .sub_path = "big.txt", .data = "big\n" }); + var dir_buf: [4096]u8 = undefined; + const dir = dir_buf[0..try tmp.dir.realPath(testing.io, &dir_buf)]; + const p = try th.withFile(testing.allocator, "scratch\n"); + defer p.deinit(); + p.settings.jumps = .walk; + var path: [4200]u8 = undefined; + // The notes in a reading pane (the first walked to them). + look.lookAt(p, 0, try std.fmt.bufPrint(&path, "{s}/notes.txt", .{dir})); + const notes = p.view().active; + try testing.expect(pardes.Trail.reading(p, p.panes[notes].?)); + try testing.expectEqual(tree.Status.ok, th.wr(p, tree.Node.of(p.panes[notes].?.serial, .ctl), "Edit 3a/ an edit/\n").reply.status); + try testing.expectEqualStrings("one\ntwo\nthree\n an edit", p.panes[notes].?.file.?.content); + try testing.expect(!pardes.Trail.reading(p, p.panes[notes].?)); + // A Look from it: its reader, under it; the notes and their change kept. + look.lookAt(p, notes, try std.fmt.bufPrint(&path, "{s}/big.txt", .{dir})); + const reader = p.view().active; + try testing.expect(reader != notes); + try testing.expectEqualStrings("big.txt", std.Io.Dir.path.basename(p.panes[reader].?.file.?.path)); + try testing.expectEqualStrings("one\ntwo\nthree\n an edit", p.panes[notes].?.file.?.content); +} diff --git a/runtime/upgrade.zig b/runtime/upgrade.zig index 62f49ffa..ca788cfc 100644 --- a/runtime/upgrade.zig +++ b/runtime/upgrade.zig @@ -89,10 +89,12 @@ fn inodeOf(path: [:0]const u8) ?u64 { /// A newer build installed at that path since this process started, said /// in a line, once a build: asked at a focus-in, where one comes back from -/// rebuilding (a stat). ponytail: explicit only, no watch and no automatic -/// upgrade. +/// rebuilding (a stat). Of no pane, as the Upgrade's outcome is: a pane's +/// message names its cause first (pick-ui SPEC §10.1), and the focused +/// file's path is not this one's. ponytail: explicit only, no watch and +/// no automatic upgrade. pub fn noticeNewer(core: *pardes.Pardes) void { - if (newer()) core.setMessage(.at(core.view().active), pardes.newer_build_words); + if (newer()) core.setMessage(.at(pardes.MAX_PANES), pardes.newer_build_words); } /// Whether to say a newer build is installed now (`noticeNewer`): asked @@ -474,7 +476,10 @@ pub fn load(gpa: std.mem.Allocator, core_gpa: std.mem.Allocator, opts: pardes.Op var o = opts; o.load_path = null; const p = try pardes.Pardes.init(core_gpa, o); - p.setMessage(.at(p.view().active), std.fmt.bufPrint(&buf, "Upgrade: no build could load the session ({s}); its shells are here, and Restore {s} brings the rest back", .{ why, again_name[0..@min(again_name.len, 400)] }) catch "Upgrade: no build could load the session; its dump is kept for a Restore"); + // An error, of no pane (tellEveryView): a notice would be retired at + // once by the fresh session's first word's echo (its shell's + // `Term`), and its Restore never read on the notice row. + _ = pardes.Messages.say(p, .@"error", pardes.MAX_PANES, std.fmt.bufPrint(&buf, "Upgrade: no build could load the session ({s}); its shells are here, and Restore {s} brings the rest back", .{ why, again_name[0..@min(again_name.len, 400)] }) catch "Upgrade: no build could load the session; its dump is kept for a Restore"); return p; } } @@ -621,7 +626,7 @@ test "an upgrade from the build before reads the dump file its record names, and try std.testing.expectError(error.FileNotFound, tmp.dir.statFile(std.testing.io, "pardes-upgrade-1.dump", .{})); } -test "an older build's dump named by a path past 4096 bytes is refused in words and kept for a Restore" { +test "an older build's dump named by a path past 4096 bytes is refused in words and kept for a Restore: an error of no pane, which the fresh session's first word's echo leaves on the notice row" { const gpa = std.testing.allocator; var text_buf: [4200]u8 = undefined; var long: [4096]u8 = undefined; @@ -631,6 +636,42 @@ test "an older build's dump named by a path past 4096 bytes is refused in words const q = try load(gpa, gpa, .{ .tty_only = true }, &rec); defer q.deinit(); try std.testing.expect(rec.fresh); - const pane = q.panes[q.view().active].?; - try std.testing.expect(std.mem.indexOf(u8, q.messages.saidBy(pane), "Upgrade: no build could load the session") != null); + // The fresh session's first word (its shell's pane, `Term`) announced, + // an echo, as its host does at its start (exec.zig). + _ = pardes.Messages.say(q, .echo, q.view().active, "Term"); + const said = q.messages.headline() orelse return error.NothingSaid; + try std.testing.expect(std.mem.startsWith(u8, said.words(), "Upgrade: no build could load the session")); + try std.testing.expectEqual(pardes.Messages.Kind.@"error", said.kind); + try std.testing.expectEqual(@as(usize, 0), said.src.len); +} + +test "a newer build installed is said on the notice row in its own words, of no pane: the focused file's path is not its cause" { + const gpa = std.testing.allocator; + const p = try pardes.Pardes.init(gpa, .{ .tty_only = true }); + defer p.deinit(); + const pane = try p.setTestFile("one\ntwo\n"); + // The focused file at a path as long as a session's scratch file's. + gpa.free(pane.file.?.path); + pane.file.?.path = try gpa.dupe(u8, "/home/someone/projects/a-rather-long-directory/of-the-session/notes-of-the-week.txt"); + // A build installed at the start path since: another file there. + var tmp = std.testing.tmpDir(.{}); + defer tmp.cleanup(); + try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "pardes", .data = "a newer build" }); + exe_len = try tmp.dir.realPathFile(std.testing.io, "pardes", &exe_buf); + exe_buf[exe_len] = 0; + started_inode = inodeOf(exe().?).? +% 1; + defer { + exe_len = 0; + started_inode = null; + told_inode = null; + } + noticeNewer(p); + const said = p.messages.headline() orelse return error.NothingSaid; + try std.testing.expectEqualStrings(pardes.newer_build_words, said.words()); + try std.testing.expectEqual(@as(u32, 0), said.pane); + try std.testing.expectEqual(@as(usize, 0), said.src.len); + // An 80-column terminal's notice row leads with its words. + var row_buf: [pardes.Messages.notice_row_cap]u8 = undefined; + const row = pardes.Messages.noticeRow(p, 80, &row_buf); + try std.testing.expect(std.mem.startsWith(u8, row.text, "\u{b7} a newer pardes is installed")); } diff --git a/test/daemon.py b/test/daemon.py index f9cbc9e1..3dfb0710 100644 --- a/test/daemon.py +++ b/test/daemon.py @@ -781,8 +781,13 @@ def pair(binary): nine2, session2 = session_of('lone') wait_for('the lone pair drawn', lambda: b'line 3 of the notes' in lone.text(), timeout=30) # An Upgrade refused, with why: its client could not find it again. + # Said (the session's /log, its history) and shown: an error, the + # notice row's lead (pick-ui SPEC §10.3), whose words come after + # its cause, the asking pane's file, cut on the right in 80 columns + # behind the test's long path. nine2.write('/ctl', b'Upgrade\n') - wait_for('the Upgrade refused', lambda: 'its client could not join it again' in screen_text(nine2), timeout=20) + wait_for('the Upgrade refused', lambda: b'its client could not join it again' in nine2.read('/log'), timeout=20) + wait_for('the refusal on the notice row', lambda: screen_text(nine2).splitlines()[-1].lstrip().startswith('\u2717 '), timeout=20) assert alive(session2) and c2.poll() is None nine2.socket.close() os.kill(c2.pid, signal.SIGKILL) @@ -2622,8 +2627,12 @@ def far(binary): wait_for('the session\'s 9P socket', (root / 'pardes-9p-files.sock').exists) nine = Client(root / 'pardes-9p-files.sock') pane = next(int(row.split()[0]) for row in nine.read('/index').splitlines() if row.split()[1] == b'text') - nine.write(f'/pane/{pane}/exec', f'Look {big}\n'.encode()) + # The notes edited first: a held pane (pick-ui SPEC §6.1, `jumps + # walk` the default), whose Look opens the big file in a pane of its + # own (its reader) and keeps the notes, which the clients type into; + # a reading pane's would step it to the big file in place. nine.write(f'/pane/{pane}/exec', b'Edit 3a/ an edit the session made /\n') + nine.write(f'/pane/{pane}/exec', f'Look {big}\n'.encode()) # A: the first, its cache empty: every blob sent, and kept. ta, a = client('a') typed('a', ta, b'from-A') @@ -2864,14 +2873,14 @@ def by_hash(binary): f.write(b'%08d %s\n' % (i, os.urandom(27).hex().encode()[:54])) started, terms = [], [] - def client(name, far): + def client(name, far, shown=b'line 3 of the notes'): t = Term(24, 90) terms.append(t) c = t.spawn([binary, f'--attach={root / "pardes-replica.sock"}:files'], dict(env, PARDES_REPLICA_CHECK=str(root / f'{name}.check'), PARDES_REPLICA_STATS=str(root / f'{name}.stats'), **({'PARDES_REPLICA_FAR': '1'} if far else {}))) started.append(c.pid) - wait_for(f'client {name}\'s first frame', lambda: b'line 3 of the notes' in t.text(), timeout=30) + wait_for(f'client {name}\'s first frame', lambda: shown in t.text(), timeout=30) time.sleep(.3) return t, c @@ -2901,7 +2910,10 @@ def by_hash(binary): got = {c.pid: read(c.pid) - was[c.pid] for c in (a, f)} assert size <= got[a.pid] < size + (512 << 10), (size, got) assert got[f.pid] < size, (size, got) - tg, g = client('g', True) + # The Look walked the notes' pane, a reading one, to the big file + # (pick-ui SPEC §6.1, `jumps walk` the default): G's first frame + # is the big file's. + tg, g = client('g', True, b'00000002 ') os.write(tg.master, b' sD') wait_for('client G let go', lambda: g.poll() is not None, timeout=20) g_join = joins(root / 'g.stats')[0] @@ -4034,6 +4046,10 @@ def upgrades(old, new): client = reconnect(sock) took = time.monotonic() - t assert int(dict(line.split(maxsplit=1) for line in client.read('/status').decode().splitlines())['pid']) == session + # The word said on the notice row (pick-ui SPEC §10.3) until the + # next message: looked for before the test says any (the Undo's + # echo below retires it, §10.1). + wait_for('the word said', lambda: 'Upgrade: now pardes' in screen_text(client)) if procfs: wait_for('the daemon on the new build', lambda: exe_of(daemon) == (str(binary), True)) else: @@ -4099,7 +4115,6 @@ def upgrades(old, new): (stub2.poll() is not None and (b'detached from' in term2.text() or b'upgrade this client too' in term2.text() or b'run the same pardes at both ends' in term2.text())), timeout=30) - wait_for('the word said', lambda: 'Upgrade: now pardes' in screen_text(client)) # Two clients' views kept at the Upgrade, with the time (views.away), # whose clients never come back (the raw replica, the old build's): # each its client's for 30 s, and the session's views all taken. @@ -4159,7 +4174,9 @@ def upgrades(old, new): t0 = time.monotonic() client.write(f'/pane/{shell}/exec', b'Upgrade\n') client.socket.close() - client = saying(sock, 'it goes on as') + # The outcome's words as the notice row shows a long message: + # its start, cut on the right with `…` (pick-ui SPEC §10.3). + client = saying(sock, 'could not load this session') back = time.monotonic() - t0 joined = {} @@ -4174,10 +4191,15 @@ def upgrades(old, new): raise TimeoutError(f'the client joined again: not {[c.stem for _, c in owners if c not in joined]} ' f'{time.monotonic() - t0:.1f} s after the Upgrade, the session back at {back:.1f} s') from None assert again.poll() is None and again5.poll() is None - # The session's news: each client's own screen says it (a long - # message shows its end), not only the view whose input came - # last before the Upgrade's step. - wait_for("each client's own screen saying the Upgrade's outcome", lambda: all(b'it goes on as' in t.text() for t, _ in owners), timeout=15) + # The session's news: each client's own screen says it, not only + # the view whose input came last before the Upgrade's step: on + # its notice row (pick-ui SPEC §10.3; a long message shows its + # start), once a key of its own has put away the client's own + # word drawn over that row (`joined again: ...`, tui.zig + # noticeLine; replica.zig Link.input). + for t, check in owners: + made_live(t, check) + wait_for("each client's own screen saying the Upgrade's outcome", lambda: all(b'could not load this session' in t.text() for t, _ in owners), timeout=15) for (t, check), pane, theirs in zip(owners, mine, reversed(mine)): in_own_view('its own view again', lambda: made_live(t, check), client, pane, theirs) for c, t in ((again, term4), (again5, term5)): @@ -4196,7 +4218,7 @@ def upgrades(old, new): refusing('all') client.write(f'/pane/{shell}/exec', b'Upgrade\n') client.socket.close() - client = saying(sock, 'brings the rest back') + client = saying(sock, 'no build could load the session') # The dump stays in the state file, under its label (a second # upgrade of one pid is `upgrade-<pid>-2`). kept = client.read('/dumps').decode() |
