summaryrefslogtreecommitdiff
path: root/src/replica.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-18 07:09:32 -0300
committerGabriel Schneider <[email protected]>2026-11-18 07:09:32 -0300
commitf0e6eb0de0b5ac9f81ba2c728f3040c4a51ab284 (patch)
treee2660cddde27b7dc03240e6c56ceefad1ffc35fe /src/replica.zig
parent3350156db428656fa8e583d1971663e1c4a215b0 (diff)
downloadpardes-f0e6eb0de0b5ac9f81ba2c728f3040c4a51ab284.tar.gz
pardes-f0e6eb0de0b5ac9f81ba2c728f3040c4a51ab284.zip
kinds: a kind's job tokens are the session's on every core, a client's plain kind keeps no job's input, and a PDF render's pixels go with the document they are of: Slot.tokens is dumped and digested (a client joined later numbers its next job as the session does; a Shadow takes it from the call's outcome), api.job on a replica gives the token alone (it runs no job, so its four input slots filled and it refused the fifth while the session asked on), and a render's answer names its document, so one that lands after its pane opened its file again (changed on disk) no longer frees pixels the old document freed with it (a double free, ABRT in the new behaviour test without the fix); kitty-harness's panic placed: the base's (the harness panics before its first line when NO_COLOR is in its environment, as zig build gives it; run by hand without it, it passes on the base and on this tree); tui core-test 820/959 (139 skipped), shell-test 994/997, behaviour-test 274/274 and --replay 0 failures, pane-test 180/181, addon-test 1/1, replicas pass (checked/wrong 0)
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'src/replica.zig')
-rw-r--r--src/replica.zig37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/replica.zig b/src/replica.zig
index b1b0514c..d10cdf83 100644
--- a/src/replica.zig
+++ b/src/replica.zig
@@ -4473,6 +4473,43 @@ test "a kind's place moved in a step of another view's: a replica's key that rea
try agrees(a, r);
}
+/// A kind whose every key asks a job, for the job tokens' test.
+const Jobber = struct {
+ const pa = pardes.Kind.c;
+ fn open(_: [*c]const u8, _: [*c]const u8, _: u64) callconv(.c) ?*anyopaque {
+ return pardes.Kind.api.alloc.?(4);
+ }
+ fn paint(_: ?*anyopaque, _: [*c]const pa.pa_window, _: [*c]pa.pa_paint) callconv(.c) void {}
+ fn press(_: ?*anyopaque, _: [*c]const pa.pa_key) callconv(.c) c_int {
+ _ = pardes.Kind.api.job.?(null, 0);
+ return 1;
+ }
+ const words = [_]pa.pa_word{std.mem.zeroInit(pa.pa_word, .{ .name = "Jobber", .opens = 1, .doc = "a key a job" })};
+ const ops = std.mem.zeroInit(pardes.Kind.Ops, .{
+ .head = std.mem.zeroInit(pa.pa_head, .{ .size = @sizeOf(pa.pa_head), .abi = pardes.Kind.abi, .name = "jobber".* ++ @as([10]u8, @splat(0)), .version = 1, .exts = "", .words = &words, .nwords = 1 }),
+ .open = open,
+ .paint = paint,
+ .key = press,
+ });
+};
+
+test "a client joined from a dump numbers a kind's next job as the session does" {
+ const gpa = std.testing.allocator;
+ const a = try Authority.init(gpa, .{ .cols = 80, .rows = 24, .file = "mise.toml" }, TestHost.host(), false);
+ defer a.deinit();
+ var words: [64]pardes.Kind.LoadedWord = undefined;
+ const jobber = pardes.Kind.loadedOf(&Jobber.ops, "/x/jobber.so", @splat(7), &words);
+ _ = try a.local(.{ .addon = .{ .op = .load, .pane = 0, .kind = &jobber } });
+ _ = try a.local(.{ .command = "Jobber" });
+ for (0..3) |_| _ = try a.local(.{ .key = .{ .cp = 'x', .text = "x" } });
+ const id = a.core.view().active;
+ try std.testing.expectEqual(@as(u32, 3), a.core.panes[id].?.addon.?.tokens);
+ const joiner = try joinedNow(a, 2, 1);
+ defer joiner.deinit();
+ try std.testing.expectEqual(@as(u32, 3), joiner.core().panes[id].?.addon.?.tokens);
+ try std.testing.expectEqual(digestOf(a), joiner.digest());
+}
+
test "a replica's word that opens a kind's pane with no file waits for the authority's open: never mispredicted" {
const gpa = std.testing.allocator;
const a = try Authority.init(gpa, .{ .cols = 80, .rows = 24, .file = "mise.toml" }, TestHost.host(), false);