Skip to content

Commit 57a1cbb

Browse files
authored
test(tui): prove editor input through PTY (#118982)
1 parent 2c79d1d commit 57a1cbb

2 files changed

Lines changed: 80 additions & 1 deletion

File tree

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
title: TUI editor input PTY contracts
2+
scenario:
3+
id: tui-editor-input-pty
4+
surface: tui
5+
category: tui.input-and-commands
6+
coverage:
7+
primary:
8+
- tui.message-composition
9+
- tui.input-history
10+
- tui.keyboard-shortcuts
11+
- tui.paste-and-busy-submit-handling
12+
- tui.ime-and-altgr-handling
13+
risk: medium
14+
objective: Prove editor input behavior through the real runTui terminal loop and literal PTY bytes.
15+
successCriteria:
16+
- Typed and fragmented Unicode input reaches the backend unchanged.
17+
- Terminal navigation recalls submitted input history.
18+
- Literal keyboard shortcuts mutate editor state before submission.
19+
- Bracketed paste submits normally and is rejected while a run is busy.
20+
- Fragmented IME text and Kitty AltGr printable bytes reach the backend unchanged.
21+
codeRefs:
22+
- src/tui/tui-pty-harness.e2e.test.ts
23+
- src/tui/tui.ts
24+
- src/tui/components/custom-editor.ts
25+
- src/tui/tui-submit.ts
26+
execution:
27+
kind: script
28+
path: test/e2e/qa-lab/tui/tui-pty-evidence-producer.ts
29+
summary: Runs independently matched real-PTY editor assertions and authenticates their fresh Vitest results.
30+
timeoutMs: 180000
31+
args:
32+
- --artifact-base
33+
- ${outputDir}
34+
- --scenario-id
35+
- ${scenarioId}
36+
config:
37+
tuiPtyCases:
38+
- coverageId: tui.message-composition
39+
testFile: src/tui/tui-pty-harness.e2e.test.ts
40+
testNamePattern: ^TUI PTY harness drives the real TUI terminal loop through typed and fragmented Unicode input$
41+
- coverageId: tui.input-history
42+
testFile: src/tui/tui-pty-harness.e2e.test.ts
43+
testNamePattern: ^TUI PTY harness recalls submitted input history through literal terminal navigation$
44+
- coverageId: tui.keyboard-shortcuts
45+
testFile: src/tui/tui-pty-harness.e2e.test.ts
46+
testNamePattern: ^TUI PTY harness applies literal terminal shortcuts before submitting editor input$
47+
- coverageId: tui.paste-and-busy-submit-handling
48+
testFile: src/tui/tui-pty-harness.e2e.test.ts
49+
testNamePattern: ^TUI PTY harness handles bracketed paste and rejects the pasted submit while busy$
50+
- coverageId: tui.ime-and-altgr-handling
51+
testFile: src/tui/tui-pty-harness.e2e.test.ts
52+
testNamePattern: ^TUI PTY harness submits fragmented IME text and Kitty AltGr printable bytes$

‎src/tui/tui-pty-harness.e2e.test.ts‎

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,34 @@ describe.sequential("TUI PTY harness", () => {
344344
},
345345
STARTUP_TEST_TIMEOUT_MS,
346346
);
347-
347+
// prettier-ignore
348+
const editorInputCases = [
349+
["recalls submitted input history through literal terminal navigation", [["w", "history recall proof\r"], ["s", "history recall proof"], ["o", "PTY_RESPONSE: history recall proof"], ["w", "\u001b[A\u0005 edited\r"], ["s", "history recall proof edited"]]],
350+
["applies literal terminal shortcuts before submitting editor input",
351+
[["w", "discard this input"], ["w", "\u0003"], ["o", "cleared input; press ctrl+c again to exit"], ["w", "shortcut kept input\r"], ["s", "shortcut kept input"], ["n", "discard this input"]]],
352+
["handles bracketed paste and rejects the pasted submit while busy",
353+
[["w", "\u001b[200~bracketed paste proof\u001b[201~\r"], ["s", "bracketed paste proof"], ["o", "PTY_RESPONSE: bracketed paste proof"], ["w", "slow prompt\r"], ["s", "slow prompt"],
354+
["w", "\u001b[200~busy pasted prompt\u001b[201~\r"], ["o", "agent is busy"], ["o", "PTY_RESPONSE: slow prompt"], ["n", "busy pasted prompt"]]],
355+
["submits fragmented IME text and Kitty AltGr printable bytes", [["w", "日本"], ["w", "語 "], ["w", "\u001b[64::113;7u\u001b[8364::101;7u\r"], ["s", "日本語 @€"], ["o", "PTY_RESPONSE: 日本語 @€"]]],
356+
] as const;
357+
it.each(editorInputCases)(
358+
"%s",
359+
async (_name, steps) => {
360+
const tui = await startTuiFixture();
361+
try {
362+
await tui.run.waitForOutput("local ready", STARTUP_TIMEOUT_MS);
363+
for (const [action, value] of steps) {
364+
// prettier-ignore
365+
const sent = (entry: FixtureLogEntry) => entry.method === "sendChat" && objectFieldEquals(entry, "message", value);
366+
// prettier-ignore
367+
await { w: () => tui.run.write(value, { delay: false }), o: () => tui.run.waitForOutput(value), s: () => tui.waitForLogEntry(sent), n: async () => expect((await readFixtureLog(tui.logPath)).some(sent)).toBe(false) }[action]();
368+
}
369+
} finally {
370+
await tui.cleanup();
371+
}
372+
},
373+
STARTUP_TEST_TIMEOUT_MS,
374+
);
348375
it(
349376
"preserves consecutive backspaces received in the same terminal input chunk",
350377
async () => {

0 commit comments

Comments
 (0)