Skip to content

fix(tui): dedupe consecutive prompt history entries#27816

Merged
kitlangton merged 1 commit into
devfrom
worktree-tui-history-dedupe
May 16, 2026
Merged

fix(tui): dedupe consecutive prompt history entries#27816
kitlangton merged 1 commit into
devfrom
worktree-tui-history-dedupe

Conversation

@kitlangton
Copy link
Copy Markdown
Contributor

Summary

Clearing a prompt with at least 20 characters saves the draft to prompt history (in-memory + prompt-history.jsonl). If you then press the history-previous keybind to restore that entry and clear it again, the same entry was being appended a second time — every cycle adds another duplicate.

The fix is a standard shell-style dedupe: skip the append when the new entry deep-equals the most recent history entry.

Changes

  • packages/opencode/src/cli/cmd/tui/component/prompt/history.tsx — new pure helper isDuplicateEntry(prev, next) (deep compare via JSON), called at the top of append(). On a duplicate, only the index is reset (so navigation stays consistent), and no write hits memory or disk.
  • packages/opencode/test/cli/cmd/tui/prompt-history.test.ts — unit tests for the dedupe helper covering no-previous, identical, differing input, differing parts, and differing mode.

Test plan

  • bun run test test/cli/cmd/tui/prompt-history.test.ts — 5 pass
  • bun run typecheck — clean
  • Manual: type >20 chars, clear, press ↑, clear again — only one entry in prompt-history.jsonl

Clearing a prompt with >=20 chars saves it to history. Restoring that
entry from history and clearing again was appending a duplicate to both
the in-memory store and prompt-history.jsonl. Skip the append when the
new entry deep-equals the most recent one.
@kitlangton kitlangton enabled auto-merge (squash) May 16, 2026 02:30
@kitlangton kitlangton merged commit f3b0d3d into dev May 16, 2026
12 checks passed
@kitlangton kitlangton deleted the worktree-tui-history-dedupe branch May 16, 2026 02:36
zenoda pushed a commit to zenoda/opencode that referenced this pull request May 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant