diff options
| -rw-r--r-- | src/dump.zig | 28 | ||||
| -rw-r--r-- | src/tape.zig | 2 | ||||
| -rw-r--r-- | src/terminal.zig | 7 | ||||
| -rw-r--r-- | test/snapshots/dump.golden | 141 | ||||
| -rw-r--r-- | test/snapshots/headersweep-restored.golden | 11 | ||||
| -rw-r--r-- | test/snapshots/load.golden | 46 | ||||
| -rw-r--r-- | test/snapshots/load.snap | 9 | ||||
| -rw-r--r-- | test/snapshots/restore.golden | 3 | ||||
| -rw-r--r-- | test/snapshots/tagnav.golden | 5 |
9 files changed, 90 insertions, 162 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. diff --git a/test/snapshots/dump.golden b/test/snapshots/dump.golden index 2704918d..c9e8b73b 100644 --- a/test/snapshots/dump.golden +++ b/test/snapshots/dump.golden @@ -1,117 +1,24 @@ -== file dump -.{ - .magic = "pardes-dump", - .version = 1, - .screen = .{ .cols = 100, .rows = 31 }, - .active = 0, - .topbar = "Newcol Joincol Find Grep Help Changelog Tutor Dump Themes Config Debug Exit", - .topbar_custom = null, - .theme = "orchard", - .locations_config = .{ - .context = 0, - .tscontext = false, - .tslocations = true, - .layout = .stacked, - }, - .tree_context_tag_style = true, - .columns = .{ .{ - .serial = 1, - .tag = null, - .weight = 1, - .panes = .{ 0, 1 }, - }, .{ - .serial = 2, - .tag = null, - .weight = 1, - .panes = .{2}, - } }, - .panes = .{ - .{ - .kind = .terminal, - .tag = "/tmp/pardes-snap/dump/cwd Tty+bash Save Mode Filter Collapse Del", - .body = "ls\nd.txt\n\n\n\n typed-marker\n\n\n\n\n\n\n", - .scroll = 0, - .cols = 48, - .rows = 13, - .vweight = 1, - .collapsed = false, - .serial = 1, - .tag_tail = null, - .attached_to = null, - .terminal = .{ - .cwd = "/tmp/pardes-snap/dump/cwd", - .shell = "", - .command = "", - .status = null, - .stream = "ls\nd.txt\n", - .stream_b64 = <elided> - .stream_is_screen = true, - .cursor = .{ .col = 2, .row = 2 }, - .petscii = false, - }, - .file = null, - .image = null, - }, - .{ - .kind = .terminal, - .tag = "/tmp/pardes-snap/dump/cwd Tty+bash Save Mode Filter Collapse Del", - .body = "ls\nd.txt\n\n\n\n\n\n\n\n\n\n", - .scroll = 0, - .cols = 48, - .rows = 12, - .vweight = 1, - .collapsed = false, - .serial = 2, - .tag_tail = null, - .attached_to = null, - .terminal = .{ - .cwd = "/tmp/pardes-snap/dump/cwd", - .shell = "", - .command = "", - .status = null, - .stream = "ls\nd.txt\n", - .stream_b64 = <elided> - .stream_is_screen = true, - .cursor = .{ .col = 2, .row = 2 }, - .petscii = false, - }, - .file = null, - .image = null, - }, - .{ - .kind = .terminal, - .tag = "/tmp/pardes-snap/dump/cwd Tty+bash Save Mode Filter Collapse Del", - .body = "ls\nd.txt\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", - .scroll = 0, - .cols = 48, - .rows = 27, - .vweight = 1, - .collapsed = false, - .serial = 3, - .tag_tail = null, - .attached_to = null, - .terminal = .{ - .cwd = "/tmp/pardes-snap/dump/cwd", - .shell = "", - .command = "", - .status = null, - .stream = "ls\nd.txt\n", - .stream_b64 = <elided> - .stream_is_screen = true, - .cursor = .{ .col = 2, .row = 2 }, - .petscii = false, - }, - .file = null, - .image = null, - }, - }, - .mounts = .{}, - .settings = .{ - "MessageAnimation off", - "MessageLinger 0", - "Shell bash", - }, - .incl = .{ "/usr/include", "/usr/local/include" }, - .carried = null, -} -== end file +== snap loaded grid=100x31 cursor=16,9 +| Newcol Joincol Find Grep Help Changelog Tutor Dump Themes Config Debug Exit +| New Tty Find Grep Joincol Delcol New Tty Find Grep Joincol Delcol +| /tmp/pardes-snap/dump/cwd Tty+bash Save Mode Fil /tmp/pardes-snap/dump/cwd Tty+bash Save Mode Fil +| ter Collapse Del ter Collapse Del +| ls Dump ls +| d.txt d.txt +| +| ── restored history ── ── restored history ── +| +| typed-marker +| +| +| +| +| +| +| +| /tmp/pardes-snap/dump/cwd Tty+bash Save Mode Fil +| ter Collapse Del +| ls +| d.txt +| +| ── restored history ── diff --git a/test/snapshots/headersweep-restored.golden b/test/snapshots/headersweep-restored.golden index 522945bd..64e48503 100644 --- a/test/snapshots/headersweep-restored.golden +++ b/test/snapshots/headersweep-restored.golden @@ -4,7 +4,7 @@ |2: 0-1 d,#add38a, 2-43 #becfc4,#314738, 44-52 #dfbce5,#314738, 53-59 #becfc4,#314738, 60-61 #becfc4,#496656, 62-103 #b2c3b8,#1d2824, 104-112 #d3b0d9,#1d2824, 113-119 #b2c3b8,#1d2824, |3: 0-1 d,#314738, 2-59 #becfc4,#314738, 60-61 #becfc4,#1d2824, 62-119 #b2c3b8,#1d2824, |4: 0-0 d,#608269, 1-1 d,#0d1410, 2-59 #e5eee5,#0d1410, 60-60 #e5eee5,#608269, 61-119 #e5eee5,#0d1410, -|5: 0-0 d,#608269, 1-1 d,#0d1410, 2-59 #e5eee5,#0d1410, 60-60 #e5eee5,#608269, 61-119 #e5eee5,#0d1410, +|5: 0-0 d,#608269, 1-59 d,#0d1410, 60-60 d,#608269, 61-119 d,#0d1410, |6: 0-0 d,#608269, 1-1 d,#0d1410, 2-23 #e5eee5,#0d1410,f 24-59 #e5eee5,#0d1410, 60-60 #e5eee5,#608269, 61-61 #e5eee5,#0d1410, 62-83 #e5eee5,#0d1410,f 84-119 #e5eee5,#0d1410, |7: 0-0 d,#608269, 1-59 d,#0d1410, 60-60 d,#608269, 61-119 d,#0d1410, |8: 0-0 d,#608269, 1-59 d,#0d1410, 60-60 d,#608269, 61-119 d,#0d1410, @@ -14,7 +14,7 @@ |12: 0-1 d,#496656, 2-43 #b2c3b8,#1d2824, 44-52 #d3b0d9,#1d2824, 53-59 #b2c3b8,#1d2824, 60-60 #b2c3b8,#608269, 61-119 #b2c3b8,#0d1410, |13: 0-1 d,#1d2824, 2-59 #b2c3b8,#1d2824, 60-60 #b2c3b8,#608269, 61-119 #b2c3b8,#0d1410, |14: 0-0 d,#608269, 1-1 d,#0d1410, 2-59 #e5eee5,#0d1410, 60-60 #e5eee5,#608269, 61-119 #e5eee5,#0d1410, -|15: 0-0 d,#608269, 1-1 d,#0d1410, 2-59 #e5eee5,#0d1410, 60-60 #e5eee5,#608269, 61-119 #e5eee5,#0d1410, +|15: 0-0 d,#608269, 1-59 d,#0d1410, 60-60 d,#608269, 61-119 d,#0d1410, |16: 0-0 d,#608269, 1-1 d,#0d1410, 2-23 #e5eee5,#0d1410,f 24-59 #e5eee5,#0d1410, 60-60 #e5eee5,#608269, 61-119 #e5eee5,#0d1410, |17: 0-0 d,#608269, 1-59 d,#0d1410, 60-60 d,#608269, 61-119 d,#0d1410, |18: 0-0 d,#608269, 1-59 d,#0d1410, 60-60 d,#608269, 61-119 d,#0d1410, @@ -25,8 +25,8 @@ | New Tty Find Grep Joincol Delcol echo RE''STORED-COL New Tty Find Grep Joincol Delcol | /tmp/pardes-snap/headersweep-restored/cwd Tty+bash Save Mo /tmp/pardes-snap/headersweep-restored/cwd Tty+bash Save Mo | de Filter Collapse Del de Filter Collapse Del -| $ ls $ ls -| $ $ +| ls ls +| | ── restored history ── ── restored history ── | | @@ -35,7 +35,7 @@ | | /tmp/pardes-snap/headersweep-restored/cwd Tty+bash Save Mo | de Filter Collapse Del -| $ +| | ── restored history ── | | /tmp/pardes-snap/headersweep-restored/cwd (echo RE''STORED @@ -44,6 +44,7 @@ == style ws-sweeping grid=120x21 |0: 0-1 d,#1d2824, 2-100 #b2c3b8,#1d2824, 101-108 #f5f7ee,#5b7e5a, 109-119 #b2c3b8,#1d2824, |1: 0-1 d,#887455, 2-59 #becfc4,#314738, 60-61 #becfc4,#887455, 62-119 #b2c3b8,#1d2824, +|14: 0-0 d,#608269, 1-59 d,#0d1410, 60-60 d,#608269, 61-119 d,#0d1410, |15: 0-0 d,#608269, 1-1 d,#0d1410, 2-23 #e5eee5,#0d1410,f 24-59 #e5eee5,#0d1410, 60-60 #e5eee5,#608269, 61-119 #e5eee5,#0d1410, |16: 0-0 d,#152019, 1-59 d,#0d1410, 60-60 d,#608269, 61-119 d,#0d1410, |17: 0-1 d,#496656, 2-59 #b2c3b8,#1d2824, 60-60 #b2c3b8,#608269, 61-119 #b2c3b8,#0d1410, diff --git a/test/snapshots/load.golden b/test/snapshots/load.golden index 18de9a8f..ea8f26ec 100644 --- a/test/snapshots/load.golden +++ b/test/snapshots/load.golden @@ -3,48 +3,48 @@ | New Tty Find Grep Joincol Delcol New Tty Find Grep Joincol Delcol | /tmp/pardes-snap/load/cwd Tty+bash Save Mode Fil /tmp/pardes-snap/load/cwd Tty+bash Save Mode Fil | ter Collapse Del ter Collapse Del -| $ echo LOAD''MARK; seq 1 40; echo E''ND $ ls -| LOADMARK d.txt -| 1 $ -| 2 ── restored history ── -| 3 -| 4 -| 5 -| 6 -| 7 -| 8 -| 9 -| 10 -| 11 +| 28 Dump ls +| 29 d.txt +| 30 +| 31 ── restored history ── +| 32 +| 33 +| 34 +| 35 +| 36 +| 37 +| 38 +| 39 +| 40 | /tmp/pardes-snap/load/cwd Tty+bash Save Mode Fil | ter Collapse Del -| $ ls +| ls | d.txt -| $ +| | ── restored history ── == style loaded grid=100x31 -|0: 0-1 d,#1d2824, 2-99 #b2c3b8,#1d2824, +|0: 0-1 d,#1d2824, 2-47 #b2c3b8,#1d2824, 48-51 #f5f7ee,#3c614a, 52-52 #f5f7ee,#1d2824, 53-99 #b2c3b8,#1d2824, |1: 0-1 d,#887455, 2-49 #becfc4,#314738, 50-51 #becfc4,#887455, 52-99 #b2c3b8,#1d2824, |2: 0-1 d,#add38a, 2-27 #becfc4,#314738, 28-36 #dfbce5,#314738, 37-49 #becfc4,#314738, 50-51 #becfc4,#496656, 52-77 #b2c3b8,#1d2824, 78-86 #d3b0d9,#1d2824, 87-99 #b2c3b8,#1d2824, |3: 0-1 d,#314738, 2-49 #becfc4,#314738, 50-51 #becfc4,#1d2824, 52-99 #b2c3b8,#1d2824, -|4: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 #e5eee5,#608269, 51-99 #e5eee5,#0d1410, -|5: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 #e5eee5,#608269, 51-99 #e5eee5,#0d1410, -|6: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 #e5eee5,#608269, 51-99 #e5eee5,#0d1410, +|4: 0-0 d,#152019, 1-1 d,#0d1410, 2-43 #e5eee5,#0d1410, 44-44 #e5eee5,#1d2824, 45-49 #b2c3b8,#1d2824, 50-50 #b2c3b8,#608269, 51-51 #b2c3b8,#0d1410, 52-99 #e5eee5,#0d1410, +|5: 0-0 d,#152019, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 #e5eee5,#608269, 51-99 #e5eee5,#0d1410, +|6: 0-0 d,#152019, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 #e5eee5,#608269, 51-99 #e5eee5,#0d1410, |7: 0-0 d,#152019, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 #e5eee5,#608269, 51-51 #e5eee5,#0d1410, 52-73 #e5eee5,#0d1410,f 74-99 #e5eee5,#0d1410, |8: 0-0 d,#152019, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 #e5eee5,#608269, 51-99 #e5eee5,#0d1410, |9: 0-0 d,#152019, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 #e5eee5,#608269, 51-99 #e5eee5,#0d1410, |10: 0-0 d,#152019, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 #e5eee5,#608269, 51-99 #e5eee5,#0d1410, |11: 0-0 d,#152019, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 #e5eee5,#608269, 51-99 #e5eee5,#0d1410, -|12: 0-0 d,#152019, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 #e5eee5,#608269, 51-99 #e5eee5,#0d1410, -|13: 0-0 d,#152019, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 #e5eee5,#608269, 51-99 #e5eee5,#0d1410, -|14: 0-0 d,#152019, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 #e5eee5,#608269, 51-99 #e5eee5,#0d1410, +|12: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 #e5eee5,#608269, 51-99 #e5eee5,#0d1410, +|13: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 #e5eee5,#608269, 51-99 #e5eee5,#0d1410, +|14: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 #e5eee5,#608269, 51-99 #e5eee5,#0d1410, |15: 0-0 d,#152019, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 #e5eee5,#608269, 51-99 #e5eee5,#0d1410, |16: 0-0 d,#152019, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 #e5eee5,#608269, 51-99 #e5eee5,#0d1410, |17: 0-1 d,#496656, 2-27 #b2c3b8,#1d2824, 28-36 #d3b0d9,#1d2824, 37-49 #b2c3b8,#1d2824, 50-50 #b2c3b8,#608269, 51-99 #b2c3b8,#0d1410, |18: 0-1 d,#1d2824, 2-49 #b2c3b8,#1d2824, 50-50 #b2c3b8,#608269, 51-99 #b2c3b8,#0d1410, |19: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 #e5eee5,#608269, 51-99 #e5eee5,#0d1410, |20: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 #e5eee5,#608269, 51-99 #e5eee5,#0d1410, -|21: 0-0 d,#608269, 1-1 d,#0d1410, 2-49 #e5eee5,#0d1410, 50-50 #e5eee5,#608269, 51-99 #e5eee5,#0d1410, +|21: 0-0 d,#608269, 1-49 d,#0d1410, 50-50 d,#608269, 51-99 d,#0d1410, |22: 0-0 d,#608269, 1-1 d,#0d1410, 2-23 #e5eee5,#0d1410,f 24-49 #e5eee5,#0d1410, 50-50 #e5eee5,#608269, 51-99 #e5eee5,#0d1410, |23: 0-0 d,#608269, 1-49 d,#0d1410, 50-50 d,#608269, 51-99 d,#0d1410, |24: 0-0 d,#608269, 1-49 d,#0d1410, 50-50 d,#608269, 51-99 d,#0d1410, diff --git a/test/snapshots/load.snap b/test/snapshots/load.snap index 62c661b7..75a9a341 100644 --- a/test/snapshots/load.snap +++ b/test/snapshots/load.snap @@ -1,7 +1,6 @@ -# pardes -l restores another instance's dump (NEW behavior — the old app had a -# separate replay viewer; this golden is generated from the NEW binary as its -# own regression baseline). Shell output survives the replay; typed insert runs -# are an overlay and do not (same semantics as the old replay viewer). +# pardes -l loads another instance's dump: the session as it was dumped, each +# terminal's view where it was (scrolled back into the seq output), its +# history above a "restored history" banner and a new shell below it. file d.txt x start 31 100 -n 3 wait 8000 d.txt @@ -21,7 +20,7 @@ press middle @Dump 1 release middle @Dump 1 stable 600 8000 start 31 100 -l $DUMP -wait 8000 LOADMARK +wait 8000 restored stable 700 20000 snap loaded snapstyle loaded diff --git a/test/snapshots/restore.golden b/test/snapshots/restore.golden index a8e39308..0a6fd913 100644 --- a/test/snapshots/restore.golden +++ b/test/snapshots/restore.golden @@ -7,6 +7,5 @@ | KEEPME | $ == snap restored grid=100x31 cursor=4,8 -|2: /tmp/pardes-snap/restore/cwd Tty+bash Save Mode Filter Collapse Del -|3: $ ls |7: ── restored history ── +|8: $ diff --git a/test/snapshots/tagnav.golden b/test/snapshots/tagnav.golden index 8b6752bd..7ed268f5 100644 --- a/test/snapshots/tagnav.golden +++ b/test/snapshots/tagnav.golden @@ -42,9 +42,6 @@ |4: 1 alpha ls == snap topbar-restored grid=100x31 cursor=7,4 |0: Newcol Joincol Find Grep Help Changelog Tutor Dump Themes Config Debug Exit Restore /tmp/pardes-sn -|4: 1 alpha $ ls -|6: 3 gamma $ +|4: 1 alpha Dump ls |7: /tmp/pardes-snap/tagnav/cwd Tty+bash Save Mode F ── restored history ── -|9: $ ls -|11: $ |12: ── restored history ── |
