mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-19 00:03:13 +03:00
test(cli-rs): wait for each P-PTY Escape and exit before the next key
A step that only settled could not tell a slow program from one that was done. On a loaded box that let two kinds of key go out too early. A second Ctrl+C reached a TUI that was already exiting, as a SIGINT once the terminal was restored (P.0b/title-off-exit exited 130). A lone ESC the program had not yet timed out joined the next key as Alt+key. The harness can now wait until a string is gone (until.gone) or the program exited (until.exit). The TUI scenarios exit with one Ctrl+C and wait for the exit. Each Escape waits for what it closes; where nothing visible changes, it goes as the Kitty keyboard sends it (CSI 27 u), which both clients turned on. Mini's two-press exit and E.20's selection-ending Ctrl+C keep their two presses.
This commit is contained in:
@@ -38,8 +38,17 @@ export type PtyStep = {
|
||||
// Pushed to the `fallback: "tui"` event stream after the keys.
|
||||
emit?: Parameters<FakeServer["emit"]>[0][]
|
||||
// Waits until an OSC sequence or the screen matches (a string matches as a substring).
|
||||
// `oscCount` waits until that many OSC sequences contain the string.
|
||||
until?: { osc?: string | RegExp; screen?: string | RegExp; oscCount?: [string, number] }
|
||||
// `oscCount` waits until that many OSC sequences contain the string. `gone` waits until the screen no longer
|
||||
// contains the string, and `exit` until the program exited: a key whose effect is a closed view or an exit, such
|
||||
// as Escape or Ctrl+C, waits for it before the next keys go out, since a still screen cannot tell a slow program
|
||||
// from one that is done (a lone ESC the program has not yet timed out joins the next key as Alt+key).
|
||||
until?: {
|
||||
osc?: string | RegExp
|
||||
screen?: string | RegExp
|
||||
oscCount?: [string, number]
|
||||
gone?: string
|
||||
exit?: boolean
|
||||
}
|
||||
// Once `until` holds and the screen settled: the screen must not contain this.
|
||||
absent?: string
|
||||
// Waits until the screen has not changed for this long.
|
||||
@@ -445,7 +454,10 @@ async function waitFor(step: PtyStep, probe: Probe) {
|
||||
const countOk =
|
||||
counted === undefined || probe.osc().filter((entry) => entry.data.includes(counted[0])).length >= counted[1]
|
||||
const screenOk =
|
||||
countOk && (want === undefined || (typeof want === "string" ? text.includes(want) : want.test(text)))
|
||||
countOk &&
|
||||
(want === undefined || (typeof want === "string" ? text.includes(want) : want.test(text))) &&
|
||||
(step.until?.gone === undefined || !text.includes(step.until.gone)) &&
|
||||
(!step.until?.exit || exited)
|
||||
const settled = step.settle === undefined || Date.now() - state.since >= step.settle
|
||||
if (oscOk && screenOk && settled) {
|
||||
if (step.absent !== undefined && text.includes(step.absent))
|
||||
|
||||
@@ -18,7 +18,8 @@ export default definePty({
|
||||
checkpoint: "palette",
|
||||
deviation: { file: "X02-new-designs-graduated", lines: 12 },
|
||||
},
|
||||
{ keys: "\x1b", settle: 300 },
|
||||
// Each Escape waits for its dialog to close: a lone ESC not yet read would join the next key.
|
||||
{ keys: "\x1b", until: { gone: "Suggested" }, settle: 300 },
|
||||
{ keys: "/debug", until: { screen: "/debug" }, settle: 300 },
|
||||
{
|
||||
keys: "\r",
|
||||
@@ -27,9 +28,9 @@ export default definePty({
|
||||
checkpoint: "debug",
|
||||
deviation: { file: "X02-new-designs-graduated", lines: 12 },
|
||||
},
|
||||
{ keys: "\x1b", settle: 300 },
|
||||
{ keys: "\x03", settle: 300 },
|
||||
{ keys: "\x03" },
|
||||
{ keys: "\x1b", until: { gone: "Share this when reporting an issue" }, settle: 300 },
|
||||
// Ctrl+C on the empty prompt exits; a second press could land once the terminal is restored, as a SIGINT.
|
||||
{ keys: "\x03", until: { exit: true } },
|
||||
],
|
||||
masks: [
|
||||
{ pattern: /Date\s+\S+/, reason: "the time the dialog opened" },
|
||||
|
||||
@@ -19,9 +19,9 @@ export default definePty({
|
||||
// Well inside the model list's delay, with no settle: the keys show while it loads.
|
||||
{ keys: "typed early", until: { screen: "typed early" }, timeout: 1500, absent: "Demo Model" },
|
||||
{ until: { screen: "Demo Model" }, settle: 300, checkpoint: "loaded", timeout: 10_000 },
|
||||
{ keys: "\x15", settle: 300 },
|
||||
{ keys: "\x03", settle: 300 },
|
||||
{ keys: "\x03" },
|
||||
{ keys: "\x15", until: { gone: "typed early" }, settle: 300 },
|
||||
// Ctrl+C on the empty prompt exits; a second press could land once the terminal is restored, as a SIGINT.
|
||||
{ keys: "\x03", until: { exit: true } },
|
||||
],
|
||||
exits: true,
|
||||
})
|
||||
|
||||
@@ -20,13 +20,14 @@ export default definePty({
|
||||
checkpoint: "update",
|
||||
deviation: { file: "D131-update-command", lines: 2 },
|
||||
},
|
||||
{ keys: "\x1b", settle: 300 },
|
||||
// Each Escape waits for its dialog to close: a lone ESC not yet read would join the next key.
|
||||
{ keys: "\x1b", until: { gone: "update" }, settle: 300 },
|
||||
// `/debug` copies with `c` under the new designs, as the footer says.
|
||||
{ keys: "/debug", until: { screen: "/debug" }, settle: 300 },
|
||||
{ keys: "\r", until: { screen: "copy c" }, settle: 300, checkpoint: "debug" },
|
||||
{ keys: "\x1b", settle: 300 },
|
||||
{ keys: "\x03", settle: 300 },
|
||||
{ keys: "\x03" },
|
||||
{ keys: "\x1b", until: { gone: "copy c" }, settle: 300 },
|
||||
// Ctrl+C on the empty prompt exits; a second press could land once the terminal is restored, as a SIGINT.
|
||||
{ keys: "\x03", until: { exit: true } },
|
||||
],
|
||||
masks: [
|
||||
{ pattern: /Date\s+\S+/, reason: "the time the dialog opened" },
|
||||
|
||||
@@ -33,9 +33,9 @@ export function plugins(config: object): PtyCase {
|
||||
{ keys: "\r", until: { screen: "alpha" }, settle: 500, checkpoint: "plugins" },
|
||||
// Up from the top shows the end of the list.
|
||||
{ keys: "\x1b[A", settle: 300, checkpoint: "end" },
|
||||
{ keys: "\x1b", settle: 300 },
|
||||
{ keys: "\x03", settle: 300 },
|
||||
{ keys: "\x03" },
|
||||
// Escape waits for the list to close, and the one Ctrl+C on the empty prompt for the exit.
|
||||
{ keys: "\x1b", until: { gone: "check for updates" }, settle: 300 },
|
||||
{ keys: "\x03", until: { exit: true } },
|
||||
],
|
||||
exits: true,
|
||||
}
|
||||
|
||||
+2
-3
@@ -27,9 +27,8 @@ export default definePty({
|
||||
},
|
||||
steps: [
|
||||
{ until: { screen: "Fix the parser" }, settle: 500, timeout: 30_000 },
|
||||
{ keys: "\x03", settle: 300 },
|
||||
{ keys: "\x03" },
|
||||
{ until: { screen: "opencode -s ses_b" }, settle: 300, checkpoint: "epilogue", timeout: 10_000 },
|
||||
// One Ctrl+C on the empty prompt exits; a second press could land once the terminal is restored, as a SIGINT.
|
||||
{ keys: "\x03", until: { screen: "opencode -s ses_b" }, settle: 300, checkpoint: "epilogue", timeout: 10_000 },
|
||||
],
|
||||
osc: [],
|
||||
exits: true,
|
||||
|
||||
@@ -44,7 +44,7 @@ export default definePty({
|
||||
{ keys: "/diff", until: { screen: "/diff" }, settle: 300 },
|
||||
{ keys: "\r", until: { screen: "≡ lexer.ts" }, settle: 500, checkpoint: "open" },
|
||||
{ keys: "\x03", until: { screen: "█▀▀█" }, settle: 1000, checkpoint: "home" },
|
||||
{ keys: "\x03" },
|
||||
{ keys: "\x03", until: { exit: true } },
|
||||
],
|
||||
masks: homeMasks,
|
||||
exits: true,
|
||||
|
||||
@@ -48,8 +48,8 @@ export default definePty({
|
||||
{ keys: release(10, 5).replace("<0;", "<2;"), settle: 300, checkpoint: "menu" },
|
||||
{ keys: "\r", until: { screen: "1/2" }, settle: 500, checkpoint: "complete" },
|
||||
{ keys: "q", until: { screen: "█▀▀█" }, settle: 500, checkpoint: "home" },
|
||||
{ keys: "\x03", settle: 300 },
|
||||
{ keys: "\x03" },
|
||||
// Ctrl+C on the empty prompt exits; a second press could land once the terminal is restored, as a SIGINT.
|
||||
{ keys: "\x03", until: { exit: true } },
|
||||
],
|
||||
masks: homeMasks,
|
||||
exits: true,
|
||||
|
||||
@@ -11,8 +11,8 @@ export const home = {
|
||||
server: { fallback: "tui" as const },
|
||||
steps: [
|
||||
{ until: { screen: "█▀▀█" }, settle: 800, timeout: 30_000, checkpoint: "home" },
|
||||
{ keys: "\x03", settle: 300 },
|
||||
{ keys: "\x03" },
|
||||
// Ctrl+C on the empty prompt exits; a second press could land once the terminal is restored, as a SIGINT.
|
||||
{ keys: "\x03", until: { exit: true } },
|
||||
],
|
||||
exits: true,
|
||||
masks: [{ pattern: /Ask anything… .*$/, reason: "the placeholder is picked at random" }],
|
||||
|
||||
@@ -80,8 +80,8 @@ export default definePty({
|
||||
until: { screen: "Session failed" },
|
||||
settle: 300,
|
||||
},
|
||||
{ keys: "\x03", settle: 300 },
|
||||
{ keys: "\x03" },
|
||||
// Ctrl+C on the empty prompt exits; a second press could land once the terminal is restored, as a SIGINT.
|
||||
{ keys: "\x03", until: { exit: true } },
|
||||
],
|
||||
osc: ["status", "notify"],
|
||||
// Deviation N03-status-order: the order between a notification and a status record is not fixed in Rust.
|
||||
|
||||
+6
-4
@@ -23,11 +23,13 @@ export default definePty({
|
||||
{ keys: "\x1b[<32;21;17M\x1b[<32;25;17M", settle: 50 },
|
||||
{ keys: "\x1b[<0;25;17m" },
|
||||
{ until: { osc: "52;" }, settle: 300, timeout: 10_000, checkpoint: "copied" },
|
||||
// Escape clears the selection; Ctrl+U empties the prompt so Ctrl+C exits.
|
||||
{ keys: "\x1b", settle: 300 },
|
||||
{ keys: "\x15", settle: 300 },
|
||||
// Escape, then Ctrl+U empties the prompt. Escape shows no text to wait for, so it goes as the Kitty keyboard sends
|
||||
// it (the TUI turned it on): a lone ESC the program had not yet timed out would join Ctrl+U. The mouse selection
|
||||
// stays on both sides, so the first Ctrl+C ends it (copy on select) and the second exits.
|
||||
{ keys: "\x1b[27u", settle: 300 },
|
||||
{ keys: "\x15", until: { gone: "copy this text" }, settle: 300 },
|
||||
{ keys: "\x03", settle: 300 },
|
||||
{ keys: "\x03" },
|
||||
{ keys: "\x03", until: { exit: true } },
|
||||
],
|
||||
osc: ["clipboard"],
|
||||
masks: [
|
||||
|
||||
+2
-2
@@ -21,8 +21,8 @@ export default definePty({
|
||||
{ keys: "hello", until: { screen: "hello" }, settle: 200 },
|
||||
{ keys: "\x18e", until: { screen: "second line" }, settle: 300, timeout: 10_000, checkpoint: "edited" },
|
||||
// Ctrl+C clears the prompt, then exits.
|
||||
{ keys: "\x03", settle: 300 },
|
||||
{ keys: "\x03" },
|
||||
{ keys: "\x03", until: { gone: "second line" }, settle: 300 },
|
||||
{ keys: "\x03", until: { exit: true } },
|
||||
],
|
||||
osc: [],
|
||||
masks: [
|
||||
|
||||
@@ -18,7 +18,8 @@ export default definePty({
|
||||
{ until: { screen: "█▀▀█" }, settle: 500, timeout: 30_000 },
|
||||
{ keys: "\x18", settle: 200 },
|
||||
{ keys: "l", until: { screen: "Search sessions" }, settle: 300, checkpoint: "completed" },
|
||||
{ keys: "\x1b", settle: 300 },
|
||||
// Escape waits for the list to close: a lone ESC not yet read would join the leader key.
|
||||
{ keys: "\x1b", until: { gone: "Search sessions" }, settle: 300 },
|
||||
{ keys: "\x18", settle: 1600 },
|
||||
{ keys: "l", settle: 300, absent: "Search sessions", checkpoint: "expired" },
|
||||
],
|
||||
|
||||
@@ -15,7 +15,8 @@ export default definePty({
|
||||
{ until: { screen: "█▀▀█" }, settle: 500, timeout: 30_000 },
|
||||
{ keys: "\x18", settle: 1000 },
|
||||
{ keys: "l", until: { screen: "Search sessions" }, settle: 300, checkpoint: "completed" },
|
||||
{ keys: "\x1b", settle: 300 },
|
||||
// Escape waits for the list to close: a lone ESC not yet read would join the leader key.
|
||||
{ keys: "\x1b", until: { gone: "Search sessions" }, settle: 300 },
|
||||
{ keys: "\x18", settle: 2600 },
|
||||
{ keys: "l", settle: 300, absent: "Search sessions", checkpoint: "expired" },
|
||||
],
|
||||
|
||||
+2
-2
@@ -12,8 +12,8 @@ export default definePty({
|
||||
steps: [
|
||||
// The title can come before the first paint, so wait for the logo as well.
|
||||
{ until: { osc: "OpenCode", screen: "█▀▀█" }, settle: 500, timeout: 30_000 },
|
||||
{ keys: "\x03", settle: 300 },
|
||||
{ keys: "\x03" },
|
||||
// Ctrl+C on the empty prompt exits; a second press could land once the terminal is restored, as a SIGINT.
|
||||
{ keys: "\x03", until: { exit: true } },
|
||||
],
|
||||
exits: true,
|
||||
})
|
||||
|
||||
+4
-2
@@ -29,8 +29,10 @@ export default definePty({
|
||||
opened,
|
||||
{ keys: "first", settle: 200 },
|
||||
{ keys: "\r", settle: 600 },
|
||||
{ keys: "\x1b", settle: 200 },
|
||||
{ keys: "\x1b", settle: 600 },
|
||||
// The interrupt's first Escape shows no text to wait for, so each goes as the Kitty keyboard sends it (Mini turned it
|
||||
// on): a lone ESC the program had not yet timed out would join the next key.
|
||||
{ keys: "\x1b[27u", settle: 200 },
|
||||
{ keys: "\x1b[27u", settle: 600 },
|
||||
...leave,
|
||||
],
|
||||
exits: true,
|
||||
|
||||
+3
-1
@@ -35,7 +35,9 @@ export default definePty({
|
||||
{ keys: "!", settle: 100 },
|
||||
{ keys: "ls", settle: 100 },
|
||||
{ keys: "\x18\r", settle: 400, checkpoint: "refused" },
|
||||
{ keys: "\x1b", settle: 100 },
|
||||
// Escape shows no text to wait for, so it goes as the Kitty keyboard sends it (Mini turned it on): a lone ESC the
|
||||
// program had not yet timed out would join Ctrl+L.
|
||||
{ keys: "\x1b[27u", settle: 100 },
|
||||
{ keys: "\x0c", settle: 600, checkpoint: "cleared" },
|
||||
// The first Ctrl+C clears the draft.
|
||||
{ keys: "\x03", settle: 200 },
|
||||
|
||||
@@ -26,8 +26,10 @@ export default definePty({
|
||||
opened,
|
||||
{ keys: "!sleep 5", settle: 300 },
|
||||
{ keys: "\r", settle: 500, checkpoint: "running" },
|
||||
{ keys: "\x1b", settle: 200 },
|
||||
{ keys: "\x1b", settle: 600, checkpoint: "interrupted" },
|
||||
// The interrupt's first Escape shows no text to wait for, so each goes as the Kitty keyboard sends it (Mini turned it
|
||||
// on): a lone ESC the program had not yet timed out would join the next key.
|
||||
{ keys: "\x1b[27u", settle: 200 },
|
||||
{ keys: "\x1b[27u", until: { gone: "esc interrupt" }, settle: 600, checkpoint: "interrupted" },
|
||||
...leave,
|
||||
],
|
||||
exits: true,
|
||||
|
||||
+2
-1
@@ -12,7 +12,8 @@ export default definePty({
|
||||
steps: [
|
||||
opened,
|
||||
{ keys: "!", settle: 300, checkpoint: "shell" },
|
||||
{ keys: "\x1b", settle: 300, checkpoint: "normal" },
|
||||
// Escape waits for shell mode to end: a lone ESC not yet read would join the next key.
|
||||
{ keys: "\x1b", until: { gone: "Shell ·" }, settle: 300, checkpoint: "normal" },
|
||||
{ keys: "!", settle: 200 },
|
||||
{ keys: "\x7f", settle: 300, checkpoint: "backspace" },
|
||||
{ keys: "!ls -la", settle: 300, checkpoint: "typed" },
|
||||
|
||||
+2
-1
@@ -14,7 +14,8 @@ export default definePty({
|
||||
{ keys: "/", settle: 400, checkpoint: "slash" },
|
||||
{ keys: "\x1b[B\x1b[B", settle: 300, checkpoint: "moved" },
|
||||
{ keys: "re", settle: 400, checkpoint: "filtered" },
|
||||
{ keys: "\x1b", settle: 300, checkpoint: "hidden" },
|
||||
// Escape waits for the list to close: a lone ESC not yet read would join the next key.
|
||||
{ keys: "\x1b", until: { gone: "Review the working tree" }, settle: 300, checkpoint: "hidden" },
|
||||
{ keys: "/rev", settle: 300 },
|
||||
{ keys: "\r", settle: 800, checkpoint: "sent" },
|
||||
{ keys: "/compact ", settle: 300 },
|
||||
|
||||
+3
-2
@@ -14,10 +14,11 @@ export default definePty({
|
||||
{ ...opened, until: { screen: "Permission required" }, checkpoint: "asked" },
|
||||
{ keys: "\x1b[C", settle: 300, checkpoint: "moved" },
|
||||
{ keys: "\r", settle: 300, checkpoint: "always" },
|
||||
{ keys: "\x1b", settle: 300 },
|
||||
// Each Escape waits for the stage it opens: a lone ESC not yet read would join the next key as Alt+key.
|
||||
{ keys: "\x1b", until: { gone: "This will always allow" }, settle: 300 },
|
||||
{ keys: "\x1b[D", settle: 300 },
|
||||
{ keys: "\r", until: { screen: "WebFetch" }, settle: 400, checkpoint: "next" },
|
||||
{ keys: "\x1b", settle: 300, checkpoint: "reject" },
|
||||
{ keys: "\x1b", until: { screen: "Reject permission" }, settle: 300, checkpoint: "reject" },
|
||||
{ keys: "use the cache", settle: 300 },
|
||||
{ keys: "\r", until: { screen: "ctrl+p menu" }, settle: 600, checkpoint: "replied" },
|
||||
...leave,
|
||||
|
||||
@@ -46,10 +46,11 @@ export default definePty({
|
||||
steps: [
|
||||
{ until: { screen: "Third answer" }, settle: 800, timeout: 30_000, checkpoint: "cold" },
|
||||
{ keys: "/rev", settle: 400, checkpoint: "cold-slash" },
|
||||
{ keys: "\x1b", settle: 300 },
|
||||
// Each Escape waits for the list to close: a lone ESC not yet read would join the next key.
|
||||
{ keys: "\x1b", until: { gone: "No matching items" }, settle: 300 },
|
||||
{ keys: "hello\r", until: { screen: "Demo Model" }, settle: 800, checkpoint: "warm" },
|
||||
{ keys: "/rev", settle: 400, checkpoint: "warm-slash" },
|
||||
{ keys: "\x1b", settle: 300 },
|
||||
{ keys: "\x1b", until: { gone: "Review the working tree" }, settle: 300 },
|
||||
...leave,
|
||||
],
|
||||
exits: true,
|
||||
|
||||
+2
-1
@@ -24,7 +24,8 @@ export default definePty({
|
||||
{ keys: "/settings", settle: 300 },
|
||||
{ keys: "\r", until: { screen: "Settings" }, settle: 500, checkpoint: "settings" },
|
||||
{ keys: "\x1b[C", settle: 800, checkpoint: "everything" },
|
||||
{ keys: "\x1b", settle: 400 },
|
||||
// Escape waits for the settings to close: a lone ESC not yet read would join the next key.
|
||||
{ keys: "\x1b", until: { gone: "left/right change" }, settle: 400 },
|
||||
...leave,
|
||||
],
|
||||
exits: true,
|
||||
|
||||
@@ -16,7 +16,9 @@ export default definePty({
|
||||
...Array.from({ length: 7 }, () => ({ keys: "\x1b[B", settle: 150 })),
|
||||
// TS's open panel animates its spinner preview once mono is on, so the screen does not settle.
|
||||
{ keys: "\x1b[C", until: { screen: /Monochrome UI +on/ } },
|
||||
{ keys: "\x1b", settle: 600, checkpoint: "mono" },
|
||||
// Escape waits for the settings to close: with mono the Kitty keyboard is off, and a lone ESC not yet read would
|
||||
// join the next key.
|
||||
{ keys: "\x1b", until: { gone: "Monochrome UI" }, settle: 600, checkpoint: "mono" },
|
||||
...leave,
|
||||
],
|
||||
exits: true,
|
||||
|
||||
+2
-1
@@ -14,7 +14,8 @@ export default definePty({
|
||||
steps: [
|
||||
{ ...opened, checkpoint: "hints" },
|
||||
{ keys: "\x10", until: { screen: "View subagents" }, settle: 400, checkpoint: "menu" },
|
||||
{ keys: "\x1b", settle: 300 },
|
||||
// Escape waits for the menu to close: a lone ESC not yet read would join the arrow as Alt+Down.
|
||||
{ keys: "\x1b", until: { gone: "View subagents" }, settle: 300 },
|
||||
{ keys: "\x1b[B", until: { screen: "Select subagent" }, settle: 400, checkpoint: "panel" },
|
||||
{ keys: "\t", settle: 300, checkpoint: "inactive" },
|
||||
{ keys: "\r", until: { screen: "The docs cover" }, settle: 500, checkpoint: "inspector" },
|
||||
|
||||
@@ -16,8 +16,8 @@ export default definePty({
|
||||
terminal: "kitty",
|
||||
steps: [
|
||||
{ until: { screen: "█▀▀█" }, settle: 500, timeout: 30_000, checkpoint: "home" },
|
||||
{ keys: "\x03", settle: 300 },
|
||||
{ keys: "\x03", settle: 800, checkpoint: "exit", deviation },
|
||||
// One Ctrl+C on the empty prompt exits; a second press could land once the terminal is restored, as a SIGINT.
|
||||
{ keys: "\x03", until: { exit: true }, settle: 800, checkpoint: "exit", deviation },
|
||||
],
|
||||
exits: true,
|
||||
masks: homeMasks,
|
||||
|
||||
@@ -41,8 +41,8 @@ export async function install(root: string, config?: object) {
|
||||
export const home: PtyStep[] = [
|
||||
{ until: { screen: "█▀▀█" }, settle: 500, timeout: 30_000 },
|
||||
{ keys: "/p0brun", until: { screen: "Run a program" }, settle: 200, timeout: 30_000 },
|
||||
{ keys: "\x1b", settle: 200 },
|
||||
{ keys: "\x15", settle: 200 },
|
||||
{ keys: "\x1b", until: { gone: "Run a program" }, settle: 200 },
|
||||
{ keys: "\x15", until: { gone: "/p0brun" }, settle: 200 },
|
||||
]
|
||||
|
||||
// Runs `command` through `/p0brun`, which first prints `ready-<n + 1>`, and waits for that: text the command itself
|
||||
@@ -54,15 +54,14 @@ export function run(command: string, n: number): PtyStep[] {
|
||||
]
|
||||
}
|
||||
|
||||
// Two Ctrl+C: the TUI exits.
|
||||
export const leave: PtyStep[] = [{ keys: "\x03", settle: 300 }, { keys: "\x03" }]
|
||||
// Ctrl+C on the empty prompt: the TUI exits. A second press could land once the terminal is restored, as a SIGINT.
|
||||
export const leave: PtyStep[] = [{ keys: "\x03", until: { exit: true } }]
|
||||
|
||||
// Home, then `/p0btitle` once both clients list it, then two Ctrl+C to exit.
|
||||
// Home, then `/p0btitle` once both clients list it, then Ctrl+C to exit.
|
||||
export const steps: PtyStep[] = [
|
||||
// The title can come before the first paint, so wait for the logo as well.
|
||||
{ until: { screen: "█▀▀█" }, settle: 500, timeout: 30_000 },
|
||||
{ keys: "/p0btitle", until: { screen: "Set the title" }, settle: 300, timeout: 30_000 },
|
||||
{ keys: "\r", until: { osc: "p0b title" }, settle: 300 },
|
||||
{ keys: "\x03", settle: 300 },
|
||||
{ keys: "\x03" },
|
||||
...leave,
|
||||
]
|
||||
|
||||
@@ -21,7 +21,7 @@ export default definePty({
|
||||
...run("sleep 1; exit 4", 3),
|
||||
{ keys: "\x1a", until: { osc: 'p0b exit {"code":4}' }, settle: 300, timeout: 15_000 },
|
||||
{ keys: "still here", until: { screen: "still here" }, settle: 300 },
|
||||
{ keys: "\x15", settle: 200 },
|
||||
{ keys: "\x15", until: { gone: "still here" }, settle: 200 },
|
||||
...leave,
|
||||
],
|
||||
osc: ["title"],
|
||||
|
||||
@@ -14,7 +14,7 @@ export default definePty({
|
||||
{ keys: "/p0blong", until: { screen: "Set a long title" }, settle: 300 },
|
||||
{ keys: "\r", until: { osc: "p0b long éé" }, settle: 300 },
|
||||
{ keys: "still here", until: { screen: "still here" }, settle: 300 },
|
||||
{ keys: "\x15", settle: 200 },
|
||||
{ keys: "\x15", until: { gone: "still here" }, settle: 200 },
|
||||
...leave,
|
||||
],
|
||||
osc: ["title"],
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
import { mkdir, writeFile } from "node:fs/promises"
|
||||
import path from "node:path"
|
||||
import { definePty } from "../../pty/run"
|
||||
import { leave } from "./fixture"
|
||||
|
||||
export default definePty({
|
||||
args: [],
|
||||
@@ -15,7 +16,7 @@ export default definePty({
|
||||
await mkdir(config, { recursive: true })
|
||||
await writeFile(path.join(config, "cli.json"), JSON.stringify({ terminal: { title: false } }))
|
||||
},
|
||||
steps: [{ until: { screen: "█▀▀█" }, settle: 500, timeout: 30_000 }, { keys: "\x03", settle: 300 }, { keys: "\x03" }],
|
||||
steps: [{ until: { screen: "█▀▀█" }, settle: 500, timeout: 30_000 }, ...leave],
|
||||
osc: ["title"],
|
||||
exits: true,
|
||||
})
|
||||
|
||||
@@ -29,8 +29,8 @@ export default definePty({
|
||||
{ until: { screen: /hello\s*$/m }, settle: 300, timeout: 30_000, checkpoint: "home" },
|
||||
{ keys: "/hello", until: { screen: "Say hello" }, settle: 300 },
|
||||
{ keys: "\r", until: { screen: "Hello from a plugin" }, settle: 300, checkpoint: "toast" },
|
||||
{ keys: "\x03", settle: 300 },
|
||||
{ keys: "\x03" },
|
||||
// Ctrl+C on the empty prompt exits; a second press could land once the terminal is restored, as a SIGINT.
|
||||
{ keys: "\x03", until: { exit: true } },
|
||||
],
|
||||
masks: [{ pattern: /Ask anything… .*$/, reason: "the placeholder is picked at random" }],
|
||||
exits: true,
|
||||
|
||||
@@ -17,7 +17,8 @@ export default definePty({
|
||||
{ until: { screen: "fault plugin c" }, settle: 500, timeout: 30_000 },
|
||||
...palette("Fault in render: segv"),
|
||||
{ until: { screen: /crashed the client in `render-slot`[\s\S]*fault plugin c/ }, settle: 500, timeout: 20_000 },
|
||||
{ keys: "\x1b", settle: 300 },
|
||||
// Each Escape waits for its toast to close: a lone ESC not yet read would join the palette's Ctrl+P.
|
||||
{ keys: "\x1b", until: { gone: "crashed the client" }, settle: 300 },
|
||||
...palette("Fault B in render: segv"),
|
||||
// The third client holds both: `example.fault` by the crash list, `example.fault.b` by the handoff.
|
||||
{
|
||||
@@ -25,7 +26,7 @@ export default definePty({
|
||||
settle: 500,
|
||||
timeout: 20_000,
|
||||
},
|
||||
{ keys: "\x1b", settle: 300 },
|
||||
{ keys: "\x1b", until: { gone: "example.fault.b" }, settle: 300 },
|
||||
...palette("Fault C in render: segv"),
|
||||
{
|
||||
until: { screen: /\$ opencode-native -s ses_b[\s\S]*crashed 3 times in 60 s \(last in plugin example\.fault\.c\)/ },
|
||||
|
||||
@@ -20,7 +20,8 @@ export default definePty({
|
||||
checkpoint: "first",
|
||||
timeout: 20_000,
|
||||
},
|
||||
{ keys: "\x1b", settle: 300 },
|
||||
// Escape waits for the toast to close: a lone ESC not yet read would join the palette's Ctrl+P.
|
||||
{ keys: "\x1b", until: { gone: "restarted" }, settle: 300 },
|
||||
...palette("Fault on a thread: segv"),
|
||||
{
|
||||
until: { screen: /^(?![\s\S]*fault plugin)[\s\S]*opencode-native crashed twice/ },
|
||||
|
||||
Reference in New Issue
Block a user