diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-21 17:47:24 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-21 18:20:00 -0300 |
| commit | f11ba0c54b500d855740c54f26208217793bcef6 (patch) | |
| tree | 2da4a6392a3ba5aae5fff3eb425d2f5cd1f365e7 /core | |
| parent | aefdb402b577c270111e2736e175611def0833e7 (diff) | |
| download | pardes-f11ba0c54b500d855740c54f26208217793bcef6.tar.gz pardes-f11ba0c54b500d855740c54f26208217793bcef6.zip | |
tests: a screen-state client's reads of a terminal's prompt marks are the session's in its own input's step: core/replica.zig "a command typed into a shell with prompt marks under screen state: every side notes it as the session's emulator numbers it, and Kill finds it" (pardes's bash marks, one command run, an `Exec sleep 9` typed at the prompt: `sent_command.seq` 2 on both sides, then its C mark and a Kill: every field agrees), the audit's one doubt settled by a run: the OSC 133 cycle crosses with every delta (core/term/terminal.zig `marksOf`/`takeMarks`), so exec.zig's `noteCommand` and Kill read the session's; what still parts is a step of the session's own after the same pump's output (the pump-lag class, the client replaying it over the last flush: a test of it is kept out of the tree, failing, in the report); passes on the base and with the fix
Co-Authored-By: Claude Opus <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'core')
| -rw-r--r-- | core/replica.zig | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/core/replica.zig b/core/replica.zig index 49ae4594..1939efbc 100644 --- a/core/replica.zig +++ b/core/replica.zig @@ -6487,6 +6487,56 @@ test "a terminal's program shows a kitty image under screen state: the client's try std.testing.expect(std.mem.indexOf(u8, prefix, " petscii:") != null); } +test "a command typed into a shell with prompt marks under screen state: every side notes it as the session's emulator numbers it, and Kill finds it" { + if (pardes.Term.ops == null) return error.SkipZigTest; // a shell + const gpa = std.testing.allocator; + var arena: std.heap.ArenaAllocator = .init(gpa); + defer arena.deinit(); + const ShellHost = struct { + fn taken(_: ?*anyopaque, _: pardes.Pane.Id) bool { + return false; + } + fn write(_: ?*anyopaque, _: pardes.Pane.Id, _: []const u8) void {} + const vtable: pardes.Host.VTable = .{ .watched = TestHost.watched, .tty_taken = taken, .pty_write = write }; + }; + const a = try Authority.init(gpa, .{ .cols = 80, .rows = 24, .boot = .tty }, .{ .vtable = &ShellHost.vtable }, true); + defer a.deinit(); + var screens: Screens = .init(gpa); + defer screens.deinit(a.core); + const peer = try screens.addPeer(); + const r = try Replica.init(gpa, 1, try a.unit(0, 0), true); + defer r.deinit(); + const shell: u8 = for (a.core.panes, 0..) |slot, id| { + if (slot) |pane| if (pane.isTerminal()) break @intCast(id); + } else return error.NoShell; + // pardes's own bash marks (host_io.zig): one command run, a prompt. + const prompt = "\x1b]133;A;cl=line;aid=pardes\x07$ \x1b]133;B;aid=pardes\x07"; + a.output(.{ .output = .{ .pane = .at(shell), .bytes = prompt ++ "ls\r\n\x1b]133;C;aid=pardes\x07a b\r\n\x1b]133;D;0;aid=pardes\x07" ++ prompt } }); + r.confirm((try a.pending()).?); + r.settle(); + try deliver(a, &screens, peer, r, .flush); + a.core.view().active = shell; + r.confirm(try a.local(.{ .focus = true })); + r.settle(); + try std.testing.expectEqualStrings("", try partsApart(a, r, arena.allocator())); + // Exec'd in the shell: typed at its prompt, the command noted. + r.confirm(try a.local(.{ .command = "Exec sleep 9" })); + r.settle(); + // Its marks cross with the cells (Term.marksOf): numbered alike. + try std.testing.expectEqual(@as(u32, 2), a.core.panes[shell].?.sent_command.?.seq); + try std.testing.expectEqual(@as(u32, 2), r.core().panes[shell].?.sent_command.?.seq); + try std.testing.expectEqualStrings("", try partsApart(a, r, arena.allocator())); + // Its echo and its C mark: running. Kill is asked for it. + a.output(.{ .output = .{ .pane = .at(shell), .bytes = "sleep 9\r\n\x1b]133;C;aid=pardes\x07" } }); + r.confirm((try a.pending()).?); + r.settle(); + try deliver(a, &screens, peer, r, .flush); + r.confirm(try a.local(.{ .command = "Kill" })); + r.settle(); + try std.testing.expectEqualStrings("", try partsApart(a, r, arena.allocator())); + try agrees(a, r); +} + test "a far client's own Del of a pane whose kind's state is not plain, rolled back by another's unit: the pane comes back whole, and is closed again with the session's order" { const gpa = std.testing.allocator; const a = try Authority.init(gpa, .{ .cols = 80, .rows = 24, .file = "mise.toml" }, TestHost.host(), false); |
