summaryrefslogtreecommitdiff
path: root/src/ninep/pty.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-28 10:49:56 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:14 -0300
commit68a74ec034a24c9b016497880e375f291498ae5f (patch)
tree968a3eeec731d3ea632ab98f872074863ec6183b /src/ninep/pty.zig
parent73e797e3f31eb52b0074b86cd16949c827b75670 (diff)
downloadpardes-68a74ec034a24c9b016497880e375f291498ae5f.tar.gz
pardes-68a74ec034a24c9b016497880e375f291498ae5f.zip
A terminal's new directory is a rename in the log, and its ctl counts its body
The log said new N / and later del N <cwd> for a terminal, with no rename in between, though a terminal is named by its directory. setCwd now logs the rename once the pane has been announced. A terminal's ctl line gave body length 0 while its body reads its history; it now counts that history (without keeping a copy). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/ninep/pty.zig')
-rw-r--r--src/ninep/pty.zig29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/ninep/pty.zig b/src/ninep/pty.zig
index 0a55df94..50d14624 100644
--- a/src/ninep/pty.zig
+++ b/src/ninep/pty.zig
@@ -849,6 +849,35 @@ test "a run's answer says cut when its output's start is gone, and reads a bound
try testing.expectEqualStrings("error out of memory\n", sh.answered(p, node, h, into));
}
+test "a terminal's ctl counts its body, and a new directory is a rename in the log" {
+ const gpa = testing.allocator;
+ const p = try withTerm(gpa);
+ defer p.deinit();
+ const serial = serialOf(p);
+ p.update(.{ .output = .{ .pane = 0, .bytes = "some history\r\nmore" } });
+ while (p.nextEffect()) |_| {}
+ const opened = call(p, .{ .tag = 1, .op = .open, .node = Node.of(serial, .body) });
+ const body_len = call(p, .{ .tag = 2, .op = .read, .node = Node.of(serial, .body), .handle = opened.reply.handle, .size = 1 << 16 }).bytes.len;
+ _ = call(p, .{ .tag = 3, .op = .release, .node = Node.of(serial, .body), .handle = opened.reply.handle });
+ try testing.expect(body_len > 0);
+ var fields = std.mem.tokenizeScalar(u8, rd(p, Node.of(serial, .ctl), 0, 4096).bytes, ' ');
+ _ = fields.next();
+ _ = fields.next();
+ try testing.expectEqual(body_len, try std.fmt.parseInt(usize, fields.next().?, 10));
+
+ const log = @intFromEnum(tree.TopFile.log);
+ const f = call(p, .{ .tag = 4, .op = .open, .node = log }).reply.handle;
+ const frozen = call(p, .{ .tag = 5, .op = .read, .node = log, .handle = f, .size = 1 << 16 }).bytes.len;
+ _ = call(p, .{ .tag = 6, .op = .write, .node = log, .handle = f, .data = "follow" });
+ p.setCwd(0, "/somewhere/else");
+ var want: [64]u8 = undefined;
+ try testing.expectEqualStrings(
+ try std.fmt.bufPrint(&want, "rename {d} /somewhere/else\n", .{serial}),
+ call(p, .{ .tag = 7, .op = .read, .node = log, .handle = f, .off = frozen, .size = 4096 }).bytes,
+ );
+ _ = call(p, .{ .tag = 8, .op = .release, .node = log, .handle = f });
+}
+
test "closing a terminal pane asks its shell to hang up the pty" {
const p = try withTerm(testing.allocator);
defer p.deinit();