summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-10-29 18:04:38 -0300
committerGabriel Schneider <[email protected]>2026-10-29 21:13:33 -0300
commit7ba57610929544bf3d1b3d0bf65dbb039d97942b (patch)
tree3cfa59be7b0b56e82b8bff80856eaa7f1cf63b53 /src
parent70de5ec5ff3dad01afcc45244ad5e5a481486da6 (diff)
downloadpardes-7ba57610929544bf3d1b3d0bf65dbb039d97942b.tar.gz
pardes-7ba57610929544bf3d1b3d0bf65dbb039d97942b.zip
snapshots: dump, load, restore, tagnav and headersweep-restored show the session as it was dumped: a terminal's view, its prompts hidden in text mode, a pane's message, typed text over its history
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/dump.zig28
-rw-r--r--src/tape.zig2
-rw-r--r--src/terminal.zig7
3 files changed, 31 insertions, 6 deletions
diff --git a/src/dump.zig b/src/dump.zig
index ccbcd158..20299b79 100644
--- a/src/dump.zig
+++ b/src/dump.zig
@@ -331,7 +331,7 @@ fn loadAndRevive(gpa: std.mem.Allocator, opts: Options, bytes: []const u8, previ
/// A loaded core given to this host (with `revivePane` for each of its
/// panes): the store and Recent read (a Restore's carried from the session
-/// it replaces), its ThemeFile asked for again, and the screen this host's.
+/// it replaces) and its ThemeFile asked for again.
fn reviveSession(p: *Pardes, previous: ?*const Pardes) !void {
if (previous) |old| {
// Never a serial or a request number the old session gave out.
@@ -358,9 +358,8 @@ fn reviveSession(p: *Pardes, previous: ?*const Pardes) !void {
for (p.panes) |slot| if (slot) |pane| {
pane.fs.unannounced = true;
};
- // This host's screen; the next sync lays the panes out on it.
- p.screen_w = p.opts.cols;
- p.screen_h = p.opts.rows;
+ // The dump's screen until this host says its own (a resize): two
+ // reflows would lose where a terminal's view was.
p.sync();
exec.applyStartupConfig(p);
colors.finishThemeInitialization(p);
@@ -569,3 +568,24 @@ test "a pane restored with unsaved text is asked about by Exit, Restore, Del and
try std.testing.expect(!restored.quit and restored.panes[id] != null);
}
}
+
+test "a loaded terminal's history stays above its banner, the cursor where it was" {
+ if (comptime !pardes.panes.terminal.enabled or isolated) return error.SkipZigTest;
+ const gpa = std.testing.allocator;
+ const term = pardes.panes.terminal;
+ const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 40, .rows = 12 });
+ defer p.deinit();
+ while (p.nextEffect()) |_| {}
+ term.feedOutput(p, p.panes[0].?, "one\r\ntwo\r\n$ ");
+ const before = term.gridCursor(p.panes[0].?);
+ try dumpState(p);
+ const loaded = try load(gpa, .{ .tty_only = true, .cols = 40, .rows = 12 }, p.dump_out.?, null);
+ defer loaded.deinit();
+ try std.testing.expectEqual(before, term.gridCursor(loaded.panes[0].?));
+ const q = try initFromDump(gpa, .{ .tty_only = true, .cols = 40, .rows = 12 }, p.dump_out.?);
+ defer q.deinit();
+ const text = try term.screenTextAlloc(q.panes[0].?, gpa);
+ defer gpa.free(text);
+ try std.testing.expect(std.mem.indexOf(u8, text, "one\ntwo\n") != null);
+ try std.testing.expect(std.mem.indexOf(u8, text, "two") .? < std.mem.indexOf(u8, text, "restored history").?);
+}
diff --git a/src/tape.zig b/src/tape.zig
index 3573d887..d4fb7756 100644
--- a/src/tape.zig
+++ b/src/tape.zig
@@ -983,6 +983,8 @@ pub fn replayMain(io: std.Io, path: []const u8) u8 {
if (t.diverged) |why| if (std.mem.startsWith(u8, why, "the tape ends")) {
t.diverged = null;
};
+ // One killed (as the harnesses end theirs) has its end state here.
+ if (t.dump_check and t.diverged == null) if (t.core) |core| t.dumpRoundTrip(core);
if (t.diverged) |why| {
failed = true;
std.debug.print("replay {s}: {s} replica diverged after {d} digests: {s}\n", .{ path, run.name, t.digests, why });
diff --git a/src/terminal.zig b/src/terminal.zig
index 6fdd46f0..ad35784f 100644
--- a/src/terminal.zig
+++ b/src/terminal.zig
@@ -835,8 +835,11 @@ pub const restored_banner = "\x1b[0m\r\n\x1b[2m\u{2500}\u{2500} restored history
pub fn reviveShell(pane: *Pane) void {
if (comptime !enabled) return;
if (pane.terminal == null) return;
- // The primary screen, modes and mouse as a shell starts with them.
- ingest(pane, "\x1b[?1049l\x1b[!p\x1b[?1000l\x1b[?1002l\x1b[?1003l\x1b[?1006l\x1b[?2004l\x1b[<u");
+ // The primary screen, keys, cursor and mouse as a shell starts with
+ // them, the cursor where it was (a soft reset, or leaving a primary
+ // screen for itself, would take it home).
+ if (pane.terminal.?.vt.screens.active_key == .alternate) ingest(pane, "\x1b[?1049l");
+ ingest(pane, "\x1b[?1l\x1b>\x1b[?25h\x1b[?7h\x1b[?1000l\x1b[?1002l\x1b[?1003l\x1b[?1006l\x1b[?2004l\x1b[<u");
ingest(pane, restored_banner);
// What the old shell was, ran and said is gone with it: the REPL it
// ran, the Tty+ word naming it.