From e50c1b3fc928bf860bc6e91b0a2fea469f7e41e7 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 5 Nov 2026 00:53:40 -0300 Subject: host_io: a Restore's new core is restoreCore's (the clients that replicate the old one let go, the dump read and restored, its failure said once, the old core's pane and theme watches dropped), with both ponytail notes, where the tty and the window each wrote those steps out; each keeps its own ptys, pipes and views, and the tty's dump import goes with its one use Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- src/host_io.zig | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/host_io.zig') diff --git a/src/host_io.zig b/src/host_io.zig index d6b9b72e..3a9a73fd 100644 --- a/src/host_io.zig +++ b/src/host_io.zig @@ -7,6 +7,7 @@ const selection_pipe = @import("selection_pipe.zig"); const ninep_io = @import("9p_io.zig"); const filesystem = @import("fs.zig"); const file_watch = @import("file_watch.zig"); +const replica = @import("replica.zig"); pub const Host = struct { ctx: ?*anyopaque = null, @@ -96,6 +97,29 @@ pub fn stopWorkers() void { pardes.syntax.stop(); } +/// A Restore's new core, from the dump at `path` (core.takeRestore), or +/// null once why it is not is said. ponytail: a Restore replaces the core +/// its clients replicate; they are let go, and attach again. The old +/// core's panes and theme are no longer watched; the frontend lets go of +/// its ptys and pipes and swaps the new core in. ponytail: a restored +/// session is one view, the live one's (the tty's terminal, the window's +/// window): the others are let go, as a detach of each. +pub fn restoreCore(gpa: std.mem.Allocator, core: *pardes.Pardes, path: []const u8, peers: *replica.Peers, inotify_fd: c_int, watches: *file_watch.Table) ?*pardes.Pardes { + peers.dropAll(core); + const bytes = filesystem.readRestore(gpa, path, core.settings.dump_dir.get()) catch |err| { + core.reportError(core.active, "Restore", err); + return null; + }; + defer gpa.free(bytes); + const nc = pardes.dump.restore(core, bytes, path) catch |err| { + core.reportError(core.active, "Restore", err); + return null; + }; + file_watch.unwatchAll(inotify_fd, watches); + _ = file_watch.applyThemeEffect(core, gpa, inotify_fd, watches, 0, false, false); + return nc; +} + pub const Fallback = struct { pub const dump_path = "pardes.dump"; -- cgit v1.3