summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/config.md3
-rw-r--r--src/Terminal.zig4
-rw-r--r--src/dump.zig4
-rw-r--r--test/snapshots/dump.golden3
4 files changed, 13 insertions, 1 deletions
diff --git a/docs/config.md b/docs/config.md
index 16fd59e5..4d1cebe9 100644
--- a/docs/config.md
+++ b/docs/config.md
@@ -607,7 +607,8 @@ writes a timestamped file in the default directory.
A restored terminal comes back live: its recorded output (the last MiB of it)
is replayed as history, a dim `── restored history ──` line marks where it
-ends, and a new shell starts below it in the directory the old one was in. A
+ends, and a new shell starts below it in the directory the old one was in,
+the same shell it ran (a `Tty bash` pane comes back running bash). A
view left scrolled back stays where it was. Only the shell is new; nothing the
old one was running is restarted. The web shell, which has no ptys, still
shows the history alone.
diff --git a/src/Terminal.zig b/src/Terminal.zig
index a390b76b..e50eb2df 100644
--- a/src/Terminal.zig
+++ b/src/Terminal.zig
@@ -668,6 +668,7 @@ test "a restored terminal keeps its history above a marker and gets a shell wher
const pane = p.panes[0].?;
feedOutput(p, pane, "old output\r\n$ ls\r\n");
try pane.setOwnedCwd("/tmp");
+ pane.shell = try gpa.dupe(u8, "bash"); // `Tty bash`: it comes back as bash
try dump.dumpState(p);
const restored = try dump.initFromDump(gpa, .{ .tty_only = true, .cols = 40, .rows = 12 }, p.dump_out.?);
defer restored.deinit();
@@ -678,6 +679,7 @@ test "a restored terminal keeps its history above a marker and gets a shell wher
};
try std.testing.expect(spawned);
const again = restored.panes[0].?;
+ try std.testing.expectEqualStrings("bash", again.shell.?);
try std.testing.expectEqual(.spawn, again.pending_command.wait);
const text = try screenTextAlloc(again, gpa);
defer gpa.free(text);
@@ -1436,6 +1438,7 @@ pub fn dumpPane(
.collapsed = pane.collapsed,
.terminal = .{
.cwd = try arena.dupe(u8, pane.cwdSlice()),
+ .shell = try arena.dupe(u8, pane.shell orelse ""),
.stream = try arena.dupe(u8, text),
.stream_b64 = &.{},
.cursor = .{ .col = 0, .row = 0 },
@@ -1485,6 +1488,7 @@ pub fn dumpPane(
.collapsed = pane.collapsed,
.terminal = .{
.cwd = try arena.dupe(u8, pane.cwdSlice()),
+ .shell = try arena.dupe(u8, pane.shell orelse ""),
.stream = stream[0..len],
.stream_b64 = try dump.encodeBytes(arena, try screenVt(pane, arena)),
.stream_is_screen = true,
diff --git a/src/dump.zig b/src/dump.zig
index 954a3270..446776d4 100644
--- a/src/dump.zig
+++ b/src/dump.zig
@@ -99,6 +99,9 @@ pub const PaneKind = enum {
pub const Terminal = struct {
cwd: []const u8 = "",
+ /// The shell it runs when not the configured one (`Tty bash`); empty,
+ /// the configured one, as in dumps from before.
+ shell: []const u8 = "",
/// The rendered scrollback and screen as plain text, one row per line.
stream: []const u8 = "",
stream_b64: []const u8 = "",
@@ -747,6 +750,7 @@ fn initDump(gpa: std.mem.Allocator, opts: Options, zon_bytes: []const u8, previo
const restored = try pardes.panes.Terminal.restore(p, src, revive);
p.installPane(i, restored);
try restored.setOwnedCwd(t.cwd);
+ if (t.shell.len > 0) restored.shell = try gpa.dupe(u8, t.shell);
if (std.mem.startsWith(u8, src.tag, "TTY ")) restored.body.mode = .tty;
if (revive) p.emit(.{ .spawn = .{ .pane = @intCast(i), .serial = restored.serial, .cwd = .from(t.cwd) } });
break :terminal restored;
diff --git a/test/snapshots/dump.golden b/test/snapshots/dump.golden
index 858e6670..d3a7c0cc 100644
--- a/test/snapshots/dump.golden
+++ b/test/snapshots/dump.golden
@@ -36,6 +36,7 @@
.tag_tail = null,
.terminal = .{
.cwd = "/tmp/pardes-snap/dump/cwd",
+ .shell = "",
.stream = "ls\nd.txt\n",
.stream_b64 = <elided>
.stream_is_screen = true,
@@ -56,6 +57,7 @@
.tag_tail = null,
.terminal = .{
.cwd = "/tmp/pardes-snap/dump/cwd",
+ .shell = "",
.stream = "ls\nd.txt\n",
.stream_b64 = <elided>
.stream_is_screen = true,
@@ -76,6 +78,7 @@
.tag_tail = null,
.terminal = .{
.cwd = "/tmp/pardes-snap/dump/cwd",
+ .shell = "",
.stream = "ls\nd.txt\n",
.stream_b64 = <elided>
.stream_is_screen = true,