diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-08 23:37:38 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-09 01:28:28 -0300 |
| commit | 21277ffc6b08f458eb9a1210a3818e40b14293d2 (patch) | |
| tree | 20feccca94b87f4e75a77eaf18c1699775b9a608 /test | |
| parent | e7cf866a3841398880ca94b0a00841ee82e1d227 (diff) | |
| download | pardes-21277ffc6b08f458eb9a1210a3818e40b14293d2.tar.gz pardes-21277ffc6b08f458eb9a1210a3818e40b14293d2.zip | |
tests: the terminal snapshot scripts (19: tty ttyclick ttyedit ttyfollow ttyhelp ttylook ttyonly ttypaste ttyprompt ttytaken psearch reflow respawn scroll cmdexit look-fd-deep ghostty-mid exec exec-bigdrag) are process cases, test/process/tty_terminals.zig, their goldens unchanged; checked against the old runner by Ctrl-b no longer leaving tty mode (the same 12 fail in both)
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'test')
| -rw-r--r-- | test/process/tty_terminals.zig | 863 | ||||
| -rw-r--r-- | test/snapshots/cmdexit.snap | 28 | ||||
| -rw-r--r-- | test/snapshots/exec-bigdrag.snap | 44 | ||||
| -rw-r--r-- | test/snapshots/exec.snap | 47 | ||||
| -rw-r--r-- | test/snapshots/ghostty-mid.snap | 32 | ||||
| -rw-r--r-- | test/snapshots/look-fd-deep.snap | 34 | ||||
| -rw-r--r-- | test/snapshots/psearch.snap | 88 | ||||
| -rw-r--r-- | test/snapshots/reflow.snap | 20 | ||||
| -rw-r--r-- | test/snapshots/respawn.snap | 21 | ||||
| -rw-r--r-- | test/snapshots/scroll.snap | 31 | ||||
| -rw-r--r-- | test/snapshots/tty.snap | 31 | ||||
| -rw-r--r-- | test/snapshots/ttyclick.snap | 36 | ||||
| -rw-r--r-- | test/snapshots/ttyedit.snap | 45 | ||||
| -rw-r--r-- | test/snapshots/ttyfollow.snap | 47 | ||||
| -rw-r--r-- | test/snapshots/ttyhelp.snap | 24 | ||||
| -rw-r--r-- | test/snapshots/ttylook.snap | 69 | ||||
| -rw-r--r-- | test/snapshots/ttyonly.snap | 11 | ||||
| -rw-r--r-- | test/snapshots/ttypaste.snap | 32 | ||||
| -rw-r--r-- | test/snapshots/ttyprompt.snap | 35 | ||||
| -rw-r--r-- | test/snapshots/ttytaken.snap | 50 |
20 files changed, 862 insertions, 726 deletions
diff --git a/test/process/tty_terminals.zig b/test/process/tty_terminals.zig index 3a3ad072..d5540818 100644 --- a/test/process/tty_terminals.zig +++ b/test/process/tty_terminals.zig @@ -1,3 +1,864 @@ //! The tty frontend's own cases (test/tty.zig), terminal panes: tty mode, its keys and mouse, scrollback, commands. +const std = @import("std"); +const Tty = @import("../tty.zig").Tty; -pub const cases = .{}; +pub const cases = .{ + .{ "tty terminals: tty", tty }, + .{ "tty terminals: ttyclick", ttyclick }, + .{ "tty terminals: ttyedit", ttyedit }, + .{ "tty terminals: ttyfollow", ttyfollow }, + .{ "tty terminals: ttyhelp", ttyhelp }, + .{ "tty terminals: ttylook", ttylook }, + .{ "tty terminals: ttyonly", ttyonly }, + .{ "tty terminals: ttypaste", ttypaste }, + .{ "tty terminals: ttyprompt", ttyprompt }, + .{ "tty terminals: ttytaken", ttytaken }, + .{ "tty terminals: psearch", psearch }, + .{ "tty terminals: reflow", reflow }, + .{ "tty terminals: respawn", respawn }, + .{ "tty terminals: scroll", scroll }, + .{ "tty terminals: cmdexit", cmdexit }, + .{ "tty terminals: look-fd-deep", look_fd_deep }, + .{ "tty terminals: ghostty-mid", ghostty_mid }, + .{ "tty terminals: exec", exec }, + .{ "tty terminals: exec-bigdrag", exec_bigdrag }, +}; + +// tty mode round-trip: Ctrl-b in, run a command, Ctrl-b out. Ctrl-b is the one +// switch between raw and normal. Shift-Esc (CSI 27;2u — needs a host that +// reports modifiers on Escape) never switches: in every mode it is what Escape +// is in normal mode — Last, the pane you were in before this one — and a raw +// terminal stays raw. The hop itself is covered by a unit test in pardes.zig. +fn tty(gpa: std.mem.Allocator, exe: [:0]const u8) !void { + var t = try Tty.init(gpa, exe, "tty"); + defer t.deinit(); + try t.file("m.txt", "marker"); + try t.start(31, 100, &.{ "-n", "3" }); + try t.wait(8000, "m.txt"); + try t.stable(700, 20000); + try t.key("c-b"); + try t.stable(600, 8000); + try t.snap("tty-on"); + try t.send("echo SNAP''OK"); + try t.key("enter"); + try t.wait(8000, "SNAPOK"); + try t.stable(700, 10000); + try t.snap("tty-echo"); + try t.key("c-b"); + try t.stable(600, 8000); + try t.snap("tty-off"); + // Shift-Esc from normal: never into raw; it backs out to the previous pane. + try t.send("\x1b[27;2u"); + try t.stable(600, 8000); + try t.snap("shift-esc-normal"); + // Ctrl-b is the switch: into raw, and out again. + try t.key("c-b"); + try t.stable(600, 8000); + try t.snap("ctrl-b-on"); + try t.key("c-b"); + try t.stable(600, 8000); + try t.snap("ctrl-b-off"); + try t.done(); +} + +// clicks in a shell pane never change its mode: a body click in raw tty +// keeps tty (before: the press dropped it to normal), a round trip through the +// tag leaves it alone (the tag has a mode of its own), and an insert-mode body +// click re-pins the cursor but stays insert. File panes keep the old behavior (click -> normal). +// The mode is the character in each pane's layout box: `•` normal, `^` insert, +// `$` tty. +fn ttyclick(gpa: std.mem.Allocator, exe: [:0]const u8) !void { + var t = try Tty.init(gpa, exe, "ttyclick"); + defer t.deinit(); + try t.file("probe.txt", "marker"); + try t.start(31, 100, &.{ "-n", "3" }); + try t.wait(8000, "probe.txt"); + try t.stable(700, 20000); + try t.key("c-b"); + try t.stable(600, 8000); + // body click in raw tty: focus/selection only, the box stays `$` + try t.press("left", "10", 5); + try t.release("left", "10", 5); + try t.stable(400, 5000); + try t.snap("tty-bodyclick"); + // tag edit from tty: the box still reads `$` while the tag is typed into (the + // tag's mode is its own: a clicked tag is in normal mode), and `:` hands the keyboard back — a bug + // that lost the body's mode would show `•` in one snap or the other + try t.press("left", "@Term", 3); + try t.release("left", "@Term", 3); + try t.stable(400, 5000); + try t.snap("tty-tagedit"); + try t.key(":"); + try t.stable(400, 5000); + try t.snap("tty-tagexit"); + // out of tty, into insert: a body click moves the cursor but keeps INS + try t.key("c-b"); + try t.stable(600, 8000); + try t.key("i"); + try t.stable(400, 5000); + try t.press("left", "12", 5); + try t.release("left", "12", 5); + try t.stable(400, 5000); + try t.snap("ins-bodyclick"); + try t.done(); +} + +// editing a shell pane exactly like a document: Enter SPLITS the line under +// the cursor and pushes the shell rows below it down, `o` opens a fresh line, +// and backspace at column 0 joins back up. Before the edit buffer landed a +// terminal could only splice single-row insertion runs, so none of this was +// expressible. test/hxcases/parity.jsonl pins the keystroke-level equivalence +// with a file pane case for case; this is the end-to-end pty proof. +fn ttyedit(gpa: std.mem.Allocator, exe: [:0]const u8) !void { + var t = try Tty.init(gpa, exe, "ttyedit"); + defer t.deinit(); + try t.file("words.txt", "alpha beta"); + try t.start(31, 100, &.{ "-n", "3" }); + try t.wait(8000, "words.txt"); + try t.stable(700, 20000); + try t.key("c-b"); + try t.stable(600, 8000); + try t.send("printf 'one two three\\nfour five six\\nseven eight nine\\n'"); + try t.key("enter"); + try t.wait(8000, "seven"); + try t.stable(700, 10000); + try t.key("c-b"); + try t.stable(600, 8000); + // click into the middle of the first output row + try t.press("left", "8", 9); + try t.release("left", "8", 9); + try t.stable(400, 5000); + try t.snap("before"); + // Enter splits the row there: "one t" stays, "wo three" becomes a real line + // of its own and the two output rows below it slide down + try t.key("i enter"); + try t.stable(400, 5000); + try t.snap("split"); + try t.key("esc"); + try t.stable(400, 5000); + // `o` opens a line below the split's tail and pushes the rest down again + try t.key("o"); + try t.send("OPEN"); + try t.key("esc"); + try t.stable(400, 5000); + try t.snap("opened"); + // backspace at column 0 joins the opened line back onto its predecessor + try t.key("i home bs"); + try t.key("esc"); + try t.stable(400, 5000); + try t.snap("joined"); + // undo walks the whole session back out to untouched shell output + try t.key("u u u"); + try t.stable(400, 5000); + try t.snap("undone"); + try t.done(); +} + +// follow-output gate: a shell pane in normal/insert mode holds its scrolled-up +// view while new pty output streams in (before: only the ACTIVE pane held); +// back in tty mode output follows to the bottom again. Pane A parks a +// background job blocked on file `go`, pane B triggers it and syncs on `done1`. +fn ttyfollow(gpa: std.mem.Allocator, exe: [:0]const u8) !void { + var t = try Tty.init(gpa, exe, "ttyfollow"); + defer t.deinit(); + try t.file("s.txt", "x"); + try t.start(31, 100, &.{ "-n", "3" }); + try t.wait(8000, "s.txt"); + try t.stable(700, 20000); + try t.key("c-b"); + try t.stable(600, 8000); + try t.send("(until test -f go; do sleep 0.05; done; seq 201 260; touch done1) &"); + try t.key("enter"); + try t.stable(500, 8000); + try t.send("seq 1 200"); + try t.key("enter"); + try t.wait(8000, "199"); + try t.stable(700, 15000); + try t.key("c-b"); + try t.stable(600, 8000); + try t.wheel("up", "10", 8); + try t.wheel("up", "10", 8); + try t.wheel("up", "10", 8); + try t.stable(500, 8000); + try t.snap("held-pre"); + // focus pane B (right column), trigger A's job, sync on completion: A is now a + // NON-active normal-mode pane receiving output — its view must not move + try t.press("left", "60", 6); + try t.release("left", "60", 6); + try t.stable(400, 5000); + try t.key("c-b"); + try t.stable(600, 8000); + try t.send("touch go; until test -f done1; do sleep 0.05; done; echo SYN''CED"); + try t.key("enter"); + try t.wait(8000, "SYNCED"); + try t.stable(700, 15000); + try t.snap("held-post"); + // back in A, re-enter tty: the echoed keystrokes pull the view to the bottom + try t.press("left", "10", 9); + try t.release("left", "10", 9); + try t.stable(400, 5000); + try t.key("c-b"); + try t.stable(600, 8000); + try t.send("seq 261 300"); + try t.key("enter"); + try t.wait(8000, "300"); + try t.stable(700, 15000); + try t.snap("tty-follows"); + try t.done(); +} + +// bare boot = tty mode: SPC belongs to the shell, so the topbar Help word is +// the only route to the command list. Row 0 is not a pane, so a middle-click +// there is dispatched before any pane's mode is consulted. +fn ttyhelp(gpa: std.mem.Allocator, exe: [:0]const u8) !void { + var t = try Tty.init(gpa, exe, "ttyhelp"); + defer t.deinit(); + try t.start(31, 100, &.{}); + try t.wait(8000, "Newcol Joincol"); + try t.stable(700, 20000); + try t.snap("boot"); + try t.press("middle", "@Help", 1); + try t.release("middle", "@Help", 1); + try t.wait(10000, "pardes builtins"); + try t.stable(700, 15000); + try t.snap("helped"); + // and the shell is untouched: still TTY, still at its prompt. The click went to + // row 0, which is not a pane, so the terminal never saw it. + try t.key("c-b"); + try t.stable(600, 10000); + try t.key("space"); + try t.key("?"); + // The bare-tty boot now opens an empty pane under the shell, so the index is + // half as tall: wait on a row that is on screen. What the leader route + // produced is the snapshot below, not this. + try t.wait(10000, "SPC Y ClipYankMain"); + try t.stable(700, 15000); + try t.snap("leaderworks"); + try t.done(); +} + +// tty n/N token motion (normal mode only): n/N SELECT the next/prev +// whitespace-separated token that look resolves — several per line, so the +// greet ls row hops big.txt -> plain.txt -> sub — moving the cursor to the +// token start and opening NOTHING. Return looks the selection (dir -> the +// pane listing it, file -> pane) and focus follows what opened. The first +// n wraps from the prompt row to the first token; insert-mode n still +// types; and a pane with nothing look-able in it never traps the walk, +// because the walk is a RING ACROSS PANES rather than a scan of the one +// you are in. +fn ttylook(gpa: std.mem.Allocator, exe: [:0]const u8) !void { + var t = try Tty.init(gpa, exe, "ttylook"); + defer t.deinit(); + try t.lines("big.txt", 40, ""); + try t.file("plain.txt", "just text"); + try t.dir("sub"); + try t.start(31, 120, &.{ "-n", "3" }); + try t.wait(8000, "big.txt"); + try t.stable(700, 20000); + // first n: cursor sits at the shell prompt below the output — wrap lands on + // the ls row's first token, big.txt; nothing opens + try t.key("space j n"); + try t.stable(400, 5000); + try t.snap("tok1"); + try t.style("tok1"); + // same row, next token: plain.txt + try t.key("space j n"); + try t.stable(400, 5000); + try t.snap("tok2"); + // N steps back to big.txt + try t.key("space j p"); + try t.stable(400, 5000); + try t.snap("tokback"); + // insert-mode n still types (a run splice), no stepping; undo it + try t.key("i"); + try t.send("nn"); + try t.key("esc"); + try t.settle(100); + try t.stable(400, 5000); + try t.snap("insert"); + try t.key("u"); + try t.stable(400, 5000); + // resume the walk from big.txt's start: plain.txt, then sub + try t.key("space j n"); + try t.stable(400, 5000); + try t.key("space j n"); + try t.stable(400, 5000); + try t.snap("tok3"); + // Return looks the selected dir: sub's directory pane opens, empty as sub + // is, and takes the keyboard + try t.key("enter"); + try t.wait(10000, "sub/"); + try t.stable(700, 15000); + try t.snap("diropen"); + // the fresh pane lists nothing, sub being empty, and that is not where n + // stops: the ring is spun on the panes that have LOOKED, so the step leaves + // this pane for the one it was looked out of. That pane's cursor is on its + // last token (`sub`), so the walk runs off the end and comes round to its + // first — big.txt. + try t.key("space j n"); + try t.stable(400, 5000); + try t.snap("noop"); + // back in the first pane, Enter with the cursor ON a token looks it (no + // selection: the cursor word expands): the click puts it on the ls command + // line's `ls`, a word no file names, which a terminal lists in a +Search, + // its row the place in that terminal (@p1:1:1-2) + try t.press("left", "4", 5); + try t.release("left", "4", 5); + try t.stable(400, 5000); + try t.key("enter"); + try t.wait(10000, "@p1:1:1-2"); + try t.stable(700, 15000); + try t.snap("cursorword"); + try t.done(); +} + +// --tty: a single fullscreen shell already in raw tty mode, prompts visible +fn ttyonly(gpa: std.mem.Allocator, exe: [:0]const u8) !void { + var t = try Tty.init(gpa, exe, "ttyonly"); + defer t.deinit(); + try t.file("t.txt", "x"); + try t.start(31, 100, &.{"--tty"}); + try t.wait(8000, "$"); + try t.stable(700, 20000); + try t.send("echo TTY''ONLY"); + try t.key("enter"); + try t.wait(8000, "TTYONLY"); + try t.stable(700, 10000); + try t.snap("ttyonly"); + try t.style("ttyonly"); + try t.done(); +} + +// Pasting INTO the program a tty pane is running. +// +// `SPC p` and the acme 1-3 chord are both unreachable in raw tty: the pty owns +// every keystroke and every button. So tty mode has its own chord, and a paste +// arriving from outside has to reach the shell rather than an edit buffer that +// the pty does not know exists. +// +// Two paths, both ending at the shell's command line: +// Ctrl-V types the DEFAULT register (config.tty_paste) +// bracketed paste the outer terminal's own paste, or a desktop one relayed +// by a GUI host, which used to land in an overlay instead +fn ttypaste(gpa: std.mem.Allocator, exe: [:0]const u8) !void { + var t = try Tty.init(gpa, exe, "ttypaste"); + defer t.deinit(); + try t.file("src.txt", "PASTED-PAYLOAD"); + try t.start(31, 100, &.{ "-n", "3" }); + try t.wait(8000, "src.txt"); + try t.stable(700, 20000); + // fill the default register from a file pane: sweep the word and yank it + try t.key("c-b"); + try t.stable(600, 8000); + // in tty now; type a prefix so the pasted text is visibly appended to it + try t.send("echo"); + try t.stable(600, 8000); + // the outer terminal's bracketed paste: not a keystroke, no request behind it, + // and it must arrive at the shell's line + try t.send("\x1b[200~ BRACKETED\x1b[201~"); + try t.stable(600, 8000); + try t.snap("bracketed-paste-reached-the-shell"); + // Ctrl-V types the register. Nothing was yanked in this session, so the + // register is empty and the chord is INERT rather than sending the shell the + // 0x16 it used to (quoted-insert): the line below is unchanged. + try t.key("c-v"); + try t.stable(600, 8000); + try t.snap("ctrl-v-with-empty-register-is-inert"); + try t.done(); +} + +// Leaving raw tty hides the shell's PROMPT and keeps the command typed at it. +// +// The two share one grid row, so blanking the row used to take the command with +// the prompt and a shell out of tty read as output only. OSC 133 marks the row +// CELL by cell, so config.tty_blank = .prompt cuts the prompt's own columns and +// left-hugs what is left: the command lands at column 0, in line with the +// output under it, rather than in a bay of blanks the prompt used to fill. +// +// `.prompt_and_input` is the old behaviour and blanks the whole row; it is a +// comptime choice, so what THIS script pins is the default. +fn ttyprompt(gpa: std.mem.Allocator, exe: [:0]const u8) !void { + var t = try Tty.init(gpa, exe, "ttyprompt"); + defer t.deinit(); + try t.file("probe.txt", "marker"); + try t.start(31, 100, &.{ "-n", "3" }); + try t.wait(8000, "probe.txt"); + try t.stable(700, 20000); + // the greeting `ls` was typed at a prompt and already shows the rule: the + // command is there, the prompt in front of it is not + try t.snap("greeted"); + // into tty and type a command WITHOUT submitting it, so the shell is sitting at + // a prompt with input on it — the case the old behaviour erased + try t.key("c-b"); + try t.stable(600, 8000); + try t.send("echo ABCDEFGH"); + try t.stable(600, 8000); + try t.snap("in-tty"); + // ...and out: the prompt goes, `echo ABCDEFGH` stays, hugging the left edge + try t.key("c-b"); + try t.stable(600, 8000); + try t.snap("out-of-tty"); + // The columns still have to reach the shell, and they do: the modal cursor's + // column on a hidden-prompt row is short by exactly the prompt's width, so + // enterTty adds it back before asking ghostty to walk the shell's own cursor + // there. That arithmetic is pinned by the "entering tty walks the shell cursor" + // unit test, which can put a pinned cursor on a known column; a click here + // cannot, because leaving tty unpins and a body click on a terminal does not + // pin it again. + try t.done(); +} + +// Process monitoring, end to end. A terminal whose tty is held by a +// full-screen program is not somewhere a command line may be typed: the SAME +// Exec from that terminal goes into its shell while it sits at its prompt, +// and into a command pane of its own once `less` owns the terminal -- where +// it runs, instead of becoming keystrokes the pager would eat. Nothing about +// the pager's screen changes. (From any pane but a terminal, an Exec always +// runs as a command pane: exec.snap.) +fn ttytaken(gpa: std.mem.Allocator, exe: [:0]const u8) !void { + var t = try Tty.init(gpa, exe, "ttytaken"); + defer t.deinit(); + try t.lines("big.txt", 40, ""); + try t.start(31, 210, &.{ "-n", "1" }); + try t.wait(8000, "big.txt"); + try t.stable(700, 20000); + try t.snap("opened"); + // at the prompt: a command word in the terminal's own tag, executed, is + // typed into its shell. `:` opens the tag, `A` appends, and the execute key + // runs the word under the cursor. + try t.key(":"); + try t.key("A"); + try t.key("space"); + try t.send("@`echo TAKEN''ONE`"); + try t.key("esc"); + try t.settle(100); + try t.key("h"); + try t.key("tab"); + try t.wait(10000, "TAKENONE"); + try t.stable(700, 20000); + try t.snap("at-prompt"); + // ...and now a pager owns that terminal. Ctrl-b is raw tty + // (config.tty_toggle), which is how a script types AT the shell instead of + // into the pane's own edit buffer. + try t.key("c-b"); + try t.stable(400, 5000); + try t.send("env LESS= less big.txt"); + try t.key("enter"); + try t.wait(10000, "line 1"); + try t.stable(700, 20000); + try t.key("c-b"); + try t.stable(400, 5000); + try t.snap("paging"); + // the same gesture from that terminal: a command pane, not `less` keystrokes + try t.key(":"); + try t.key("A"); + try t.key("space"); + try t.send("@`echo TAKEN''TWO`"); + try t.key("esc"); + try t.settle(100); + try t.key("h"); + try t.key("tab"); + try t.wait(10000, "TAKENTWO"); + try t.stable(700, 20000); + try t.snap("spawned"); + try t.done(); +} + +// `/` search on a TERMINAL pane: the same tag input as a file pane, searching +// the shell's own scrollback (the plain text view Look reads, prompt rows +// hidden). Results land in a +Search OUTPUT BUFFER — a file pane with no file +// behind it, so its tag has no Save — and point at `@p1:LINE:COL-ENDCOL` (the terminal's serial), the +// look target that names a live pane, since a terminal has no path. n/N SELECT +// the next/prev row in the buffer and open nothing; Enter — the look chord — +// is what scrolls the terminal to that line of its scrollback and selects the +// span the row names. +// PLACEMENT, and this script is the proof: an output buffer is NOT a document +// — it is the result list of the pane that asked for it — so even here, with no +// doc pane in the session for it to join, it does NOT take a column of its own. +// It splits BELOW the shell it came from: every snap below stays ONE column, +// the shell's tag and the +Search tag both starting at x=0, thirty rows split +// between them, and nothing shifts sideways. +fn psearch(gpa: std.mem.Allocator, exe: [:0]const u8) !void { + var t = try Tty.init(gpa, exe, "psearch"); + defer t.deinit(); + try t.start(31, 140, &.{}); + try t.wait(8000, "Newcol Joincol"); + try t.stable(700, 20000); + // print something to search (a bare boot starts in tty mode; the marker is + // split so the echoed command line, which normal mode hides anyway, can never + // be the thing that matched) + try t.send("printf 'x MA''RK a\\nzz\\nx MA''RK b\\nzz\\nx MA''RK c\\n'"); + try t.key("enter"); + try t.wait(10000, "MARK c"); + try t.stable(700, 10000); + try t.key("c-b"); + try t.stable(600, 8000); + try t.snap("output"); + // / types the pattern into the terminal's tag exactly as on a file pane + try t.key("/"); + try t.stable(400, 5000); + try t.send("MARK"); + try t.stable(400, 5000); + try t.snap("typing"); + // Enter opens the results buffer — three @p1:LINE:COL rows — and goes to the + // first of them: the terminal's cursor lands on that scrollback line, on the + // matched SPAN (cols 3..6, past the leading "x ") — not the start of the line, + // and selected rather than merely parked on. No `n` was pressed to get here. + try t.key("enter"); + try t.wait(10000, "@p1:2:3"); + try t.stable(700, 15000); + try t.snap("results"); + try t.style("results"); + // n walks on to the next row, Enter looks it + try t.key("space j n"); + try t.key("enter"); + try t.stable(700, 15000); + try t.snap("second"); + // N walks back one row, Enter looks it + try t.key("space j p"); + try t.key("enter"); + try t.stable(700, 15000); + try t.snap("back"); + // a no-match search opens an empty buffer of its own — and n does not stop + // there. The walk is a RING across panes, not one buffer's rows, so with + // nothing look-able in the empty list it carries on into the one that does + // have rows and resumes it a row past where the N above left off. + try t.key("/"); + try t.send("zzqq"); + try t.key("enter"); + try t.stable(700, 10000); + try t.key("space j n"); + try t.stable(400, 5000); + try t.snap("nomatch"); + // right-clicking a word that names no file is the same search (acme button 3), + // but NOT in tty mode: there the click belongs to the program on the other end, + // so the buffer stays empty. Col 5 row 4 is the `M` of the first `x MARK a`, + // in the shell's body in both modes (normal hides the prompt row, leaving it + // blank, so the output rows sit at the same place either way). + // The left click first is the price of the step above: it left the cursor in + // the results buffer, and c-b is read by the ACTIVE pane — there is no tty + // behind a +Search to toggle. + try t.press("left", "5", 5); + try t.release("left", "5", 5); + try t.stable(400, 5000); + try t.key("c-b"); + try t.stable(600, 8000); + try t.press("right", "5", 5); + try t.release("right", "5", 5); + try t.stable(700, 10000); + try t.snap("ttyinert"); + // back in normal mode the same click searches for MARK + try t.key("c-b"); + try t.stable(600, 8000); + try t.press("right", "5", 5); + try t.release("right", "5", 5); + try t.wait(10000, "@p1:2:3"); + try t.stable(700, 15000); + try t.snap("rightsearch"); + try t.done(); +} + +// Widening a window whose scrollback holds WRAPPED lines, with the viewport +// scrolled into history: ghostty's resizeCols unwraps, then grows rows while +// the history viewport pin is still short, and its Debug-only PageList +// integrity check panicked the whole app ("ViewportPinInsufficientRows"). +// build.zig now pins the ghostty dependency at ReleaseSafe so those +// development-only checks are off — the app's own safety checks are unchanged. +fn reflow(gpa: std.mem.Allocator, exe: [:0]const u8) !void { + var t = try Tty.init(gpa, exe, "reflow"); + defer t.deinit(); + try t.start(25, 40, &.{}); + try t.wait(8000, "$"); + try t.send("printf 'y%.0s' $(seq 1 3000); echo do''ne"); + try t.key("enter"); + try t.stable(600, 15000); + try t.stable(700, 15000); + try t.wheel("up", "10", 10); + try t.wheel("up", "10", 10); + try t.wheel("up", "10", 10); + try t.wheel("up", "10", 10); + try t.stable(500, 8000); + try t.resize(25, 200); + try t.stable(700, 15000); + try t.snap("widened"); + try t.done(); +} + +// a deleted shell pane's pty lingers in its slot (there is no close effect); +// a later spawn reusing the pane id must reap it instead of tripping the +// drainEffects spawn assert — this exact sequence crashed pre-fix +fn respawn(gpa: std.mem.Allocator, exe: [:0]const u8) !void { + var t = try Tty.init(gpa, exe, "respawn"); + defer t.deinit(); + try t.start(31, 140, &.{ "-n", "3" }); + try t.wait(8000, "Newcol Joincol"); + try t.stable(700, 20000); + // middle-click Del on the lower-left pane's tag: the pane id is freed while + // its shell process stays alive in the slot + try t.press("middle", "@Collapse+9", 18); + try t.release("middle", "@Collapse+9", 18); + try t.stable(700, 10000); + // Alt-n reuses the freed id -> spawn effect lands on the occupied slot + try t.key("a-n"); + try t.stable(700, 15000); + try t.key("c-b"); + try t.stable(600, 8000); + try t.send("echo RESP''AWNOK"); + try t.key("enter"); + try t.wait(10000, "RESPAWNOK"); + try t.stable(700, 10000); + try t.snap("respawn"); + try t.done(); +} + +// scrolling: wheel + scrollbar gutter clicks over real scrollback +fn scroll(gpa: std.mem.Allocator, exe: [:0]const u8) !void { + var t = try Tty.init(gpa, exe, "scroll"); + defer t.deinit(); + try t.file("s.txt", "x"); + try t.start(31, 100, &.{ "-n", "3" }); + try t.wait(8000, "s.txt"); + try t.stable(700, 20000); + try t.key("c-b"); + try t.stable(600, 8000); + try t.send("seq 1 200"); + try t.key("enter"); + try t.wait(8000, "199"); + try t.stable(700, 15000); + try t.key("c-b"); + try t.stable(600, 8000); + try t.snap("bottom"); + try t.wheel("up", "10", 8); + try t.wheel("up", "10", 8); + try t.wheel("up", "10", 8); + try t.stable(500, 8000); + try t.snap("wheel3"); + try t.press("left", "1", 12); + try t.release("left", "1", 12); + try t.stable(500, 8000); + try t.snap("gutter-up"); + try t.press("right", "1", 7); + try t.release("right", "1", 7); + try t.stable(500, 8000); + try t.snap("gutter-down"); + try t.wheel("down", "10", 8); + try t.stable(500, 8000); + try t.snap("wheel-down"); + try t.style("wheel-down"); + try t.done(); +} + +// A command pane's command is over when its process exits, not when its pty +// closes. A job it leaves in the background holds the pty open, and the pane +// still says `exit 0` as soon as the command itself is done; a command that +// lets go of its terminal and runs on is not hung up at its pty's end, and +// says how it ended when it does. +fn cmdexit(gpa: std.mem.Allocator, exe: [:0]const u8) !void { + var t = try Tty.init(gpa, exe, "cmdexit"); + defer t.deinit(); + try t.file("cmds.txt", "sleep 30 & echo BG''STARTED\nexec </dev/null >/dev/null 2>&1; sleep 1; false"); + try t.config("Verbose off"); + try t.start(31, 120, &.{"cmds.txt"}); + try t.wait(8000, "cmds.txt"); + try t.stable(700, 20000); + try t.snap("opened"); + // line 1: `sleep 30` keeps the pty, and the pane says exit 0 regardless + try t.press("middle", "7", 4); + try t.drag("middle", "34", 4); + try t.release("middle", "34", 4); + try t.wait(10000, "exit 0"); + try t.stable(700, 15000); + try t.snap("background"); + // line 2, in a second pane: the first's command is done but its background + // `sleep 30` lives on (job control gives it its own group) and still holds + // that pane's pty; here the end of file comes at once, and the exit a second + // later, from `false` + try t.press("middle", "7", 5); + try t.drag("middle", "54", 5); + try t.release("middle", "54", 5); + try t.wait(10000, "exit 1"); + try t.stable(700, 15000); + try t.snap("letgo"); + try t.done(); +} + +// A shell run under a wrapper exec'd over the one pardes started, that +// stays where it started (fish's own `exec 9ns --mntgen -- fish`; timeout +// here): after a cd the pane is where the foreground shell is, not where +// the wrapper is. So a path fd prints two +// directories down (b/c.txt) and a name ls prints (top.txt) look from there. +// The fd path goes first: the file it opens sits in a/b, a directory that +// could not rescue the ls name after it. +fn look_fd_deep(gpa: std.mem.Allocator, exe: [:0]const u8) !void { + var t = try Tty.init(gpa, exe, "look-fd-deep"); + defer t.deinit(); + try t.dir("a"); + try t.dir("a/b"); + try t.file("a/top.txt", "top-marker"); + try t.file("a/b/c.txt", "deep-marker"); + try t.start(31, 100, &.{}); + try t.wait(8000, "$"); + try t.stable(700, 20000); + try t.send("exec timeout --foreground 600 bash -i"); + try t.key("enter"); + try t.stable(700, 20000); + try t.send("cd a && ls && fd"); + try t.key("enter"); + try t.wait(8000, "c.txt"); + try t.wait(8000, "cwd/a Term"); + try t.stable(700, 20000); + try t.snap("listed"); + try t.press("right", "6", 8); + try t.release("right", "6", 8); + try t.wait(10000, "deep-marker"); + try t.stable(700, 15000); + try t.snap("fd-path-looked"); + // the ls name, from the shell's directory + try t.press("right", "8", 6); + try t.release("right", "8", 6); + try t.wait(10000, "top-marker"); + try t.stable(700, 15000); + try t.snap("ls-name-looked"); + try t.done(); +} + +// ghostty's wire flavor of a middle click, byte-exact (mode 1002;1003;1004;1006 +// as pardes requests): focus-in, per-cell hover motions (ghostty dedups per +// cell, so none repeat), press keeping SGR button identity, release 'm', +// trailing hover — split across writes like real input. Proves the tty input +// path (vaxis parse -> core execute) handles ghostty's encoding: the live bug +// ("middle click dead only in ghostty") is ghostty's GTK apprt swallowing +// middle press+release BEFORE mouse reporting whenever the desktop has +// gtk-enable-primary-paste=false (apprt/gtk/class/surface.zig, gcMouseDown/ +// gcMouseUp) — the bytes below simply never get sent. +fn ghostty_mid(gpa: std.mem.Allocator, exe: [:0]const u8) !void { + var t = try Tty.init(gpa, exe, "ghostty-mid"); + defer t.deinit(); + try t.file("g.txt", "x"); + try t.start(31, 100, &.{ "-n", "3" }); + try t.wait(8000, "g.txt"); + try t.stable(700, 20000); + try t.press("left", "5", 9); + try t.release("left", "5", 9); + try t.stable(400, 5000); + try t.key("c-b"); + try t.stable(600, 8000); + try t.send("printf '#!/bin/sh\\necho GHOST''OK\\n' > g.sh; chmod +x g.sh; clear; printf 'ZZPAD\\n./g.sh\\n'"); + try t.key("enter"); + try t.wait(10000, "./g.sh"); + try t.stable(700, 10000); + try t.key("c-b"); + try t.stable(600, 8000); + try t.send("\x1b[I"); + try t.send("\x1b[<35;10;10M\x1b[<35;7;8M\x1b[<35;4;6M"); + try t.send("\x1b[<1;4;6M"); + try t.send("\x1b[<1;4;6m"); + try t.send("\x1b[<35;6;6M"); + try t.wait(10000, "GHOSTOK"); + try t.stable(700, 10000); + try t.snap("ghostty-mid"); + try t.done(); +} + +// middle-drag executes the selection in the pane's shell; a left press during +// the middle drag captures the kept left selection as a trailing argument; +// middle-click Del on the pane tag closes the pane +fn exec(gpa: std.mem.Allocator, exe: [:0]const u8) !void { + var t = try Tty.init(gpa, exe, "exec"); + defer t.deinit(); + try t.file("e.txt", "x"); + try t.start(31, 140, &.{ "-n", "3" }); + try t.wait(8000, "e.txt"); + try t.stable(700, 20000); + try t.press("left", "5", 9); + try t.release("left", "5", 9); + try t.stable(400, 5000); + try t.key("i"); + try t.send("echo MID''OK"); + try t.key("esc"); + try t.settle(100); + try t.stable(400, 5000); + try t.press("middle", "5", 9); + try t.drag("middle", "16", 9); + try t.release("middle", "16", 9); + try t.wait(10000, "MIDOK"); + try t.stable(700, 10000); + try t.snap("exec"); + // chord (canonical sequence, as in the prototype e2e): print an arg word and a + // script path, left-drag-keep the arg, then middle-press on the path + left + // press (captures) + middle release (runs with the arg appended) + try t.key("c-b"); + try t.stable(600, 8000); + try t.send("printf '#!/bin/sh\\necho CHORDARG:\"$1\"\\n' > c.sh; chmod +x c.sh; clear; printf 'ZZARG\\n./c.sh\\n'"); + try t.key("enter"); + try t.wait(10000, "./c.sh"); + try t.stable(700, 10000); + try t.key("c-b"); + try t.stable(600, 8000); + try t.press("left", "3", 4); + try t.drag("left", "7", 4); + try t.release("left", "7", 4); + try t.stable(400, 5000); + try t.snap("kept"); + try t.send("\x1b[<1;4;5M\x1b[<0;4;5M\x1b[<1;4;5m"); + try t.wait(10000, "CHORDARG:ZZARG"); + try t.stable(700, 10000); + try t.snap("chord"); + // middle-click Del in THIS pane's tag: row 2 carries both panes' tags, so the + // occurrence is spelled out rather than left to the leftmost-match default + try t.press("middle", "@Del#1", 3); + try t.release("middle", "@Del#1", 3); + try t.stable(700, 10000); + try t.snap("deleted"); + try t.done(); +} + +// a giant accidental middle-drag: the whole selection is executed, chunked +// into 64-byte write effects in ONE update — this used to burst the fixed +// 64-slot effect ring and panic the core (assert in emit). Needs a big grid: +// the selection must exceed 64*64 bytes, more than any 30x100 pane can hold. +fn exec_bigdrag(gpa: std.mem.Allocator, exe: [:0]const u8) !void { + var t = try Tty.init(gpa, exe, "exec-bigdrag"); + defer t.deinit(); + try t.lines("big.txt", 3000, ""); + // Builtins announce themselves by default, and an announcement is a band at + // the top of the body -- which moves every row this script clicks. What the + // verbs do is what is under test, not the announcement. + try t.config("Verbose off"); + try t.start(61, 200, &.{ "-n", "3" }); + try t.wait(8000, "big.txt"); + try t.stable(500, 20000); + try t.press("left", "105", 9); + try t.release("left", "105", 9); + try t.stable(300, 5000); + try t.key("i"); + try t.send("tr -d '\\n' < big.txt"); + try t.key("esc"); + try t.settle(100); + try t.press("middle", "105", 9); + try t.drag("middle", "126", 9); + try t.release("middle", "126", 9); + try t.stable(800, 30000); + // the accidental sweep over the full-height right pane, then release + try t.press("middle", "105", 5); + try t.drag("middle", "150", 31); + try t.drag("middle", "198", 59); + try t.release("middle", "198", 59); + try t.stable(500, 8000); + try t.stable(800, 30000); + // still alive: type and execute a marker command + try t.press("left", "105", 41); + try t.release("left", "105", 41); + try t.stable(300, 5000); + try t.key("i"); + try t.send("echo alive-o''k"); + try t.key("esc"); + try t.settle(100); + try t.press("middle", "105", 41); + try t.drag("middle", "119", 41); + try t.release("middle", "119", 41); + try t.wait(10000, "alive-ok"); + try t.stable(800, 20000); + try t.snap("alive"); + try t.done(); +} diff --git a/test/snapshots/cmdexit.snap b/test/snapshots/cmdexit.snap deleted file mode 100644 index e9f39bfd..00000000 --- a/test/snapshots/cmdexit.snap +++ /dev/null @@ -1,28 +0,0 @@ -# A command pane's command is over when its process exits, not when its pty -# closes. A job it leaves in the background holds the pty open, and the pane -# still says `exit 0` as soon as the command itself is done; a command that -# lets go of its terminal and runs on is not hung up at its pty's end, and -# says how it ended when it does. -file cmds.txt sleep 30 & echo BG''STARTED\nexec </dev/null >/dev/null 2>&1; sleep 1; false -config Verbose off -start 31 120 cmds.txt -wait 8000 cmds.txt -stable 700 20000 -snap opened -# line 1: `sleep 30` keeps the pty, and the pane says exit 0 regardless -press middle 7 4 -drag middle 34 4 -release middle 34 4 -wait 10000 exit 0 -stable 700 15000 -snap background -# line 2, in a second pane: the first's command is done but its background -# `sleep 30` lives on (job control gives it its own group) and still holds -# that pane's pty; here the end of file comes at once, and the exit a second -# later, from `false` -press middle 7 5 -drag middle 54 5 -release middle 54 5 -wait 10000 exit 1 -stable 700 15000 -snap letgo diff --git a/test/snapshots/exec-bigdrag.snap b/test/snapshots/exec-bigdrag.snap deleted file mode 100644 index 35881190..00000000 --- a/test/snapshots/exec-bigdrag.snap +++ /dev/null @@ -1,44 +0,0 @@ -# a giant accidental middle-drag: the whole selection is executed, chunked -# into 64-byte write effects in ONE update — this used to burst the fixed -# 64-slot effect ring and panic the core (assert in emit). Needs a big grid: -# the selection must exceed 64*64 bytes, more than any 30x100 pane can hold. -lines big.txt 3000 -# Builtins announce themselves by default, and an announcement is a band at -# the top of the body -- which moves every row this script clicks. What the -# verbs do is what is under test, not the announcement. -config Verbose off -start 61 200 -n 3 -wait 8000 big.txt -stable 500 20000 -press left 105 9 -release left 105 9 -stable 300 5000 -key i -text tr -d '\n' < big.txt -key esc -settle 100 -press middle 105 9 -drag middle 126 9 -release middle 126 9 -stable 800 30000 -# the accidental sweep over the full-height right pane, then release -press middle 105 5 -drag middle 150 31 -drag middle 198 59 -release middle 198 59 -stable 500 8000 -stable 800 30000 -# still alive: type and execute a marker command -press left 105 41 -release left 105 41 -stable 300 5000 -key i -text echo alive-o''k -key esc -settle 100 -press middle 105 41 -drag middle 119 41 -release middle 119 41 -wait 10000 alive-ok -stable 800 20000 -snap alive diff --git a/test/snapshots/exec.snap b/test/snapshots/exec.snap deleted file mode 100644 index a0820c19..00000000 --- a/test/snapshots/exec.snap +++ /dev/null @@ -1,47 +0,0 @@ -# middle-drag executes the selection in the pane's shell; a left press during -# the middle drag captures the kept left selection as a trailing argument; -# middle-click Del on the pane tag closes the pane -file e.txt x -start 31 140 -n 3 -wait 8000 e.txt -stable 700 20000 -press left 5 9 -release left 5 9 -stable 400 5000 -key i -text echo MID''OK -key esc -settle 100 -stable 400 5000 -press middle 5 9 -drag middle 16 9 -release middle 16 9 -wait 10000 MIDOK -stable 700 10000 -snap exec -# chord (canonical sequence, as in the prototype e2e): print an arg word and a -# script path, left-drag-keep the arg, then middle-press on the path + left -# press (captures) + middle release (runs with the arg appended) -key c-b -stable 600 8000 -text printf '#!/bin/sh\necho CHORDARG:"$1"\n' > c.sh; chmod +x c.sh; clear; printf 'ZZARG\n./c.sh\n' -key enter -wait 10000 ./c.sh -stable 700 10000 -key c-b -stable 600 8000 -press left 3 4 -drag left 7 4 -release left 7 4 -stable 400 5000 -snap kept -send \x1b[<1;4;5M\x1b[<0;4;5M\x1b[<1;4;5m -wait 10000 CHORDARG:ZZARG -stable 700 10000 -snap chord -# middle-click Del in THIS pane's tag: row 2 carries both panes' tags, so the -# occurrence is spelled out rather than left to the leftmost-match default -press middle @Del#1 3 -release middle @Del#1 3 -stable 700 10000 -snap deleted diff --git a/test/snapshots/ghostty-mid.snap b/test/snapshots/ghostty-mid.snap deleted file mode 100644 index c20db2f7..00000000 --- a/test/snapshots/ghostty-mid.snap +++ /dev/null @@ -1,32 +0,0 @@ -# ghostty's wire flavor of a middle click, byte-exact (mode 1002;1003;1004;1006 -# as pardes requests): focus-in, per-cell hover motions (ghostty dedups per -# cell, so none repeat), press keeping SGR button identity, release 'm', -# trailing hover — split across writes like real input. Proves the tty input -# path (vaxis parse -> core execute) handles ghostty's encoding: the live bug -# ("middle click dead only in ghostty") is ghostty's GTK apprt swallowing -# middle press+release BEFORE mouse reporting whenever the desktop has -# gtk-enable-primary-paste=false (apprt/gtk/class/surface.zig, gcMouseDown/ -# gcMouseUp) — the bytes below simply never get sent. -file g.txt x -start 31 100 -n 3 -wait 8000 g.txt -stable 700 20000 -press left 5 9 -release left 5 9 -stable 400 5000 -key c-b -stable 600 8000 -text printf '#!/bin/sh\necho GHOST''OK\n' > g.sh; chmod +x g.sh; clear; printf 'ZZPAD\n./g.sh\n' -key enter -wait 10000 ./g.sh -stable 700 10000 -key c-b -stable 600 8000 -send \x1b[I -send \x1b[<35;10;10M\x1b[<35;7;8M\x1b[<35;4;6M -send \x1b[<1;4;6M -send \x1b[<1;4;6m -send \x1b[<35;6;6M -wait 10000 GHOSTOK -stable 700 10000 -snap ghostty-mid diff --git a/test/snapshots/look-fd-deep.snap b/test/snapshots/look-fd-deep.snap deleted file mode 100644 index d9e5ac06..00000000 --- a/test/snapshots/look-fd-deep.snap +++ /dev/null @@ -1,34 +0,0 @@ -# A shell run under a wrapper exec'd over the one pardes started, that -# stays where it started (fish's own `exec 9ns --mntgen -- fish`; timeout -# here): after a cd the pane is where the foreground shell is, not where -# the wrapper is. So a path fd prints two -# directories down (b/c.txt) and a name ls prints (top.txt) look from there. -# The fd path goes first: the file it opens sits in a/b, a directory that -# could not rescue the ls name after it. -dirmk a -dirmk a/b -file a/top.txt top-marker -file a/b/c.txt deep-marker -start 31 100 -wait 8000 $ -stable 700 20000 -text exec timeout --foreground 600 bash -i -key enter -stable 700 20000 -text cd a && ls && fd -key enter -wait 8000 c.txt -wait 8000 cwd/a Term -stable 700 20000 -snap listed -press right 6 8 -release right 6 8 -wait 10000 deep-marker -stable 700 15000 -snap fd-path-looked -# the ls name, from the shell's directory -press right 8 6 -release right 8 6 -wait 10000 top-marker -stable 700 15000 -snap ls-name-looked diff --git a/test/snapshots/psearch.snap b/test/snapshots/psearch.snap deleted file mode 100644 index d55fe833..00000000 --- a/test/snapshots/psearch.snap +++ /dev/null @@ -1,88 +0,0 @@ -# `/` search on a TERMINAL pane: the same tag input as a file pane, searching -# the shell's own scrollback (the plain text view Look reads, prompt rows -# hidden). Results land in a +Search OUTPUT BUFFER — a file pane with no file -# behind it, so its tag has no Save — and point at `@p1:LINE:COL-ENDCOL` (the terminal's serial), the -# look target that names a live pane, since a terminal has no path. n/N SELECT -# the next/prev row in the buffer and open nothing; Enter — the look chord — -# is what scrolls the terminal to that line of its scrollback and selects the -# span the row names. -# PLACEMENT, and this script is the proof: an output buffer is NOT a document -# — it is the result list of the pane that asked for it — so even here, with no -# doc pane in the session for it to join, it does NOT take a column of its own. -# It splits BELOW the shell it came from: every snap below stays ONE column, -# the shell's tag and the +Search tag both starting at x=0, thirty rows split -# between them, and nothing shifts sideways. -start 31 140 -wait 8000 Newcol Joincol -stable 700 20000 -# print something to search (a bare boot starts in tty mode; the marker is -# split so the echoed command line, which normal mode hides anyway, can never -# be the thing that matched) -text printf 'x MA''RK a\nzz\nx MA''RK b\nzz\nx MA''RK c\n' -key enter -wait 10000 MARK c -stable 700 10000 -key c-b -stable 600 8000 -snap output -# / types the pattern into the terminal's tag exactly as on a file pane -key / -stable 400 5000 -text MARK -stable 400 5000 -snap typing -# Enter opens the results buffer — three @p1:LINE:COL rows — and goes to the -# first of them: the terminal's cursor lands on that scrollback line, on the -# matched SPAN (cols 3..6, past the leading "x ") — not the start of the line, -# and selected rather than merely parked on. No `n` was pressed to get here. -key enter -wait 10000 @p1:2:3 -stable 700 15000 -snap results -snapstyle results -# n walks on to the next row, Enter looks it -key space j n -key enter -stable 700 15000 -snap second -# N walks back one row, Enter looks it -key space j p -key enter -stable 700 15000 -snap back -# a no-match search opens an empty buffer of its own — and n does not stop -# there. The walk is a RING across panes, not one buffer's rows, so with -# nothing look-able in the empty list it carries on into the one that does -# have rows and resumes it a row past where the N above left off. -key / -text zzqq -key enter -stable 700 10000 -key space j n -stable 400 5000 -snap nomatch -# right-clicking a word that names no file is the same search (acme button 3), -# but NOT in tty mode: there the click belongs to the program on the other end, -# so the buffer stays empty. Col 5 row 4 is the `M` of the first `x MARK a`, -# in the shell's body in both modes (normal hides the prompt row, leaving it -# blank, so the output rows sit at the same place either way). -# The left click first is the price of the step above: it left the cursor in -# the results buffer, and c-b is read by the ACTIVE pane — there is no tty -# behind a +Search to toggle. -press left 5 5 -release left 5 5 -stable 400 5000 -key c-b -stable 600 8000 -press right 5 5 -release right 5 5 -stable 700 10000 -snap ttyinert -# back in normal mode the same click searches for MARK -key c-b -stable 600 8000 -press right 5 5 -release right 5 5 -wait 10000 @p1:2:3 -stable 700 15000 -snap rightsearch diff --git a/test/snapshots/reflow.snap b/test/snapshots/reflow.snap deleted file mode 100644 index 7aac1e8c..00000000 --- a/test/snapshots/reflow.snap +++ /dev/null @@ -1,20 +0,0 @@ -# Widening a window whose scrollback holds WRAPPED lines, with the viewport -# scrolled into history: ghostty's resizeCols unwraps, then grows rows while -# the history viewport pin is still short, and its Debug-only PageList -# integrity check panicked the whole app ("ViewportPinInsufficientRows"). -# build.zig now pins the ghostty dependency at ReleaseSafe so those -# development-only checks are off — the app's own safety checks are unchanged. -start 25 40 -wait 8000 $ -text printf 'y%.0s' $(seq 1 3000); echo do''ne -key enter -stable 600 15000 -stable 700 15000 -wheel up 10 10 -wheel up 10 10 -wheel up 10 10 -wheel up 10 10 -stable 500 8000 -resize 25 200 -stable 700 15000 -snap widened diff --git a/test/snapshots/respawn.snap b/test/snapshots/respawn.snap deleted file mode 100644 index e0ebea13..00000000 --- a/test/snapshots/respawn.snap +++ /dev/null @@ -1,21 +0,0 @@ -# a deleted shell pane's pty lingers in its slot (there is no close effect); -# a later spawn reusing the pane id must reap it instead of tripping the -# drainEffects spawn assert — this exact sequence crashed pre-fix -start 31 140 -n 3 -wait 8000 Newcol Joincol -stable 700 20000 -# middle-click Del on the lower-left pane's tag: the pane id is freed while -# its shell process stays alive in the slot -press middle @Collapse+9 18 -release middle @Collapse+9 18 -stable 700 10000 -# Alt-n reuses the freed id -> spawn effect lands on the occupied slot -key a-n -stable 700 15000 -key c-b -stable 600 8000 -text echo RESP''AWNOK -key enter -wait 10000 RESPAWNOK -stable 700 10000 -snap respawn diff --git a/test/snapshots/scroll.snap b/test/snapshots/scroll.snap deleted file mode 100644 index 4b723756..00000000 --- a/test/snapshots/scroll.snap +++ /dev/null @@ -1,31 +0,0 @@ -# scrolling: wheel + scrollbar gutter clicks over real scrollback -file s.txt x -start 31 100 -n 3 -wait 8000 s.txt -stable 700 20000 -key c-b -stable 600 8000 -text seq 1 200 -key enter -wait 8000 199 -stable 700 15000 -key c-b -stable 600 8000 -snap bottom -wheel up 10 8 -wheel up 10 8 -wheel up 10 8 -stable 500 8000 -snap wheel3 -press left 1 12 -release left 1 12 -stable 500 8000 -snap gutter-up -press right 1 7 -release right 1 7 -stable 500 8000 -snap gutter-down -wheel down 10 8 -stable 500 8000 -snap wheel-down -snapstyle wheel-down diff --git a/test/snapshots/tty.snap b/test/snapshots/tty.snap deleted file mode 100644 index 48fffbd1..00000000 --- a/test/snapshots/tty.snap +++ /dev/null @@ -1,31 +0,0 @@ -# tty mode round-trip: Ctrl-b in, run a command, Ctrl-b out. Ctrl-b is the one -# switch between raw and normal. Shift-Esc (CSI 27;2u — needs a host that -# reports modifiers on Escape) never switches: in every mode it is what Escape -# is in normal mode — Last, the pane you were in before this one — and a raw -# terminal stays raw. The hop itself is covered by a unit test in pardes.zig. -file m.txt marker -start 31 100 -n 3 -wait 8000 m.txt -stable 700 20000 -key c-b -stable 600 8000 -snap tty-on -text echo SNAP''OK -key enter -wait 8000 SNAPOK -stable 700 10000 -snap tty-echo -key c-b -stable 600 8000 -snap tty-off -# Shift-Esc from normal: never into raw; it backs out to the previous pane. -send \e[27;2u -stable 600 8000 -snap shift-esc-normal -# Ctrl-b is the switch: into raw, and out again. -key c-b -stable 600 8000 -snap ctrl-b-on -key c-b -stable 600 8000 -snap ctrl-b-off diff --git a/test/snapshots/ttyclick.snap b/test/snapshots/ttyclick.snap deleted file mode 100644 index 534005b9..00000000 --- a/test/snapshots/ttyclick.snap +++ /dev/null @@ -1,36 +0,0 @@ -# clicks in a shell pane never change its mode: a body click in raw tty -# keeps tty (before: the press dropped it to normal), a round trip through the -# tag leaves it alone (the tag has a mode of its own), and an insert-mode body -# click re-pins the cursor but stays insert. File panes keep the old behavior (click -> normal). -# The mode is the character in each pane's layout box: `•` normal, `^` insert, -# `$` tty. -file probe.txt marker -start 31 100 -n 3 -wait 8000 probe.txt -stable 700 20000 -key c-b -stable 600 8000 -# body click in raw tty: focus/selection only, the box stays `$` -press left 10 5 -release left 10 5 -stable 400 5000 -snap tty-bodyclick -# tag edit from tty: the box still reads `$` while the tag is typed into (the -# tag's mode is its own: a clicked tag is in normal mode), and `:` hands the keyboard back — a bug -# that lost the body's mode would show `•` in one snap or the other -press left @Term 3 -release left @Term 3 -stable 400 5000 -snap tty-tagedit -key : -stable 400 5000 -snap tty-tagexit -# out of tty, into insert: a body click moves the cursor but keeps INS -key c-b -stable 600 8000 -key i -stable 400 5000 -press left 12 5 -release left 12 5 -stable 400 5000 -snap ins-bodyclick diff --git a/test/snapshots/ttyedit.snap b/test/snapshots/ttyedit.snap deleted file mode 100644 index 6ee3ca03..00000000 --- a/test/snapshots/ttyedit.snap +++ /dev/null @@ -1,45 +0,0 @@ -# editing a shell pane exactly like a document: Enter SPLITS the line under -# the cursor and pushes the shell rows below it down, `o` opens a fresh line, -# and backspace at column 0 joins back up. Before the edit buffer landed a -# terminal could only splice single-row insertion runs, so none of this was -# expressible. test/hxcases/parity.jsonl pins the keystroke-level equivalence -# with a file pane case for case; this is the end-to-end pty proof. -file words.txt alpha beta -start 31 100 -n 3 -wait 8000 words.txt -stable 700 20000 -key c-b -stable 600 8000 -text printf 'one two three\nfour five six\nseven eight nine\n' -key enter -wait 8000 seven -stable 700 10000 -key c-b -stable 600 8000 -# click into the middle of the first output row -press left 8 9 -release left 8 9 -stable 400 5000 -snap before -# Enter splits the row there: "one t" stays, "wo three" becomes a real line -# of its own and the two output rows below it slide down -key i enter -stable 400 5000 -snap split -key esc -stable 400 5000 -# `o` opens a line below the split's tail and pushes the rest down again -key o -text OPEN -key esc -stable 400 5000 -snap opened -# backspace at column 0 joins the opened line back onto its predecessor -key i home bs -key esc -stable 400 5000 -snap joined -# undo walks the whole session back out to untouched shell output -key u u u -stable 400 5000 -snap undone diff --git a/test/snapshots/ttyfollow.snap b/test/snapshots/ttyfollow.snap deleted file mode 100644 index 94af40aa..00000000 --- a/test/snapshots/ttyfollow.snap +++ /dev/null @@ -1,47 +0,0 @@ -# follow-output gate: a shell pane in normal/insert mode holds its scrolled-up -# view while new pty output streams in (before: only the ACTIVE pane held); -# back in tty mode output follows to the bottom again. Pane A parks a -# background job blocked on file `go`, pane B triggers it and syncs on `done1`. -file s.txt x -start 31 100 -n 3 -wait 8000 s.txt -stable 700 20000 -key c-b -stable 600 8000 -text (until test -f go; do sleep 0.05; done; seq 201 260; touch done1) & -key enter -stable 500 8000 -text seq 1 200 -key enter -wait 8000 199 -stable 700 15000 -key c-b -stable 600 8000 -wheel up 10 8 -wheel up 10 8 -wheel up 10 8 -stable 500 8000 -snap held-pre -# focus pane B (right column), trigger A's job, sync on completion: A is now a -# NON-active normal-mode pane receiving output — its view must not move -press left 60 6 -release left 60 6 -stable 400 5000 -key c-b -stable 600 8000 -text touch go; until test -f done1; do sleep 0.05; done; echo SYN''CED -key enter -wait 8000 SYNCED -stable 700 15000 -snap held-post -# back in A, re-enter tty: the echoed keystrokes pull the view to the bottom -press left 10 9 -release left 10 9 -stable 400 5000 -key c-b -stable 600 8000 -text seq 261 300 -key enter -wait 8000 300 -stable 700 15000 -snap tty-follows diff --git a/test/snapshots/ttyhelp.snap b/test/snapshots/ttyhelp.snap deleted file mode 100644 index 30148d6c..00000000 --- a/test/snapshots/ttyhelp.snap +++ /dev/null @@ -1,24 +0,0 @@ -# bare boot = tty mode: SPC belongs to the shell, so the topbar Help word is -# the only route to the command list. Row 0 is not a pane, so a middle-click -# there is dispatched before any pane's mode is consulted. -start 31 100 -wait 8000 Newcol Joincol -stable 700 20000 -snap boot -press middle @Help 1 -release middle @Help 1 -wait 10000 pardes builtins -stable 700 15000 -snap helped -# and the shell is untouched: still TTY, still at its prompt. The click went to -# row 0, which is not a pane, so the terminal never saw it. -key c-b -stable 600 10000 -key space -key ? -# The bare-tty boot now opens an empty pane under the shell, so the index is -# half as tall: wait on a row that is on screen. What the leader route -# produced is the snapshot below, not this. -wait 10000 SPC Y ClipYankMain -stable 700 15000 -snap leaderworks diff --git a/test/snapshots/ttylook.snap b/test/snapshots/ttylook.snap deleted file mode 100644 index 0a125d2c..00000000 --- a/test/snapshots/ttylook.snap +++ /dev/null @@ -1,69 +0,0 @@ -# tty n/N token motion (normal mode only): n/N SELECT the next/prev -# whitespace-separated token that look resolves — several per line, so the -# greet ls row hops big.txt -> plain.txt -> sub — moving the cursor to the -# token start and opening NOTHING. Return looks the selection (dir -> the -# pane listing it, file -> pane) and focus follows what opened. The first -# n wraps from the prompt row to the first token; insert-mode n still -# types; and a pane with nothing look-able in it never traps the walk, -# because the walk is a RING ACROSS PANES rather than a scan of the one -# you are in. -lines big.txt 40 -file plain.txt just text -dirmk sub -start 31 120 -n 3 -wait 8000 big.txt -stable 700 20000 -# first n: cursor sits at the shell prompt below the output — wrap lands on -# the ls row's first token, big.txt; nothing opens -key space j n -stable 400 5000 -snap tok1 -snapstyle tok1 -# same row, next token: plain.txt -key space j n -stable 400 5000 -snap tok2 -# N steps back to big.txt -key space j p -stable 400 5000 -snap tokback -# insert-mode n still types (a run splice), no stepping; undo it -key i -text nn -key esc -settle 100 -stable 400 5000 -snap insert -key u -stable 400 5000 -# resume the walk from big.txt's start: plain.txt, then sub -key space j n -stable 400 5000 -key space j n -stable 400 5000 -snap tok3 -# Return looks the selected dir: sub's directory pane opens, empty as sub -# is, and takes the keyboard -key enter -wait 10000 sub/ -stable 700 15000 -snap diropen -# the fresh pane lists nothing, sub being empty, and that is not where n -# stops: the ring is spun on the panes that have LOOKED, so the step leaves -# this pane for the one it was looked out of. That pane's cursor is on its -# last token (`sub`), so the walk runs off the end and comes round to its -# first — big.txt. -key space j n -stable 400 5000 -snap noop -# back in the first pane, Enter with the cursor ON a token looks it (no -# selection: the cursor word expands): the click puts it on the ls command -# line's `ls`, a word no file names, which a terminal lists in a +Search, -# its row the place in that terminal (@p1:1:1-2) -press left 4 5 -release left 4 5 -stable 400 5000 -key enter -wait 10000 @p1:1:1-2 -stable 700 15000 -snap cursorword diff --git a/test/snapshots/ttyonly.snap b/test/snapshots/ttyonly.snap deleted file mode 100644 index 1008e084..00000000 --- a/test/snapshots/ttyonly.snap +++ /dev/null @@ -1,11 +0,0 @@ -# --tty: a single fullscreen shell already in raw tty mode, prompts visible -file t.txt x -start 31 100 --tty -wait 8000 $ -stable 700 20000 -text echo TTY''ONLY -key enter -wait 8000 TTYONLY -stable 700 10000 -snap ttyonly -snapstyle ttyonly diff --git a/test/snapshots/ttypaste.snap b/test/snapshots/ttypaste.snap deleted file mode 100644 index 1591c8c4..00000000 --- a/test/snapshots/ttypaste.snap +++ /dev/null @@ -1,32 +0,0 @@ -# Pasting INTO the program a tty pane is running. -# -# `SPC p` and the acme 1-3 chord are both unreachable in raw tty: the pty owns -# every keystroke and every button. So tty mode has its own chord, and a paste -# arriving from outside has to reach the shell rather than an edit buffer that -# the pty does not know exists. -# -# Two paths, both ending at the shell's command line: -# Ctrl-V types the DEFAULT register (config.tty_paste) -# bracketed paste the outer terminal's own paste, or a desktop one relayed -# by a GUI host, which used to land in an overlay instead -file src.txt PASTED-PAYLOAD -start 31 100 -n 3 -wait 8000 src.txt -stable 700 20000 -# fill the default register from a file pane: sweep the word and yank it -key c-b -stable 600 8000 -# in tty now; type a prefix so the pasted text is visibly appended to it -text echo -stable 600 8000 -# the outer terminal's bracketed paste: not a keystroke, no request behind it, -# and it must arrive at the shell's line -send \e[200~ BRACKETED\e[201~ -stable 600 8000 -snap bracketed-paste-reached-the-shell -# Ctrl-V types the register. Nothing was yanked in this session, so the -# register is empty and the chord is INERT rather than sending the shell the -# 0x16 it used to (quoted-insert): the line below is unchanged. -key c-v -stable 600 8000 -snap ctrl-v-with-empty-register-is-inert diff --git a/test/snapshots/ttyprompt.snap b/test/snapshots/ttyprompt.snap deleted file mode 100644 index 843ffe7c..00000000 --- a/test/snapshots/ttyprompt.snap +++ /dev/null @@ -1,35 +0,0 @@ -# Leaving raw tty hides the shell's PROMPT and keeps the command typed at it. -# -# The two share one grid row, so blanking the row used to take the command with -# the prompt and a shell out of tty read as output only. OSC 133 marks the row -# CELL by cell, so config.tty_blank = .prompt cuts the prompt's own columns and -# left-hugs what is left: the command lands at column 0, in line with the -# output under it, rather than in a bay of blanks the prompt used to fill. -# -# `.prompt_and_input` is the old behaviour and blanks the whole row; it is a -# comptime choice, so what THIS script pins is the default. -file probe.txt marker -start 31 100 -n 3 -wait 8000 probe.txt -stable 700 20000 -# the greeting `ls` was typed at a prompt and already shows the rule: the -# command is there, the prompt in front of it is not -snap greeted -# into tty and type a command WITHOUT submitting it, so the shell is sitting at -# a prompt with input on it — the case the old behaviour erased -key c-b -stable 600 8000 -text echo ABCDEFGH -stable 600 8000 -snap in-tty -# ...and out: the prompt goes, `echo ABCDEFGH` stays, hugging the left edge -key c-b -stable 600 8000 -snap out-of-tty -# The columns still have to reach the shell, and they do: the modal cursor's -# column on a hidden-prompt row is short by exactly the prompt's width, so -# enterTty adds it back before asking ghostty to walk the shell's own cursor -# there. That arithmetic is pinned by the "entering tty walks the shell cursor" -# unit test, which can put a pinned cursor on a known column; a click here -# cannot, because leaving tty unpins and a body click on a terminal does not -# pin it again. diff --git a/test/snapshots/ttytaken.snap b/test/snapshots/ttytaken.snap deleted file mode 100644 index 928993a6..00000000 --- a/test/snapshots/ttytaken.snap +++ /dev/null @@ -1,50 +0,0 @@ -# Process monitoring, end to end. A terminal whose tty is held by a -# full-screen program is not somewhere a command line may be typed: the SAME -# Exec from that terminal goes into its shell while it sits at its prompt, -# and into a command pane of its own once `less` owns the terminal -- where -# it runs, instead of becoming keystrokes the pager would eat. Nothing about -# the pager's screen changes. (From any pane but a terminal, an Exec always -# runs as a command pane: exec.snap.) -lines big.txt 40 -start 31 210 -n 1 -wait 8000 big.txt -stable 700 20000 -snap opened -# at the prompt: a command word in the terminal's own tag, executed, is -# typed into its shell. `:` opens the tag, `A` appends, and the execute key -# runs the word under the cursor. -key : -key A -key space -text @`echo TAKEN''ONE` -key esc -settle 100 -key h -key tab -wait 10000 TAKENONE -stable 700 20000 -snap at-prompt -# ...and now a pager owns that terminal. Ctrl-b is raw tty -# (config.tty_toggle), which is how a script types AT the shell instead of -# into the pane's own edit buffer. -key c-b -stable 400 5000 -text env LESS= less big.txt -key enter -wait 10000 line 1 -stable 700 20000 -key c-b -stable 400 5000 -snap paging -# the same gesture from that terminal: a command pane, not `less` keystrokes -key : -key A -key space -text @`echo TAKEN''TWO` -key esc -settle 100 -key h -key tab -wait 10000 TAKENTWO -stable 700 20000 -snap spawned |
