feat(web): recall prompt history from the plugin with a browser fallback
The composer's ↑/↓ history is the web port of pi2.nvim's prompt buffer, so it has to walk the archive nvim walks — not a copy of it. Three tiers: the plugin owns the text, the daemon relays one live-only read, the browser keeps a mirror. - `features/chat/prompt-history.ts`: the readline rules (`appendEntry`: blank ignored, consecutive dedupe, newest 500), the `localStorage` mirror (`pi2-prompt-history`, per workspace, 40 workspaces LRU), the `PromptHistorySource` seam, and `PromptHistoryNav` — the per-composer cursor with a stashed draft, independent positions, and a reset on edit/send - `features/chat/prompt-history-feed.ts`: `usePromptHistory(workspaceId)` reads `GET /workspaces/:id/prompt-history`, appends a send optimistically, refreshes the mirror from every successful read, and falls back to the mirror whenever the relay cannot answer (no plugin, no capability, a 404 from an older daemon, an offline browser). One workspace-scoped read per page, never per keystroke. - composer: ↑ recalls from the first line, ↓ from the last line or while browsing, `<C-p>`/`<C-n>` always recall; an IME composition and a text selection keep their keys; the caret lands at the end of a recalled prompt and a manual edit ends recall - fixes a mirror bug found while testing it: a full list that accepts one more entry and drops the oldest has the same length, so the old "unchanged" check silently stopped recording after 500 prompts - `docs/prompt-history.md` records the tiers, the key map, the storage contract and what is deliberately not shared yet (cross-host, history without nvim); the UI mock server answers the new endpoint so the visual harness stays honest Version skew is boring by design: an old daemon (404) or an old plugin (no capability) keeps recall working from the mirror.
This commit is contained in:
1 parent
32292873f9
commit
b8f1fca5bd
11 files changed
+1324
-6
No files matched your search
@@ -72,6 +72,7 @@ owner/repo/workflow filename, not the npm name).
|
||||
| `docs/protocol.md` | the browser ↔ daemon ↔ plugin wire contract |
|
||||
| `docs/install.md` | canonical CLI-first install guide, channels, run modes, services, `pi2 update` |
|
||||
| `docs/session-dot.md` | the session-list status dot: the `:PiSessions` matrix, the unread flags, the one blink clock |
|
||||
| `docs/prompt-history.md` | composer ↑/↓ recall: key rules, per-workspace `localStorage` contract, nvim parity |
|
||||
| `docs/deployment.md` | env vars, runtime files, ports, auth, services, troubleshooting |
|
||||
| `docs/e2e.md` | scenario ids, isolation, skip conditions, report paths |
|
||||
| `docs/testing.md` | test architecture, performance tuning, hybrid core CPU guidelines |
|
||||
|
||||
Reference in new issue
Block a user