mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-29 11:42:17 +00:00
fix(cli-rs): make P-APP recordings stable across replays
The migration poll starts 1 s after mount, so a fast scenario sometimes missed it; the runner now stays open past it. The placeholder mask now runs to the end of the row, since placeholders differ in length. Six replays give the same files.
This commit is contained in:
parent
0ad7f9d20b
commit
4e14ca4ac5
6 changed files with 22 additions and 4 deletions
|
|
@ -123,7 +123,9 @@ selects one. Each case:
|
|||
three polls in a row read the same cells, not only the same characters. Highlighting changes colors after
|
||||
the text shows. A poll that meets a frame in progress (`OutputBusy`) is skipped. The process runs with
|
||||
`TZ=UTC`, so dates in the cells are the same on every machine;
|
||||
4. writes the cell files and the recording.
|
||||
4. stays open until 1.5 s after `ready`, so the migration status poll, which starts 1 s after mount
|
||||
(`packages/tui/src/component/migration-overlay.tsx:19`), is recorded in every scenario;
|
||||
5. writes the cell files and the recording.
|
||||
|
||||
Replaying a scenario twice must give byte-identical files. That is the step's TS-against-TS proof.
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@ const files = Array.from(new Bun.Glob("scenarios/*/*.app.ts").scanSync({ cwd: pa
|
|||
.sort()
|
||||
.filter((file) => !only || file === `scenarios/${only}.app.ts`)
|
||||
|
||||
const STARTUP_READS_MS = 1_500
|
||||
|
||||
type Setup = Awaited<ReturnType<typeof createAppFixture>>
|
||||
type Logged = {
|
||||
method: string
|
||||
|
|
@ -67,6 +69,7 @@ async function record(name: string, file: string) {
|
|||
},
|
||||
})
|
||||
await setup.ready
|
||||
const started = Date.now()
|
||||
const steps: (Step & { fixture?: string })[] = []
|
||||
for (const step of scenario.steps) {
|
||||
if ("keys" in step) step.keys.forEach((key) => press(setup, key))
|
||||
|
|
@ -81,6 +84,9 @@ async function record(name: string, file: string) {
|
|||
await writeFixture(`${parity}fixtures/${fixture}.json`, cells)
|
||||
steps.push({ ...step, fixture })
|
||||
}
|
||||
// The migration status poll starts 1 s after mount (src/component/migration-overlay.tsx:19). Staying open
|
||||
// past it records it in every scenario, however fast the steps ran.
|
||||
await Bun.sleep(Math.max(0, STARTUP_READS_MS - (Date.now() - started)))
|
||||
const unmatched = log.filter((entry) => entry.unmatched)
|
||||
if (unmatched.length > 0)
|
||||
throw new Error(
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@
|
|||
"until": "Ask anything",
|
||||
"masks": [
|
||||
{
|
||||
"line": "Ask anything… \".*\"",
|
||||
"line": "Ask anything….*",
|
||||
"reason": "the prompt placeholder is picked at random"
|
||||
}
|
||||
],
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@
|
|||
[[0,100]],
|
||||
[[0,100]],
|
||||
[[0,13],[6,1],[7,74],[0,12]],
|
||||
[[0,13],[6,1],[7,2],[8,32],[7,40],[0,12]],
|
||||
[[0,13],[6,1],[7,2],[8,84]],
|
||||
[[0,13],[6,1],[7,74],[0,12]],
|
||||
[[0,13],[6,1],[7,74],[0,12]],
|
||||
[[0,13],[6,1],[9,74],[0,12]],
|
||||
|
|
|
|||
|
|
@ -176,6 +176,15 @@
|
|||
"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",
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
// Home with two sessions, the session list, and opening the newest session from it (T01, DLG14).
|
||||
import { assistant, defineApp, session, user } from "../../lib/app"
|
||||
|
||||
const placeholder = { line: 'Ask anything… ".*"', reason: "the prompt placeholder is picked at random" }
|
||||
// To the end of the row: the placeholders differ in length.
|
||||
const placeholder = { line: "Ask anything….*", reason: "the prompt placeholder is picked at random" }
|
||||
|
||||
export default defineApp({
|
||||
routes: [
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue