From 5925ddbe1aa39a64b484b68a8ddb3649b3d180e4 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Fri, 30 Oct 2026 16:52:24 -0300 Subject: Adopt and a terminal reader's failure are inputs (Pardes.adoptShell, readerFailed; tape.Input adopt_shell, reader_failed): tty.zig's and gui.zig's adoptShell ran the Tty word and cleared the pane's greeting straight on the core, and the window's reader failure set its pane's mode, between steps and untaped, so every client of a session that took in a dead session's shells joined again (the hunt's H15: `the unit of 0/48 diverged: the core called poll_frame where the tape has a host (10)`, gone after); replica.zig's test, which the old writes fail Co-Authored-By: Claude Opus 5.5 --- src/pardes.zig | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'src/pardes.zig') diff --git a/src/pardes.zig b/src/pardes.zig index a4fcb2d3..81ea0cdd 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -5557,6 +5557,36 @@ pub const Pardes = struct { return if (selected.len == 0) config.defaultShell() else selected; } + /// A shell a dead session left, taken in (Adopt): a terminal pane made + /// for it as the Tty word makes one, its greeting off (the shell is up + /// already), whose spawn the host answers with that shell's pty. Its id, + /// or null with no room. An input, as every host write into the core + /// is: a replica of the session makes the same pane. + pub fn adoptShell(p: *Pardes) ?u8 { + const taped = tape.enter(p, .adopt_shell); + defer tape.leave(p, taped); + var newest: u32 = 0; + for (p.panes) |slot| if (slot) |pn| { + newest = @max(newest, pn.serial); + }; + _ = p.executeBuiltinLine(p.active, "Tty"); + for (p.panes, 0..) |slot, id| if (slot) |pn| if (pn.serial > newest and pn.isTerminal()) { + pn.greet = false; + return @intCast(id); + }; + return null; + } + + /// A terminal's reader failed (no end of file: the host closed its pty): + /// its pane takes keys again, and why is said. + pub fn readerFailed(p: *Pardes, id: u8, err: anyerror) void { + const taped = tape.enter(p, .{ .reader_failed = .{ .id = id, .err = err } }); + defer tape.leave(p, taped); + const pane = p.panes[id] orelse return; + pane.body.mode = .normal; + p.reportError(id, "terminal reader", err); + } + pub fn acknowledgeShell(p: *Pardes, id: usize, executable: []const u8, prompt_marks: bool) void { const taped = tape.enter(p, .{ .acknowledge_shell = .{ .id = id, .executable = executable, .prompt_marks = prompt_marks } }); defer tape.leave(p, taped); -- cgit v1.3