summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/Core.zig6
-rw-r--r--core/replica.zig24
-rw-r--r--core/root.zig3
-rw-r--r--dev/Host.zig3
-rw-r--r--dev/tui/tui.zig12
-rw-r--r--runtime/upgrade.zig6
6 files changed, 33 insertions, 21 deletions
diff --git a/core/Core.zig b/core/Core.zig
index d5a990e2..fe05c5b4 100644
--- a/core/Core.zig
+++ b/core/Core.zig
@@ -72,7 +72,6 @@ const lsp = pardes.lsp;
const memory = pardes.memory;
const modal = pardes.modal;
const mouse = pardes.mouse;
-const newer_build_words = pardes.newer_build_words;
const platform = pardes.platform;
const recent_files = @import("recent.zig");
const sel_slot = pardes.sel_slot;
@@ -1704,10 +1703,7 @@ fn updateInner(p: *Pardes, ev: Event) void {
edit.applyPaste(p, bytes) catch |err| p.reportError(.at(v.active), "paste", err);
},
.command => |line| _ = p.executeBuiltinLine(v.active, line),
- .focus => |focused| {
- v.window_focused = focused;
- if (focused) if (p.host.vtable.newer_build) |f| if (f(p.host.ctx)) p.setMessage(.at(v.active), newer_build_words);
- },
+ .focus => |focused| v.window_focused = focused,
.handed => |h| p.handover.finish(p, h.seq, h.to, h.failure),
.addon => |a| pardes.Addon.landed(p, a.op, a.pane.index(), a.kind.*),
.job => |j| pardes.Kind.jobDone(p, j.pane.index(), j.serial, j.token, j.gen, j.bytes),
diff --git a/core/replica.zig b/core/replica.zig
index c68848f2..a13acada 100644
--- a/core/replica.zig
+++ b/core/replica.zig
@@ -5342,7 +5342,6 @@ const may_wait = [_]Wait{
.{ .what = "Dump", .on = .any, .stop = "write_dump", .why = "a dump written" },
.{ .what = "Upgrade", .on = .any, .stop = "upgrade", .why = "the session execs itself" },
.{ .what = "Detach", .on = .any, .stop = "detach", .why = "the session lets its frontend go" },
- .{ .what = "focus lost and found", .on = .any, .stop = "newer_build", .why = "a window found again asks whether a newer build is installed: the session's disk" },
// What the session alone holds: its closed panes, Recent and History
// (every session of its user writes them), the config and theme files.
.{ .what = "Restore", .on = .any, .stop = "the authority's own state", .why = "the session's dumps" },
@@ -5884,3 +5883,26 @@ test "an idle client's check answered covers the units that came while it was as
c.take(.{ .checked = digestOf(a) });
try std.testing.expect(!c.asked and c.changed);
}
+
+// A window's keyboard found again asked the session's host whether a newer
+// pardes is installed, in the core's focus step: a client's refocus waited
+// a round trip for a question about the session's binary that its own
+// window has nothing to do with. Each process's build is its own frontend's
+// to look at, at its own focus-in (upgrade.noticeNewer).
+test "a far client's window found again is instant: its refocus asks the session's host nothing, and the session's unit confirms it" {
+ const gpa = std.testing.allocator;
+ const a = try Authority.init(gpa, .{ .cols = 80, .rows = 24, .file = "mise.toml" }, FullHost.host(), false);
+ defer a.deinit();
+ const r = try joinedFresh(a);
+ defer r.deinit();
+ for ([_]bool{ false, true }) |focused| {
+ const msg = try gpa.dupe(u8, try r.input(.{ .focus = focused }));
+ defer gpa.free(msg);
+ try std.testing.expectEqual(@as(usize, 1), r.applied);
+ r.confirm(try a.take(msg));
+ r.settle();
+ try agrees(a, r);
+ }
+ try std.testing.expectEqual(@as(u32, 0), r.stats.stopped);
+ try std.testing.expectEqual(@as(u32, 2), r.stats.fast);
+}
diff --git a/core/root.zig b/core/root.zig
index 69ec3ded..f55d72c3 100644
--- a/core/root.zig
+++ b/core/root.zig
@@ -324,7 +324,8 @@ comptime {
}
}
-/// Said at a focus-in when the Host's `newer_build` answers yes (upgrade.zig).
+/// Said by a session's own frontend at its focus-in, when the build at the
+/// path it started from is not its own (upgrade.noticeNewer).
pub const newer_build_words = "a newer pardes is installed: Upgrade (SPC s U) moves this session onto it";
pub const Rect = layout.Rect;
diff --git a/dev/Host.zig b/dev/Host.zig
index 24df3895..a23c9ef5 100644
--- a/dev/Host.zig
+++ b/dev/Host.zig
@@ -28,9 +28,6 @@ pub const VTable = struct {
/// Upgrade: this process exec'd as the pardes installed since, at
/// the step's end (upgrade.zig); `pane` hears why if it cannot be.
upgrade: ?*const fn (ctx: ?*anyopaque, pane: pardes.Pane.Id) void = null,
- /// Whether a newer pardes is installed at the path this process
- /// started from, to be said once (upgrade.zig): asked at a focus-in.
- newer_build: ?*const fn (ctx: ?*anyopaque) bool = null,
spawn: ?*const fn (ctx: ?*anyopaque, pane: pardes.Pane.Id, cwd: []const u8) void = null,
pty_write: ?*const fn (ctx: ?*anyopaque, pane: pardes.Pane.Id, bytes: []const u8) void = null,
pty_resize: ?*const fn (ctx: ?*anyopaque, pane: pardes.Pane.Id, cols: u16, rows: u16) void = null,
diff --git a/dev/tui/tui.zig b/dev/tui/tui.zig
index 1f6b9a49..5ba31bd9 100644
--- a/dev/tui/tui.zig
+++ b/dev/tui/tui.zig
@@ -1274,7 +1274,6 @@ const Shell = struct {
.detach = detach,
.adopt = adopt,
.upgrade = upgradeAsked,
- .newer_build = newerBuild,
.spawn = spawn,
.pty_write = ptyWrite,
.pty_resize = ptyResize,
@@ -1392,12 +1391,6 @@ const Shell = struct {
s.adoptions.ask(s.core, pane);
}
- /// A client's own build is not the session's to say (its core's host
- /// is the session's, through the tape).
- fn newerBuild(ctx: ?*anyopaque) bool {
- return of(ctx).client == null and upgrade.newer();
- }
-
fn upgradeAsked(ctx: ?*anyopaque, id: pardes.Pane.Id) void {
const pane = id.index();
const s = of(ctx);
@@ -1739,7 +1732,10 @@ const Shell = struct {
c.link.gone = true;
return true;
},
- .focus_in => s.feed(.{ .focus = true }),
+ .focus_in => {
+ s.feed(.{ .focus = true });
+ if (s.client == null) upgrade.noticeNewer(s.core);
+ },
.focus_out => {
s.feed(.pointer_leave);
s.feed(.{ .focus = false });
diff --git a/runtime/upgrade.zig b/runtime/upgrade.zig
index 77928dd0..2a8d6edf 100644
--- a/runtime/upgrade.zig
+++ b/runtime/upgrade.zig
@@ -80,9 +80,9 @@ pub fn noticeNewer(core: *pardes.Pardes) void {
if (newer()) core.setMessage(.at(core.view().active), pardes.newer_build_words);
}
-/// Whether to say a newer build is installed now (`noticeNewer`): the
-/// tty's Host answers the core's focus step with it, so its replica
-/// clients take the line from the tape.
+/// Whether to say a newer build is installed now (`noticeNewer`): asked
+/// by a session's own frontend at its focus-in, between steps; the line is
+/// an input (setMessage) its replica clients take from the tape.
pub fn newer() bool {
const was = started_inode orelse return false;
const now = inodeOf(exe() orelse return false) orelse return false;