test(cli-rs): prove compact pastes against TS with a paste step

The P-APP harness gains a bracketed paste step on both sides. E.4/paste collapses a three-line paste, expands it by pasting it again, and strips ANSI from a short paste; every checkpoint equals TS.
This commit is contained in:
Simon Klee 2026-11-04 22:35:21 +01:00
parent c50a4c3e36
commit 5830f6b707
No known key found for this signature in database
GPG key ID: B91696044D47BEA3
10 changed files with 969 additions and 0 deletions

View file

@ -88,6 +88,10 @@ pub enum Step {
#[serde(rename = "type")]
text: String,
},
/// A bracketed paste (E.4).
Paste {
paste: String,
},
/// A left press and release at `[x, y]`.
Click {
click: [u16; 2],

View file

@ -136,6 +136,7 @@ fn run(recording: &Recording) -> (bool, String) {
match step {
Step::Keys { keys } => keys.iter().for_each(|key| app.press(key)),
Step::Type { text } => app.type_text(text),
Step::Paste { paste } => app.paste(paste),
Step::Click { click } => app.click(click[0], click[1]),
Step::Event { event } => memory.emit(event),
Step::Drag { drag: [from, to] } => app.drag((from[0], from[1]), (to[0], to[1])),

View file

@ -100,6 +100,7 @@ async function record(name: string, file: string) {
if ("pty" in step) pty?.step(step.pty)
if ("keys" in step) step.keys.forEach((key) => press(setup, key))
if ("type" in step) await setup.mockInput.typeText(step.type)
if ("paste" in step) await setup.mockInput.pasteBracketedText(step.paste)
if ("click" in step) await setup.mockMouse.click(...step.click)
if ("event" in step) setup.events.emit(step.event as never)
if ("drag" in step) await setup.mockMouse.drag(...step.drag[0], ...step.drag[1])

View file

@ -0,0 +1,612 @@
{
"scenario": "E.4/paste",
"width": 100,
"height": 30,
"directory": "/tmp/opencode/packages/tui",
"config": {
"animations": false,
"experimental": {
"new-designs": true
}
},
"args": {
"sessionID": "ses_b"
},
"routes": [
{
"path": "/api/session/ses_b",
"json": {
"data": {
"id": "ses_b",
"title": "Fix the parser",
"projectID": "proj_test",
"cost": 0,
"tokens": {
"input": 0,
"output": 0,
"reasoning": 0,
"cache": {
"read": 0,
"write": 0
}
},
"time": {
"created": 2,
"updated": 2
},
"location": {
"directory": "/tmp/opencode/packages/tui"
}
}
}
},
{
"path": "/api/session/ses_b/message",
"json": {
"data": [
{
"id": "msg_1",
"type": "user",
"text": "Why does the parser fail?",
"time": {
"created": 1
}
}
],
"cursor": {}
}
},
{
"path": "/api/session/ses_b/inbox",
"json": {
"data": []
}
}
],
"steps": [
{
"checkpoint": "open",
"until": "Why does the parser fail?",
"fixture": "E.4/paste/open"
},
{
"type": "see "
},
{
"paste": "first line\nsecond line\nthird line"
},
{
"checkpoint": "compact",
"until": "[Pasted ~3 lines]",
"fixture": "E.4/paste/compact"
},
{
"paste": "first line\nsecond line\nthird line"
},
{
"checkpoint": "expanded",
"until": "third line",
"fixture": "E.4/paste/expanded"
},
{
"keys": [
"ctrl+c"
]
},
{
"paste": "short \u001b[31mred\u001b[0m paste"
},
{
"checkpoint": "short",
"until": "short red paste",
"fixture": "E.4/paste/short"
}
],
"requests": {
"writes": [],
"reads": [
{
"method": "GET",
"path": "/api/agent",
"query": {
"location[directory]": [
"/tmp/opencode/packages/tui"
]
},
"status": 200,
"json": {
"location": {
"directory": "/tmp/opencode/packages/tui",
"project": {
"id": "proj_test",
"directory": "/tmp/opencode",
"canonical": "/tmp/opencode"
}
},
"data": []
}
},
{
"method": "GET",
"path": "/api/command",
"query": {
"location[directory]": [
"/tmp/opencode/packages/tui"
]
},
"status": 200,
"json": {
"location": {
"directory": "/tmp/opencode/packages/tui",
"project": {
"id": "proj_test",
"directory": "/tmp/opencode",
"canonical": "/tmp/opencode"
}
},
"data": []
}
},
{
"method": "GET",
"path": "/api/config",
"query": {
"location[directory]": [
"/tmp/opencode/packages/tui"
]
},
"status": 200,
"json": []
},
{
"method": "GET",
"path": "/api/experimental/migration/v1",
"query": {},
"status": 200,
"json": {
"status": "completed"
}
},
{
"method": "GET",
"path": "/api/experimental/session/ses_b/terminal",
"query": {},
"status": 200,
"json": {
"data": []
}
},
{
"method": "GET",
"path": "/api/form",
"query": {
"location[directory]": [
"/tmp/opencode/packages/tui"
]
},
"status": 200,
"json": {
"location": {
"directory": "/tmp/opencode/packages/tui",
"project": {
"id": "proj_test",
"directory": "/tmp/opencode"
}
},
"data": []
}
},
{
"method": "GET",
"path": "/api/fs/list",
"query": {
"location[directory]": [
"<cwd>"
]
},
"status": 200,
"json": {
"location": {
"directory": "/tmp/opencode/packages/tui",
"project": {
"id": "proj_test",
"directory": "/tmp/opencode",
"canonical": "/tmp/opencode"
}
},
"data": []
}
},
{
"method": "GET",
"path": "/api/info",
"query": {},
"status": 200,
"json": {
"version": "test",
"pid": 0,
"urls": [],
"paths": {
"tmp": "/tmp"
},
"capabilities": {
"persistentPty": true
}
}
},
{
"method": "GET",
"path": "/api/integration",
"query": {
"location[directory]": [
"/tmp/opencode/packages/tui"
]
},
"status": 200,
"json": {
"location": {
"directory": "/tmp/opencode/packages/tui",
"project": {
"id": "proj_test",
"directory": "/tmp/opencode",
"canonical": "/tmp/opencode"
}
},
"data": []
}
},
{
"method": "GET",
"path": "/api/location",
"query": {
"location[directory]": [
"/tmp/opencode/packages/tui"
]
},
"status": 200,
"json": {
"directory": "/tmp/opencode/packages/tui",
"project": {
"id": "proj_test",
"directory": "/tmp/opencode",
"canonical": "/tmp/opencode"
}
}
},
{
"method": "GET",
"path": "/api/mcp",
"query": {
"location[directory]": [
"/tmp/opencode/packages/tui"
]
},
"status": 200,
"json": {
"location": {
"directory": "/tmp/opencode/packages/tui",
"project": {
"id": "proj_test",
"directory": "/tmp/opencode",
"canonical": "/tmp/opencode"
}
},
"data": []
}
},
{
"method": "GET",
"path": "/api/mcp/resource",
"query": {
"location[directory]": [
"/tmp/opencode/packages/tui"
]
},
"status": 200,
"json": {
"location": {
"directory": "/tmp/opencode/packages/tui",
"project": {
"id": "proj_test",
"directory": "/tmp/opencode",
"canonical": "/tmp/opencode"
}
},
"data": {
"resources": [],
"templates": []
}
}
},
{
"method": "GET",
"path": "/api/model",
"query": {
"location[directory]": [
"/tmp/opencode/packages/tui"
]
},
"status": 200,
"json": {
"location": {
"directory": "/tmp/opencode/packages/tui",
"project": {
"id": "proj_test",
"directory": "/tmp/opencode",
"canonical": "/tmp/opencode"
}
},
"data": []
}
},
{
"method": "GET",
"path": "/api/plugin",
"query": {
"location[directory]": [
"/tmp/opencode/packages/tui"
]
},
"status": 200,
"json": {
"location": {
"directory": "/tmp/opencode/packages/tui",
"project": {
"id": "proj_test",
"directory": "/tmp/opencode",
"canonical": "/tmp/opencode"
}
},
"data": []
}
},
{
"method": "GET",
"path": "/api/project",
"query": {},
"status": 200,
"json": []
},
{
"method": "GET",
"path": "/api/provider",
"query": {
"location[directory]": [
"/tmp/opencode/packages/tui"
]
},
"status": 200,
"json": {
"location": {
"directory": "/tmp/opencode/packages/tui",
"project": {
"id": "proj_test",
"directory": "/tmp/opencode",
"canonical": "/tmp/opencode"
}
},
"data": []
}
},
{
"method": "GET",
"path": "/api/reference",
"query": {
"location[directory]": [
"/tmp/opencode/packages/tui"
]
},
"status": 200,
"json": {
"location": {
"directory": "/tmp/opencode/packages/tui",
"project": {
"id": "proj_test",
"directory": "/tmp/opencode/packages/tui",
"canonical": "/tmp/opencode/packages/tui"
}
},
"data": []
}
},
{
"method": "GET",
"path": "/api/session",
"query": {
"limit": [
"200"
],
"order": [
"desc"
],
"parentID": [
"ses_b"
]
},
"status": 200,
"json": {
"data": [],
"cursor": {}
}
},
{
"method": "GET",
"path": "/api/session/active",
"query": {},
"status": 200,
"json": {
"data": {}
}
},
{
"method": "GET",
"path": "/api/session/ses_b",
"query": {},
"status": 200,
"json": {
"data": {
"id": "ses_b",
"title": "Fix the parser",
"projectID": "proj_test",
"cost": 0,
"tokens": {
"input": 0,
"output": 0,
"reasoning": 0,
"cache": {
"read": 0,
"write": 0
}
},
"time": {
"created": 2,
"updated": 2
},
"location": {
"directory": "/tmp/opencode/packages/tui"
}
}
}
},
{
"method": "GET",
"path": "/api/session/ses_b/form",
"query": {},
"status": 200,
"json": {
"data": []
}
},
{
"method": "GET",
"path": "/api/session/ses_b/inbox",
"query": {},
"status": 200,
"json": {
"data": []
}
},
{
"method": "GET",
"path": "/api/session/ses_b/message",
"query": {
"limit": [
"20"
],
"order": [
"desc"
]
},
"status": 200,
"json": {
"data": [
{
"id": "msg_1",
"type": "user",
"text": "Why does the parser fail?",
"time": {
"created": 1
}
}
],
"cursor": {}
}
},
{
"method": "GET",
"path": "/api/session/ses_b/permission",
"query": {},
"status": 200,
"json": {
"data": []
}
},
{
"method": "GET",
"path": "/api/shell",
"query": {
"location[directory]": [
"/tmp/opencode/packages/tui"
]
},
"status": 200,
"json": {
"location": {
"directory": "/tmp/opencode/packages/tui",
"project": {
"id": "proj_test",
"directory": "/tmp/opencode",
"canonical": "/tmp/opencode"
}
},
"data": []
}
},
{
"method": "GET",
"path": "/api/skill",
"query": {
"location[directory]": [
"/tmp/opencode/packages/tui"
]
},
"status": 200,
"json": {
"location": {
"directory": "/tmp/opencode/packages/tui",
"project": {
"id": "proj_test",
"directory": "/tmp/opencode",
"canonical": "/tmp/opencode"
}
},
"data": []
}
},
{
"method": "GET",
"path": "/api/vcs",
"query": {
"location[directory]": [
"/tmp/opencode/packages/tui"
]
},
"status": 200,
"json": {
"location": {
"directory": "/tmp/opencode/packages/tui",
"project": {
"id": "proj_test",
"directory": "/tmp/opencode",
"canonical": "/tmp/opencode"
}
},
"data": {
"branch": {
"current": "main",
"default": "main"
}
}
}
},
{
"method": "POST",
"path": "/api/rpc/opencode.goal/get",
"query": {
"location[directory]": [
"/tmp/opencode/packages/tui"
]
},
"body": {
"input": {
"sessionID": "ses_b"
}
},
"status": 200,
"json": {
"output": null
}
}
]
}
}

View file

@ -0,0 +1,82 @@
{
"width": 100,
"height": 30,
"rows": [
" Fix the parser + ",
" ",
" ┃ ",
" ┃ Why does the parser fail? ",
" ┃ ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ┃ ",
" ┃ see [Pasted ~3 lines] ",
" ┃ ",
" ┃ ",
" ╹▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀ ",
" /tmp/opencode/packages/tui:main shift+tab agents ctrl+p commands ",
" "
],
"styles": [
"#ffffffff #1e1e1eff 0",
"#eeeeeeff #1e1e1eff 1",
"#808080ff #0a0a0aff 0",
"#ffffffff #0a0a0aff 0",
"#3c70b8ff #141414ff 0",
"#ffffffff #141414ff 0",
"#eeeeeeff #141414ff 0",
"#484848ff #0a0a0aff 0",
"#eeeeeeff #1e1e1eff 0",
"#0a0a0aff #f5a742ff 1",
"#1e1e1eff #0a0a0aff 0",
"#eeeeeeff #0a0a0aff 0"
],
"runs": [
[[0,3],[1,14],[0,15],[2,3],[3,65]],
[[3,100]],
[[3,2],[4,1],[5,95],[3,2]],
[[3,2],[4,1],[5,2],[6,25],[5,68],[3,2]],
[[3,2],[4,1],[5,95],[3,2]],
[[3,100]],
[[3,100]],
[[3,100]],
[[3,100]],
[[3,100]],
[[3,100]],
[[3,100]],
[[3,100]],
[[3,100]],
[[3,100]],
[[3,100]],
[[3,100]],
[[3,100]],
[[3,100]],
[[3,100]],
[[3,100]],
[[3,100]],
[[3,100]],
[[3,2],[7,1],[0,95],[3,2]],
[[3,2],[7,1],[0,2],[8,4],[9,17],[8,1],[0,71],[3,2]],
[[3,2],[7,1],[0,95],[3,2]],
[[3,2],[7,1],[0,95],[3,2]],
[[3,2],[7,1],[10,95],[3,2]],
[[3,2],[2,31],[3,32],[11,10],[2,6],[3,2],[11,7],[2,8],[3,2]],
[[3,100]]
]
}

View file

@ -0,0 +1,81 @@
{
"width": 100,
"height": 30,
"rows": [
" Fix the parser + ",
" ",
" ┃ ",
" ┃ Why does the parser fail? ",
" ┃ ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ┃ ",
" ┃ see first line ",
" ┃ second line ",
" ┃ third line ",
" ┃ ",
" ┃ ",
" ╹▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀ ",
" /tmp/opencode/packages/tui:main shift+tab agents ctrl+p commands ",
" "
],
"styles": [
"#ffffffff #1e1e1eff 0",
"#eeeeeeff #1e1e1eff 1",
"#808080ff #0a0a0aff 0",
"#ffffffff #0a0a0aff 0",
"#3c70b8ff #141414ff 0",
"#ffffffff #141414ff 0",
"#eeeeeeff #141414ff 0",
"#484848ff #0a0a0aff 0",
"#eeeeeeff #1e1e1eff 0",
"#1e1e1eff #0a0a0aff 0",
"#eeeeeeff #0a0a0aff 0"
],
"runs": [
[[0,3],[1,14],[0,15],[2,3],[3,65]],
[[3,100]],
[[3,2],[4,1],[5,95],[3,2]],
[[3,2],[4,1],[5,2],[6,25],[5,68],[3,2]],
[[3,2],[4,1],[5,95],[3,2]],
[[3,100]],
[[3,100]],
[[3,100]],
[[3,100]],
[[3,100]],
[[3,100]],
[[3,100]],
[[3,100]],
[[3,100]],
[[3,100]],
[[3,100]],
[[3,100]],
[[3,100]],
[[3,100]],
[[3,100]],
[[3,100]],
[[3,2],[7,1],[0,95],[3,2]],
[[3,2],[7,1],[0,2],[8,14],[0,79],[3,2]],
[[3,2],[7,1],[0,2],[8,11],[0,82],[3,2]],
[[3,2],[7,1],[0,2],[8,11],[0,82],[3,2]],
[[3,2],[7,1],[0,95],[3,2]],
[[3,2],[7,1],[0,95],[3,2]],
[[3,2],[7,1],[9,95],[3,2]],
[[3,2],[2,31],[3,32],[10,10],[2,6],[3,2],[10,7],[2,8],[3,2]],
[[3,100]]
]
}

View file

@ -0,0 +1,80 @@
{
"width": 100,
"height": 30,
"rows": [
" Fix the parser + ",
" ",
" ┃ ",
" ┃ Why does the parser fail? ",
" ┃ ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ┃ ",
" ┃ ",
" ┃ ",
" ┃ ",
" ╹▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀ ",
" /tmp/opencode/packages/tui:main shift+tab agents ctrl+p commands ",
" "
],
"styles": [
"#ffffffff #1e1e1eff 0",
"#eeeeeeff #1e1e1eff 1",
"#808080ff #0a0a0aff 0",
"#ffffffff #0a0a0aff 0",
"#3c70b8ff #141414ff 0",
"#ffffffff #141414ff 0",
"#eeeeeeff #141414ff 0",
"#484848ff #0a0a0aff 0",
"#1e1e1eff #0a0a0aff 0",
"#eeeeeeff #0a0a0aff 0"
],
"runs": [
[[0,3],[1,14],[0,15],[2,3],[3,65]],
[[3,100]],
[[3,2],[4,1],[5,95],[3,2]],
[[3,2],[4,1],[5,2],[6,25],[5,68],[3,2]],
[[3,2],[4,1],[5,95],[3,2]],
[[3,100]],
[[3,100]],
[[3,100]],
[[3,100]],
[[3,100]],
[[3,100]],
[[3,100]],
[[3,100]],
[[3,100]],
[[3,100]],
[[3,100]],
[[3,100]],
[[3,100]],
[[3,100]],
[[3,100]],
[[3,100]],
[[3,100]],
[[3,100]],
[[3,2],[7,1],[0,95],[3,2]],
[[3,2],[7,1],[0,95],[3,2]],
[[3,2],[7,1],[0,95],[3,2]],
[[3,2],[7,1],[0,95],[3,2]],
[[3,2],[7,1],[8,95],[3,2]],
[[3,2],[2,31],[3,32],[9,10],[2,6],[3,2],[9,7],[2,8],[3,2]],
[[3,100]]
]
}

View file

@ -0,0 +1,81 @@
{
"width": 100,
"height": 30,
"rows": [
" Fix the parser + ",
" ",
" ┃ ",
" ┃ Why does the parser fail? ",
" ┃ ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ┃ ",
" ┃ short red paste ",
" ┃ ",
" ┃ ",
" ╹▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀ ",
" /tmp/opencode/packages/tui:main shift+tab agents ctrl+p commands ",
" "
],
"styles": [
"#ffffffff #1e1e1eff 0",
"#eeeeeeff #1e1e1eff 1",
"#808080ff #0a0a0aff 0",
"#ffffffff #0a0a0aff 0",
"#3c70b8ff #141414ff 0",
"#ffffffff #141414ff 0",
"#eeeeeeff #141414ff 0",
"#484848ff #0a0a0aff 0",
"#eeeeeeff #1e1e1eff 0",
"#1e1e1eff #0a0a0aff 0",
"#eeeeeeff #0a0a0aff 0"
],
"runs": [
[[0,3],[1,14],[0,15],[2,3],[3,65]],
[[3,100]],
[[3,2],[4,1],[5,95],[3,2]],
[[3,2],[4,1],[5,2],[6,25],[5,68],[3,2]],
[[3,2],[4,1],[5,95],[3,2]],
[[3,100]],
[[3,100]],
[[3,100]],
[[3,100]],
[[3,100]],
[[3,100]],
[[3,100]],
[[3,100]],
[[3,100]],
[[3,100]],
[[3,100]],
[[3,100]],
[[3,100]],
[[3,100]],
[[3,100]],
[[3,100]],
[[3,100]],
[[3,100]],
[[3,2],[7,1],[0,95],[3,2]],
[[3,2],[7,1],[0,2],[8,15],[0,78],[3,2]],
[[3,2],[7,1],[0,95],[3,2]],
[[3,2],[7,1],[0,95],[3,2]],
[[3,2],[7,1],[9,95],[3,2]],
[[3,2],[2,31],[3,32],[10,10],[2,6],[3,2],[10,7],[2,8],[3,2]],
[[3,100]]
]
}

View file

@ -16,6 +16,8 @@ export type Step =
| { keys: string[] }
// Text, one key press per character.
| { type: string }
// A bracketed paste of the text (E.4).
| { paste: string }
// A left press and release at a cell, `[x, y]`.
| { click: [number, number] }
// One `/api/event` event.

View file

@ -0,0 +1,25 @@
// Pastes (P06): a three-line paste collapses into a `[Pasted ~3 lines]` part in the `extmark.paste` style, the
// same text pasted again right after it expands in place, and a short paste goes in as it is, ANSI stripped.
import { defineApp, session, user } from "../../lib/app"
const pasted = "first line\nsecond line\nthird line"
export default defineApp({
args: { sessionID: "ses_b" },
routes: [
{ path: "/api/session/ses_b", json: { data: session("ses_b", "Fix the parser", { updated: 2 }) } },
{ path: "/api/session/ses_b/message", json: { data: [user("msg_1", "Why does the parser fail?")], cursor: {} } },
{ path: "/api/session/ses_b/inbox", json: { data: [] } },
],
steps: [
{ checkpoint: "open", until: "Why does the parser fail?" },
{ type: "see " },
{ paste: pasted },
{ checkpoint: "compact", until: "[Pasted ~3 lines]" },
{ paste: pasted },
{ checkpoint: "expanded", until: "third line" },
{ keys: ["ctrl+c"] },
{ paste: "short \u001b[31mred\u001b[0m paste" },
{ checkpoint: "short", until: "short red paste" },
],
})