test(e2e): cover prompt-history recall end to end

A14 (API) and B15 (browser) make the feature verifiable against a real daemon,
a real headless nvim and a real `pi`.

- A14: the prompt A4 sent through `prompt.send` is in the plugin's archive
  exactly once — the console → daemon → plugin → daemon → console round trip, and
  the guard for "a web send is recorded at all"; `?limit=1` answers the newest
  entry; a freshly added workspace with no instance answers
  `{live:false, supported:false, entries:[]}` and its `/workspaces` row still
  reports `instance: null`, which is the no-spawn rule a keystroke depends on
- B15: wipes the browser mirror, reloads, checks the console fetched
  `/prompt-history`, walks ↑ back to the prompt B6 sent, walks ↓ out to the empty
  draft, recalls with Ctrl+P from a mid-line caret, and asserts that browsing
  never sends anything
- `docs/e2e.md` documents both (A0–A14, B1–B15)

Attribution done while landing this: with the plugin change stashed, A14 fails
(the capability is absent) while A5 reproduces identically and B1/B2/B3/B9/B13
fail the same way — pre-existing, not this feature. A5 is the coalesced
`text_delta` after `agent_settled` the suite already lists as a suspected
product bug; A11 is model-dependent and passed on the rerun.
This commit is contained in:
yuez committed 2026-11-02 11:13:37 +08:00
1 parent b8f1fca5bd
commit ce87799b61
3 files changed
+220 -7

No files matched your search

+27 -6
View File
@@ -28,8 +28,8 @@ the real daemon/plugin/browser, never `MOCK.*` data.
The v1 gate is green when:
- **A0–A13** (API/WS against a real headless nvim + real pi) pass.
- **B1–B14** (Playwright against the daemon-served production bundle) pass.
- **A0–A14** (API/WS against a real headless nvim + real pi) pass.
- **B1–B15** (Playwright against the daemon-served production bundle) pass.
- **C1–C4** (responsive, theme, language, no console errors) pass.
- `tsc --noEmit`, `vitest run` (daemon), `vitest run` (web) stay green.
- Every failure found while running this plan is either fixed and re-verified, or
@@ -110,8 +110,8 @@ then the browser suite, each in its own temp root. Both drivers are standalone w
## 4. Scenarios
All scenario ids below are implemented in the two drivers: `scenario("A0", …)` … `scenario("A13", …)`
in `api-e2e.mjs`, `scenario("B1", …)` … `scenario("B14", …)` and `scenario("C1", …)` …
All scenario ids below are implemented in the two drivers: `scenario("A0", …)` … `scenario("A14", …)`
in `api-e2e.mjs`, `scenario("B1", …)` … `scenario("B15", …)` and `scenario("C1", …)` …
`scenario("C4", …)` in `ui-e2e.mjs`. A driver exits non-zero only on **FAIL**; SKIP is
tolerant, and every skip is printed with its reason and written into the report.
@@ -235,6 +235,18 @@ The plan's original intent below is unchanged; the legend **P0**/**P1**/**P2** s
daemon (next request still 200).
- every error is a JSON body with `code`, `message`, `retryable`.
**A14 Prompt history recall** (`GET /workspaces/:id/prompt-history`, protocol §3.1.1)
- the prompt A4 sent through `prompt.send` is in the plugin's archive: `live:true`,
`supported:true`, and the text appears **exactly once** in `entries` — the proof that
the round trip browser → daemon → plugin archive → daemon → browser works, and that a
web send is recorded by the plugin at all (`prompt.send` does not go through the chat
UI, so this is a real regression guard).
- `?limit=1` answers exactly one entry equal to the newest of the full read.
- a freshly added workspace with **no** instance answers `200 {live:false, supported:false,
entries:[]}`, and its `/workspaces` row still has `instance: null` afterwards: the read
must never spawn (`instances.ensure()` would boot an nvim on a keystroke).
- unknown workspace → `404`.
### 4.2 B — Browser suite (Playwright, daemon-served bundle)
**B1 Unpaired guard**
@@ -326,6 +338,15 @@ The plan's original intent below is unchanged; the legend **P0**/**P1**/**P2** s
back restores English; no missing-key placeholder.
- switch theme light/dark/system: `<html data-theme>` changes and persists.
**B15 Composer recall**
- open the B6 session in a fresh page, delete `localStorage` `pi2-prompt-history` and reload,
then confirm the console still fetched `GET /workspaces/:id/prompt-history` (200) — recall
must work from the plugin's archive, not from the browser mirror.
- `↑` recalls the newest archived prompt, and walking `↑` reaches the prompt B6 sent (later
scenarios write into the same workspace archive, so the newest entry is not necessarily
B6's); walking `↓` back out restores the empty draft; `Ctrl+P` recalls from a mid-line caret.
- recall sends nothing: no `prompt.send` may appear while browsing.
### 4.3 C — Responsive / visual
- **C1** 1440×900, 768×1024, 380×780 on `/workspaces`, `/chat`, `/status`, `/connect`
@@ -384,10 +405,10 @@ which were skipped and why (non-blocking only), and the command that reproduces
```bash
cd <repo> # the pi2 CLI/daemon checkout (this repository)
# backend only (A0–A13): tsc, then `pi2 daemon` + headless nvim + real pi
# backend only (A0–A14): tsc, then `pi2 daemon` + headless nvim + real pi
bash scripts/e2e/run-api.sh
# browser (B1–B14, C1–C4): also builds web/dist (pnpm), then Playwright
# browser (B1–B15, C1–C4): also builds web/dist (pnpm), then Playwright
bash scripts/e2e/run-ui.sh
# both, API first; exit 0 only when neither suite failed