summaryrefslogtreecommitdiff
path: root/src/dump.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-10-29 20:08:12 -0300
committerGabriel Schneider <[email protected]>2026-10-29 21:13:33 -0300
commitd8e30740463dda5a87fb8a4f6e9755fbb84b7220 (patch)
tree07628a107ed7de5f560d8c4d4d5b834482830c9c /src/dump.zig
parentad0d3f61f310ca0cc3a1ab2c36edcafb5c44b97a (diff)
downloadpardes-d8e30740463dda5a87fb8a4f6e9755fbb84b7220.tar.gz
pardes-d8e30740463dda5a87fb8a4f6e9755fbb84b7220.zip
dump: a session's dump keeps every view, the ones not live parked again by load; a session revived for one client is its live view alone, as view 0
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/dump.zig')
-rw-r--r--src/dump.zig33
1 files changed, 29 insertions, 4 deletions
diff --git a/src/dump.zig b/src/dump.zig
index c33ac02c..e6a41f09 100644
--- a/src/dump.zig
+++ b/src/dump.zig
@@ -19,6 +19,7 @@ const MAX_COLS = pardes.MAX_COLS;
const effect_path_cap = pardes.effect_path_cap;
const Options = pardes.Options;
const Pardes = pardes.Pardes;
+const views = pardes.views;
/// Where the next dump goes. $PARDES_DUMP wins verbatim (the snapshot harness
/// pins it for deterministic goldens); else $XDG_DATA_HOME|~/.local/share
@@ -144,11 +145,12 @@ pub fn defaultDirectory(buf: []u8) ?[]const u8 {
/// the frame's or worked out again (`replica` in each type, src/walk.zig),
/// then its 9P mounts, which live with the 9P server's own state, which of
/// its panes' files were on disk when it was made (one gone by its load is
-/// said deleted: its text is nowhere else now), and its theme's name: the
+/// said deleted: its text is nowhere else now), its theme's name (the
/// setting is a place in this build's ring of themes, another build's
-/// ring is another.
-const Session = walk.Dump(&.{ Pardes, []const filesystem.Mount, OnDisk, []const u8 });
-const SessionLoad = walk.Load(&.{ Pardes, []const filesystem.Mount, OnDisk, []const u8 });
+/// ring is another), and the views not live (views.zig: the core holds
+/// the live one's).
+const Session = walk.Dump(&.{ Pardes, []const filesystem.Mount, OnDisk, []const u8, []const views.Dumped });
+const SessionLoad = walk.Load(&.{ Pardes, []const filesystem.Mount, OnDisk, []const u8, []const views.Dumped });
const OnDisk = [MAX_PANES]bool;
fn onDisk(pane: *const pardes.panes.Pane) bool {
@@ -180,6 +182,13 @@ pub fn dumpBytes(p: *Pardes) ![]u8 {
try d.put(OnDisk, &on_disk);
const theme: []const u8 = colors.themes[@min(p.settings.theme, colors.themes.len - 1)].name;
try d.put([]const u8, &theme);
+ const others = try views.dumped(p, p.gpa);
+ defer {
+ for (others) |o| p.gpa.free(o.panes);
+ p.gpa.free(others);
+ }
+ const kept: []const views.Dumped = others;
+ try d.put([]const views.Dumped, &kept);
return d.finish();
}
@@ -263,6 +272,18 @@ fn loadKnowing(gpa: std.mem.Allocator, opts: Options, bytes: []const u8, notes:
for (p.panes) |slot| if (slot) |pane| try ensureKind(p, pane);
if (notes) |n| try n.appendSlice(gpa, l.notes.items);
}
+ // The views not live, last: what it moves into the core is never
+ // rolled back from under it, nothing after it failing.
+ const at = l.shared.items.len;
+ const others = l.get([]const views.Dumped) catch |err| switch (err) {
+ // A dump made before views were in it.
+ error.EndOfDump => &.{},
+ else => return err,
+ };
+ try views.undumped(p, others);
+ for (others) |o| gpa.free(o.panes);
+ gpa.free(others);
+ l.shared.shrinkRetainingCapacity(at);
return p;
}
@@ -351,6 +372,9 @@ fn loadAndRevive(gpa: std.mem.Allocator, opts: Options, bytes: []const u8, previ
/// panes): the store and Recent read (a Restore's carried from the session
/// it replaces) and its ThemeFile asked for again.
fn reviveSession(p: *Pardes, previous: ?*const Pardes) !void {
+ // ponytail: one client loads it, so it is one view, the live one's; a
+ // replica joining (phase 5) takes `load`'s, every view.
+ views.only(p);
if (previous) |old| {
// Never a serial or a request number the old session gave out.
p.next_serial = @max(p.next_serial, old.next_serial);
@@ -471,6 +495,7 @@ pub fn loadPane(p: *Pardes, id: usize, bytes: []const u8) !*pardes.panes.Pane {
pane.command_from = 0;
pane.places.from = 0;
pane.collapsed = false;
+ pane.prompt_view = p.view;
if (pane.file) |*f| if (f.content.len == 0 and (f.saved_len orelse 0) > 0) {
// A clean file kept slim: its text is its file's.
if (filesystem.read(p, f.path)) |text| {