From ddcfd860ef05c37f5536038d8828cc81c0c4125c Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 29 Oct 2026 22:18:34 -0300 Subject: upgrade: the Upgrade word (SPC s U, a tag, 9P) moves a running session onto the pardes installed where it started, in place, by exec at a step boundary: its dump in the DumpDir, its pty masters, terminals, stubs and daemon link kept open and named on the new command line, every view and running shell its own again; the daemon re-execs too, its registry on its command line; a build that cannot load the dump falls back to the old binary, or starts afresh with the shells adopted and the dump kept (test/daemon.py --upgrade, --upgrade --gui) Co-Authored-By: Claude Opus 5.5 --- src/builtins.zig | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/builtins.zig') diff --git a/src/builtins.zig b/src/builtins.zig index 0ad59fd4..1dc428da 100644 --- a/src/builtins.zig +++ b/src/builtins.zig @@ -762,6 +762,19 @@ pub const Adopt = struct { } }; +/// Move this session onto the pardes installed since it started, in place: +/// its text, undo, views, terminals with their running shells, and its +/// terminals and windows come along. The pardes daemon moves too. +pub const Upgrade = struct { + pub const scope: Scope = .session; + pub const enabled = pardes.can_attach; + pub fn run(c: Ctx) void { + if (comptime !enabled) unreachable; + const upgrade = c.p.host.vtable.upgrade orelse return c.p.reportFailure(c.id, "Upgrade: this pardes cannot move to another build in place"); + upgrade(c.p.host.ctx, @intCast(c.id)); + } +}; + /// Mount another pardes's 9P tree under /n/, given its dial address. pub const Mount = struct { pub const scope: Scope = .session; -- cgit v1.3