Skip to content

Conversation

jmmoser
Copy link
Contributor

@jmmoser jmmoser commented Sep 4, 2025

Issue #, if available:
#2633

Same as #2635, just a different branch from head repository.

Description of changes:

Implements persistent chat history that survives CLI restarts and is isolated by working directory.

Features:

  • Chat history persists across CLI sessions using SQLite database
  • History is isolated per working directory (/project/a vs /project/b)
  • Up arrow navigation works with persistent history
  • Dual cleanup limits: max 100 entries per directory, 1000 total
  • Silent failure: history issues don't break CLI functionality
  • Filters out empty/whitespace-only and confirmation inputs

Implementation:

  • Database table: chat_readline_history(input TEXT, cwd TEXT, timestamp INTEGER) with index on cwd and timestamp
  • Uses existing database infrastructure and Os abstraction
  • Transactional insert+cleanup for data consistency
  • Early return for empty inputs to avoid unnecessary DB operations

Files modified:

  • crates/chat-cli/src/database/mod.rs: Added add_chat_readline_history_entry() and get_chat_readline_history()
  • crates/chat-cli/src/cli/chat/input_source.rs: Load history on startup, save on input

Edge cases handled:

  • Database failures (silent)
  • Empty/whitespace and confirmation inputs (filtered)
  • Working directory access failures (fallback to default)
  • Unicode/special characters (parameterized queries)

Interaction with other features:

  • Does not conflict with --resume. It enhances it.
  • Does not conflict with /load.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Implements persistent chat history that survives CLI restarts and is isolated by working directory.

Features:
- Chat history persists across CLI sessions using SQLite database
- History is isolated per working directory (/project/a vs /project/b)
- Up arrow navigation works with persistent history
- Dual cleanup limits: max 100 entries per directory, 1000 total
- Silent failure: history issues don't break CLI functionality
- Filters out empty/whitespace-only and confirmation inputs

Implementation:
- Database table: chat_readline_history(input TEXT, cwd TEXT, timestamp INTEGER) with index on cwd and timestamp
- Uses existing database infrastructure and Os abstraction
- Transactional insert+cleanup for data consistency
- Early return for empty inputs to avoid unnecessary DB operations

Files modified:
- crates/chat-cli/src/database/mod.rs: Added add_chat_readline_history_entry() and get_chat_readline_history()
- crates/chat-cli/src/cli/chat/input_source.rs: Load history on startup, save on input

Edge cases handled:
- Database failures (silent)
- Empty/whitespace and confirmation inputs (filtered)
- Working directory access failures (fallback to default)
- Unicode/special characters (parameterized queries)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant