summaryrefslogtreecommitdiff
path: root/src/pardes.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-10-30 15:19:25 -0300
committerGabriel Schneider <[email protected]>2026-10-30 17:03:40 -0300
commitf2ede98aee0265e3506f5afd6039c70be7812767 (patch)
tree284a64fc9fcf7ba777a20fad75cc6295d70695fb /src/pardes.zig
parent08c9415dde1a1d5da2c20124c4fcd4c92783b290 (diff)
downloadpardes-f2ede98aee0265e3506f5afd6039c70be7812767.tar.gz
pardes-f2ede98aee0265e3506f5afd6039c70be7812767.zip
remote clients: a pointer's hit carries the place it was made on (Layer.Place, on the wire, version 17) and a step resolves it from that, never from this process's frame (`surface`, `.local`), which a session never draws for a client: a window's pointer over a tag diverged it at once (the user's `tape byte 119`, 15 rejoins in 25 s) and a click there aborted it; a replay that meets a site its tape lacks, or makes a syscall that is none, is a divergence that goes on harmless (poisonOf), not a panic, and a speculation that makes one waits (Tty's shell lookup, untaped, is a value site now, as Shell's was); a copy over a queue is refused, not asserted; a session's last client, while no one else watches it, leaves it its layout (leaveView, settled as closeView is), which its rejoin copies; a redial waits only after an Upgrade's `refused` (a divergence's redialled a gone session 20 s); a dying session shuts its clients' links before its trace, and an --attach client ends its ssh and socket whatever way it exits; a far join's hashing stops at a blob once its client is let go (its leave waits for it in the step); a confirmed speculation's state is checked against its unit's digest, and the trace gives a key's and a pointer's words; test/daemon.py: 200 far joins level, a window's pointer swept over tags and body, ssh stand-in clients refused and detached, a client of a killed session ending in 2 s; in-process tests for each
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/pardes.zig')
-rw-r--r--src/pardes.zig46
1 files changed, 28 insertions, 18 deletions
diff --git a/src/pardes.zig b/src/pardes.zig
index 5b37342e..189a5b02 100644
--- a/src/pardes.zig
+++ b/src/pardes.zig
@@ -172,8 +172,10 @@ pub const Turn = struct {
/// a step. Nests: a directory listing that resolves each entry yields
/// inside a yield, and only the outermost one lets go.
pub fn yield(t: *Turn) void {
- // A replica makes no syscall: each is a site of the tape's.
- if (tape.replaying()) @panic("tape: a syscall that is no tape site, made replaying");
+ // A replica makes no syscall: each is a site of the tape's. One that
+ // is none stops a speculation and diverges a replay (it joins
+ // again), never the process (a window client's `Tty fish`, H17).
+ if (tape.replaying()) tape.stray();
const io = t.io orelse return;
yield_depth += 1;
if (yield_depth != 1) return;
@@ -478,6 +480,7 @@ pub const Loc = struct {
test {
_ = @import("rollback.zig");
+ _ = @import("tape.zig");
_ = @import("replica.zig");
_ = @import("echo.zig");
_ = @import("modal.zig");
@@ -3595,6 +3598,7 @@ pub const Mouse = struct {
pixel_x: f32,
pixel_y: f32,
metrics: RowMetrics,
+ place: Layer.Place = .{},
};
// sel indexing relies on left/middle/right being 0/1/2
pub const Button = enum { left, middle, right, wheel_up, wheel_down, wheel_left, wheel_right, none, back, forward };
@@ -5692,6 +5696,17 @@ pub const Pardes = struct {
p.settle();
}
+ /// The last client of a session no one else watches gone: its view
+ /// goes, and the session's own is laid out as it was (views.closeKeeping),
+ /// which the client's rejoin copies. Settled as `closeView` is.
+ pub fn leaveView(p: *Pardes, k: u8) void {
+ const taped = tape.enter(p, .{ .leave_view = k });
+ defer tape.leave(p, taped);
+ views.closeKeeping(p, k);
+ p.sync();
+ p.settle();
+ }
+
/// Into view `k`, before the input its client sent.
pub fn toView(p: *Pardes, k: u8) void {
if (k == p.view) return;
@@ -8176,18 +8191,16 @@ pub const Pardes = struct {
return p.haptic;
}
+ /// A frontend's tag hit, if what it names is still there: resolved on
+ /// the place it carries (Layer.Place), not on this process's frame.
pub fn reprojectTagHit(p: *const Pardes, tag_hit: TagHit) ?TagHit {
- for (p.surface.tagLayers()) |*layer| {
- if (layer.rows == 0 or layer.kind != tag_hit.kind or layer.id != tag_hit.id or layer.serial != tag_hit.serial) continue;
- if (layer.kind == .pane) {
- if (layer.id >= p.panes.len) return null;
- const pane = p.panes[layer.id] orelse return null;
- if (pane.serial != layer.serial) return null;
- }
- if (layer.kind == .column and (layer.id >= p.ncol or p.col_serial[layer.id] != layer.serial)) return null;
- return layer.tagHit(tag_hit.pixel_x, tag_hit.pixel_y, @floatFromInt(tag_hit.metrics.body_w), @floatFromInt(tag_hit.metrics.body_h), @floatFromInt(tag_hit.metrics.tagline_w), @floatFromInt(tag_hit.metrics.tagline_h)) orelse continue;
+ if (tag_hit.kind == .pane) {
+ if (tag_hit.id >= p.panes.len) return null;
+ const pane = p.panes[tag_hit.id] orelse return null;
+ if (pane.serial != tag_hit.serial) return null;
}
- return null;
+ if (tag_hit.kind == .column and (tag_hit.id >= p.ncol or p.col_serial[tag_hit.id] != tag_hit.serial)) return null;
+ return Layer.tagAgain(tag_hit);
}
/// The pane's first body row: under the tag when it is on top, over it
@@ -8207,12 +8220,9 @@ pub const Pardes = struct {
return layer.capacity(p.row_metrics);
}
- pub fn reprojectBodyHit(p: *const Pardes, body_hit: Mouse.BodyHit) ?Mouse.BodyHit {
- for (&p.surface.body_layers) |*layer| {
- if (layer.rows == 0 or layer.serial != body_hit.serial) continue;
- return layer.bodyHit(body_hit.pixel_x, body_hit.pixel_y, @floatFromInt(body_hit.metrics.body_w), @floatFromInt(body_hit.metrics.body_h), @floatFromInt(body_hit.metrics.tagline_w), @floatFromInt(body_hit.metrics.tagline_h));
- }
- return null;
+ /// A frontend's body hit, resolved on the place it carries.
+ pub fn reprojectBodyHit(_: *const Pardes, body_hit: Mouse.BodyHit) ?Mouse.BodyHit {
+ return Layer.bodyAgain(body_hit);
}
// ---- render: build the canonical surface (draw.zig) ----