Files
codewhale/crates
Hunter Bown 162e2e027c feat(composer): cross-session input history persistence (#366)
Pressing Up-arrow at the composer now recalls submissions from previous
sessions, not just the current one. Implementation:

- New `crates/tui/src/composer_history.rs` module with `load_history()`
  + `append_history()`. Persists to `~/.deepseek/composer_history.txt`
  (one entry per line, oldest first). Capped at 1000 entries — entries
  older than the cap are pruned at append time so the file never grows
  unboundedly.
- `App::new` now seeds `input_history` from the persisted file at
  startup, so Up-arrow at first launch shows yesterday's prompts.
- `App::submit_message` mirrors each non-slash submission to the
  persisted history. Slash commands and empty/whitespace submissions
  are skipped — those don't help recall and would pollute the stream.
- Consecutive-duplicate dedup so re-submitting the same prompt doesn't
  bloat the file.

The persisted history is global (not per-workspace) — matches the
arrow-up recall pattern users expect from shells and Claude Code. Per-
workspace scoping is a follow-up if multi-project users find it noisy.

Tests: 6 unit tests cover round-trip, slash-skip, empty-skip,
consecutive-duplicate dedup, cap-pruning, and missing-file safety. The
test module uses an internal Mutex to serialize HOME env mutations so
tests can still run in parallel without stomping each other.

Closes #366.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-02 10:32:45 -05:00
..