仿 Codex 的 DSH Web GUI 输入历史插件:在会话输入框按 ↑/↓ 浏览历史 prompt,历史跨会话、跨重启持久保留。
A Codex-style input-history plugin for the DSH Web GUI: browse previous prompts with ↑/↓ in the session composer, with history persisted across conversations and restarts.
↑ recalls, ↓ moves forward: an empty composer starts browsing from the newest entry; ↓ moves toward newer entries, and moving past the newest one clears the composer and exits browsing.
Current conversation first: returning to a conversation recalls that conversation's own history first; pressing ↑ further walks into other conversations' history.
Persistent across conversations and restarts: a user-level JSONL history with stable monotonic IDs remains recallable after page reloads and restarts.
Safe key routing: with a non-empty draft, a caret in the middle of multi-line text, an active selection, or an open popup, arrow keys are handed back to the editor and never overwrite a draft.
Esc draft insurance: clearing an unsent non-empty draft stores it in the history (text only) so ↑ can bring it back.
Position indicator: a pill above the composer shows the current position (e.g. ↑ 2/38); clicking its × twice clears all history.
Text-only storage with auto-trim: only plain text is persisted; adjacent identical entries are folded; oversized files drop the oldest complete records while keeping the newest.
History has two layers: a persistent layer (the cross-conversation JSONL file, text only) and a local layer (the current conversation's recall list, including Esc-stashed drafts).
Entering or returning to a conversation freezes a snapshot: the snapshot keeps only other conversations' records, while this conversation's records are seeded into the local layer — the unified index order is [other conversations | this conversation].
Example: conversation A submits a, b, c; conversation B submits e, f; back in A, ↑ recalls c → b → a → f → e (current conversation first, global history as fallback).
Every record carries a stable monotonic ID; trimming deletes only the oldest complete records and never renumbers. New submissions in the current conversation appear only in the local layer, so every entry appears exactly once. Adjacent identical entries in the local layer (text + conversation + attachment signature) are folded, while the persistent layer keeps duplicates.
Handed back to the editor: move the caret / candidates only
Esc (non-empty draft)
Clear the draft and store it in history (recoverable with ↑)
Esc (browsing)
Exit browsing; no-op when the draft is empty
Action
Behavior
Click the pill's × twice (within 3 s)
The first click arms "confirm?", the second clears all history (including the persistent file)
Takeover rules: the key target must be the conversation composer; browsing starts with ↑ only on a semantically empty draft (no text, attachments, or mentions); any user edit to the text or attachments while browsing immediately releases the takeover and invalidates in-flight requests; keys already consumed by a popup or command menu are always left alone.
History is written to prompt-history.jsonl under the DSH home directory ($DSH_HOME/prompt-history.jsonl; default ~/.dsh/prompt-history.jsonl when DSH_HOME is unset), one JSON record per line; only plain text is saved — no images, mention bindings, or other attachment content.
Capacity: the persistent file is capped at roughly 10 MB (oldest complete records are dropped, the newest is always kept); the current conversation's local list is capped at 200 entries / 256 KB (oldest evicted). The pill's × clears everything at any time.
安装 / Installation
前置条件:已安装 pnpm 的 DSH 环境(dsh plugin 内部转发给 pnpm)。
从 GitHub 安装:
dsh plugin --profile web add github:liguanyu/dsh_PromptRecall
本地安装:
git clone https://github.com/liguanyu/dsh_PromptRecall
cd dsh_PromptRecall
pnpm install # link 安装沿仓库真实路径解析依赖,需先在仓库内安装
dsh plugin --profile web add .
Prerequisite: a DSH environment with pnpm installed (dsh plugin forwards to pnpm internally).
Install from GitHub:
dsh plugin --profile web add github:liguanyu/dsh_PromptRecall
Install locally:
git clone https://github.com/liguanyu/dsh_PromptRecall
cd dsh_PromptRecall
pnpm install # link installs resolve dependencies via the repo's real path; run install in the repo first
dsh plugin --profile web add .
Local installs use pnpm's link: protocol (code edits take effect on restart without reinstalling); because Node resolves the link's real path, run pnpm install once so the repository has its runtime dependencies. github: installs need no such step (dependencies are installed into the profile tree with the package).
After installation, restart DSH Web (dsh web) to activate; the plugin becomes a row of the web composition, loads automatically at boot, and needs no manual define/run steps.
History data is written to $DSH_HOME/prompt-history.jsonl (default ~/.dsh/prompt-history.jsonl); the directory is created automatically on first write, so no manual setup is needed.