diff options
| author | Gabriel Schneider <[email protected]> | 2026-10-30 10:21:51 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-30 12:45:02 -0300 |
| commit | 544d41b77eea27447b329a06f0fa2b852479674c (patch) | |
| tree | 807b2155bfff734d2d4e27ac17f30d297e3407fc /src | |
| parent | cb2688602b3f668790a9c35890973af80143697f (diff) | |
| download | pardes-544d41b77eea27447b329a06f0fa2b852479674c.tar.gz pardes-544d41b77eea27447b329a06f0fa2b852479674c.zip | |
pty: what a run's command printed taped (tape .prompt), as a step's read of its terminal after output is: a screen-state replica's emulator is its deltas', which a lagging client's are states behind, and a run's end replayed there read pins into pages it never had (ghostty's leftWrap overflowed: a window client stopped while a shell flooded the session aborted 3 runs in 8; none in 6 since)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src')
| -rw-r--r-- | src/ninep/pty.zig | 14 | ||||
| -rw-r--r-- | src/tape.zig | 5 |
2 files changed, 15 insertions, 4 deletions
diff --git a/src/ninep/pty.zig b/src/ninep/pty.zig index d80f7175..e68ad84f 100644 --- a/src/ninep/pty.zig +++ b/src/ninep/pty.zig @@ -378,9 +378,11 @@ pub fn noteMarks(p: *Pardes, id: usize, pane: *Pane) void { /// Answers a run whose command ended with `status`: the header and the /// output it printed. fn finish(p: *Pardes, slot: *Run, pane: *Pane, status_code: ?i32) void { - const printed = pardes.panes.terminal.commandOutput(pane, p.gpa, output_rows) catch + // As the authority's emulator has it (taped): a screen-state replica's + // is its deltas', which a lagging client's can be states behind, its + // pins in pages it never had (ghostty's leftWrap overflowed on one). + const printed = pardes.tape.value(.prompt, printedBy, .{ pane, p.scratch.allocator() }) orelse return answer(p, slot, "error out of memory", .{}); - defer p.gpa.free(printed.text); // Keep the tail, cut at a line start so the first line kept is whole. var keep: []const u8 = printed.text; if (keep.len > output_cap) { @@ -409,6 +411,14 @@ fn finish(p: *Pardes, slot: *Run, pane: *Pane, status_code: ?i32) void { answer(p, slot, "exit {s}", .{status}); } +const Printed = struct { text: []const u8, whole: bool }; + +/// What pane `pane`'s command printed (terminal.commandOutput), in `arena`. +fn printedBy(pane: *Pane, arena: std.mem.Allocator) ?Printed { + const out = pardes.panes.terminal.commandOutput(pane, arena, output_rows) catch return null; + return .{ .text = out.text, .whole = out.whole }; +} + /// The shell itself exited (a run's `exit 3`, or one typed): a run waiting /// on the command it ran answers with the shell's status and what it /// printed, and the log says `exit` before the pane's `del`. Unknown, the diff --git a/src/tape.zig b/src/tape.zig index 70a22ab0..9f1cde42 100644 --- a/src/tape.zig +++ b/src/tape.zig @@ -101,8 +101,9 @@ pub const Site = enum(u16) { /// What a terminal's ingest told the positions pardes keeps over it. positions, /// Whether a terminal is at its prompt, as a step reads it after its - /// output (a greeting, a command waiting for the prompt): a - /// screen-state replica's emulator is the last delta's until the next. + /// output (a greeting, a command waiting for the prompt), and what its + /// command printed (a pty/run's answer): a screen-state replica's + /// emulator is the last delta's until the next. prompt, }; |
