summaryrefslogtreecommitdiff
path: root/src/replica.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-10-30 16:52:24 -0300
committerGabriel Schneider <[email protected]>2026-10-30 17:40:51 -0300
commit5925ddbe1aa39a64b484b68a8ddb3649b3d180e4 (patch)
tree487fad3a79d3efa2d2a3a8fd236c083f42171447 /src/replica.zig
parentd92ea9dfdd9198b69bff420c3b594f0ffed1e1bb (diff)
downloadpardes-5925ddbe1aa39a64b484b68a8ddb3649b3d180e4.tar.gz
pardes-5925ddbe1aa39a64b484b68a8ddb3649b3d180e4.zip
Adopt and a terminal reader's failure are inputs (Pardes.adoptShell, readerFailed; tape.Input adopt_shell, reader_failed): tty.zig's and gui.zig's adoptShell ran the Tty word and cleared the pane's greeting straight on the core, and the window's reader failure set its pane's mode, between steps and untaped, so every client of a session that took in a dead session's shells joined again (the hunt's H15: `the unit of 0/48 diverged: the core called poll_frame where the tape has a host (10)`, gone after); replica.zig's test, which the old writes fail
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/replica.zig')
-rw-r--r--src/replica.zig27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/replica.zig b/src/replica.zig
index 2af32cdb..6a01ec26 100644
--- a/src/replica.zig
+++ b/src/replica.zig
@@ -3205,6 +3205,33 @@ test "a replica joined from the session's dump replays the units after it" {
try std.testing.expectEqual(digestOf(a), r.digest());
}
+test "a host's Adopt and a terminal reader's failure are inputs: a replica makes the same pane" {
+ const gpa = std.testing.allocator;
+ // Its terminals as screen state, as a session's for its clients are.
+ const a = try Authority.init(gpa, .{ .cols = 80, .rows = 24, .file = "mise.toml" }, TestHost.host(), true);
+ defer a.deinit();
+ const was = Stepping.begin(&a.t, null);
+ const bytes = try pardes.dump.dumpBytes(a.core);
+ tape.resync(&a.t);
+ was.end();
+ defer a.core.gpa.free(bytes);
+ const r = try Replica.initDump(gpa, 1, 0, bytes, .{ .cols = 80, .rows = 24 });
+ defer r.deinit();
+ // What tty.zig's and gui.zig's adoptShell and a failed reader do between
+ // steps: they wrote the core straight, and every client joined again.
+ const host = Stepping.begin(&a.t, null);
+ const id = a.core.adoptShell().?;
+ try std.testing.expect(a.core.panes[id].?.isTerminal() and !a.core.panes[id].?.greet);
+ a.core.readerFailed(id, error.InputOutput);
+ a.core.pump(a.host) catch {};
+ host.end();
+ a.seq += 1;
+ r.confirm(try a.unit(0, a.seq));
+ if (r.diverged) |why| std.debug.print("diverged: {s}\n", .{why});
+ try std.testing.expect(r.diverged == null);
+ try std.testing.expectEqual(digestOf(a), r.digest());
+}
+
test "a join's dump, its blobs put back where they go, is the session's dump" {
const gpa = std.testing.allocator;
const a = try Authority.init(gpa, .{ .cols = 80, .rows = 24, .file = "mise.toml" }, TestHost.host(), false);