feat: add auto-save functionality for chat conversations #3345
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue #, if available: #3322
Description of changes:
This PR adds an automatic conversation saving feature to Q CLI, allowing users to preserve their chat sessions without manually executing the
/savecommand.Key Features
chat.enableAutoSave = false)auto-save-YYYYMMDD-HHMMSS.jsonat session startchat.enableAutoSave(boolean): Enable/disable auto-savechat.autoSavePath(string): Customize file path pattern (default:auto-save-{timestamp}.json)Implementation Details
Files Changed:
crates/chat-cli/src/database/settings.rs(+9 lines)ChatEnableAutoSaveandChatAutoSavePathsettingscrates/chat-cli/src/cli/chat/auto_save.rs(+61 lines, new file)AutoSaveManagerstructcrates/chat-cli/src/cli/chat/mod.rs(+13 lines)AutoSaveManagerintoChatSessionTotal code changes: 83 lines
Testing
/saveand/loadcommands verifiedUsage Example
bash
Enable auto-save
q settings chat.enableAutoSave true
Start chat (auto-save will create auto-save-20251101-220000.json)
q chat
│ Hello, this will be auto-saved
│ What is 2+2?
│ /quit
File is automatically saved after each AI response
ls auto-save-*.json
Design Decisions
Backward Compatibility
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.