summaryrefslogtreecommitdiff
path: root/test/panes.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-29 08:14:42 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:16 -0300
commita630f5e83ef9efabca790770112dcea689384631 (patch)
tree390d6e6b08cba9e0964d05af1f8d0005aba47c6c /test/panes.zig
parent2f1b7cd5fb82e619043ccb34826154a53e53c28e (diff)
downloadpardes-a630f5e83ef9efabca790770112dcea689384631.tar.gz
pardes-a630f5e83ef9efabca790770112dcea689384631.zip
A new terminal's greeting `ls` goes at its shell's first prompt or never
The greeting waited for any moment the cursor sat at a prompt's input, so where the first prompt was missed (a resize still pending, a line written before it), `ls` was typed later into whatever ran then. It is now sent only while nothing has run (pardes's marks saw no command start) and nothing is typed at the prompt; past that it is dropped, never typed late. A prompt drawn again for a resize is still the first. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'test/panes.zig')
-rw-r--r--test/panes.zig28
1 files changed, 26 insertions, 2 deletions
diff --git a/test/panes.zig b/test/panes.zig
index 1ca33053..c1ae1666 100644
--- a/test/panes.zig
+++ b/test/panes.zig
@@ -3466,14 +3466,14 @@ const TerminalTests = struct {
.write => return error.GreetedBeforePrompt,
else => {},
};
- p.update(.{ .output = .{ .pane = 0, .bytes = "\x1b]133;A\x07prompt$ " } });
+ p.update(.{ .output = .{ .pane = 0, .bytes = "\x1b]133;A;aid=pardes\x07prompt$ " } });
try std.testing.expect(!promptInputReady(pane));
while (p.nextEffect()) |effect| switch (effect) {
.write => return error.GreetedDuringPrompt,
else => {},
};
- p.update(.{ .output = .{ .pane = 0, .bytes = "\x1b]133;B\x07" } });
+ p.update(.{ .output = .{ .pane = 0, .bytes = "\x1b]133;B;aid=pardes\x07" } });
try std.testing.expect(promptInputReady(pane));
var greeted = false;
while (p.nextEffect()) |effect| switch (effect) {
@@ -3484,6 +3484,30 @@ const TerminalTests = struct {
try std.testing.expect(!pane.greet);
}
+ test "the greeting is dropped, never typed later, once something ran or was typed first" {
+ if (pardes.platform == .web) return;
+ for ([_][]const u8{
+ // A command ran before the first prompt was seen at rest.
+ "\x1b]133;A;aid=pardes\x07$ \x1b]133;B;aid=pardes\x07\x1b]133;C;aid=pardes\x07out\r\n\x1b]133;D;0;aid=pardes\x07\x1b]133;A;aid=pardes\x07$ \x1b]133;B;aid=pardes\x07",
+ // Someone typed at the first prompt.
+ "\x1b]133;A;aid=pardes\x07$ \x1b]133;B;aid=pardes\x07vim",
+ }) |output| {
+ const p = try Pardes.init(std.testing.allocator, .{ .cols = 80, .rows = 24 });
+ defer p.deinit();
+ const pane = p.panes[0].?;
+ while (p.nextEffect()) |_| {}
+ p.update(.{ .resize = .{ .cols = 80, .rows = 24 } });
+ p.update(.{ .output = .{ .pane = 0, .bytes = output } });
+ // and a later, quiet prompt changes nothing
+ p.update(.{ .output = .{ .pane = 0, .bytes = "\r\n\x1b]133;A;aid=pardes\x07$ \x1b]133;B;aid=pardes\x07" } });
+ while (p.nextEffect()) |effect| switch (effect) {
+ .write => |write| if (std.mem.eql(u8, write.bytes.slice(), "ls\r")) return error.GreetedLate,
+ else => {},
+ };
+ try std.testing.expect(!pane.greet);
+ }
+ }
+
test "fresh-shell commands preserve order and wait for OSC 133 B" {
if (pardes.platform == .web) return;
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true });