From 236c9f51134adf04932f7653ed0262a0c9253708 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 4 Nov 2026 23:04:43 -0300 Subject: replica: a client's join, the terminal's and the window's alike, is replica.join (the session dialled, its build checked, its dump loaded and checked, or joined again for its view once its link ends, the core it leaves held meanwhile), where tui.zig and gui.zig each spelled out the dial, the check, the load, the redial and their timing; Link.reset takes the join, and Link.load, Link.joinedAs and Link.redial go Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- src/gui/gui.zig | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) (limited to 'src/gui/gui.zig') diff --git a/src/gui/gui.zig b/src/gui/gui.zig index a850cdca..3800c794 100644 --- a/src/gui/gui.zig +++ b/src/gui/gui.zig @@ -25,7 +25,6 @@ const ninep_io = @import("../9p_io.zig"); const daemon = @import("../daemon.zig"); const upgrade = @import("../upgrade.zig"); const replica = @import("../replica.zig"); -const wire = @import("../detached/wire.zig"); const tracy = @import("../tracy.zig"); pub const c = @import("gui_c"); // SDL3 and font.h, translated by build.zig @@ -2343,10 +2342,6 @@ fn remoteSession(init: std.process.Init, g: *Gui, opts_in: pardes.Options, test_ var have_store: replica.Have = if (far) .init(io) else .{ .io = io }; defer have_store.deinit(); const have: ?*replica.Have = if (far) &have_store else null; - var dial_t0 = std.Io.Clock.awake.now(io).nanoseconds; - var joined = replica.dial(gpa, to.path, to.session, &why, have, null) orelse Said.no(io, "{s}", .{std.mem.sliceTo(&why, 0)}); - if (joined.semantics != wire.semantics) Said.no(io, "{s}", .{replica.Link.upgrade_words}); - const allocs = pardes.memory.init(gpa); defer pardes.memory.deinit(); pardes.image.start(io, allocs.image); @@ -2360,8 +2355,8 @@ fn remoteSession(init: std.process.Init, g: *Gui, opts_in: pardes.Options, test_ var o = opts_in; o.image_allocator = allocs.image; o.pdf_allocator = allocs.pdf; - var r = replica.Link.load(gpa, &joined, o, &why, have) orelse Said.no(io, "{s}", .{std.mem.sliceTo(&why, 0)}); - var dial_ms: u64 = @intCast(@divTrunc(std.Io.Clock.awake.now(io).nanoseconds - dial_t0, std.time.ns_per_ms)); + var joined: replica.Joined = undefined; + var r = replica.join(gpa, &joined, to.path, to.session, o, have, &why, null) orelse Said.no(io, "{s}", .{std.mem.sliceTo(&why, 0)}); var client: Client = .{ .link = .{ .r = r, .fd = joined.fd }, .io = io, .gpa = gpa, .texts = .init(gpa) }; defer client.deinit(); @@ -2401,15 +2396,13 @@ fn remoteSession(init: std.process.Init, g: *Gui, opts_in: pardes.Options, test_ // A join a pass: the first, and one after the replica diverged or the // session let it go to upgrade. The window stays as it is. while (true) { - r.gmtoff = joined.gmtoff; const core = r.core(); shell.core = core; shell.gview = joined.view; shell.surface = null; g.hit_core = core; frame_probe = &core.frames; - link.reset(r, joined.fd); - link.joinedAs(&joined, dial_ms); + link.reset(r, &joined); client.ended = false; // ponytail: why it joined again is the window's title (and its // log) until a key, where a terminal's client draws it over its @@ -2491,13 +2484,7 @@ fn remoteSession(init: std.process.Init, g: *Gui, opts_in: pardes.Options, test_ return; } // The session again, the core it leaves held meanwhile. - if (have) |h| h.leaving(r.core()); - dial_t0 = std.Io.Clock.awake.now(io).nanoseconds; - joined = replica.Link.redial(gpa, to.path, to.session, &why, have, r.diverged == null, joined.view) orelse Said.no(io, "could not join again: {s}", .{std.mem.sliceTo(&why, 0)}); - if (have) |h| h.left(); - r.deinit(); - r = replica.Link.load(gpa, &joined, o, &why, have) orelse Said.no(io, "{s}", .{std.mem.sliceTo(&why, 0)}); - dial_ms = @intCast(@divTrunc(std.Io.Clock.awake.now(io).nanoseconds - dial_t0, std.time.ns_per_ms)); + r = replica.join(gpa, &joined, to.path, to.session, o, have, &why, r) orelse Said.no(io, "{s}", .{std.mem.sliceTo(&why, 0)}); } } -- cgit v1.3