Skip to content

Conversation

@NB3025
Copy link

@NB3025 NB3025 commented Nov 1, 2025

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 /save command.

Key Features

  • Opt-in by default: Auto-save is disabled by default (chat.enableAutoSave = false)
  • Session-based file naming: Generates auto-save-YYYYMMDD-HHMMSS.json at session start
  • Persistent filename: Uses the same file throughout the session (overwrites on each save)
  • Silent operation: No user notifications, errors are logged without interrupting conversations
  • Configurable: Two new settings:
    • chat.enableAutoSave (boolean): Enable/disable auto-save
    • chat.autoSavePath (string): Customize file path pattern (default: auto-save-{timestamp}.json)

Implementation Details

Files Changed:

  1. crates/chat-cli/src/database/settings.rs (+9 lines)

    • Added ChatEnableAutoSave and ChatAutoSavePath settings
  2. crates/chat-cli/src/cli/chat/auto_save.rs (+61 lines, new file)

    • Implemented AutoSaveManager struct
    • Session-based filename generation
    • Silent error handling
  3. crates/chat-cli/src/cli/chat/mod.rs (+13 lines)

    • Integrated AutoSaveManager into ChatSession
    • Added auto-save calls after AI response completion (2 locations)

Total code changes: 83 lines

Testing

  • ✅ All 327 existing tests pass
  • ✅ No impact on existing functionality
  • ✅ Manual testing completed:
    • Default disabled state verified
    • Auto-save activation and file generation tested
    • Session persistence confirmed
    • Error handling validated (permission denied, disk full scenarios)
    • Compatibility with existing /save and /load commands verified

Usage 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

  1. Opt-in approach: Respects user choice and avoids unexpected behavior
  2. Session-based filename: Prevents file proliferation while maintaining session continuity
  3. Silent operation: Minimizes UI clutter and maintains focus on conversation
  4. Minimal code footprint: Only 83 lines for complete functionality
  5. Independent operation: Works alongside existing save/load features without conflicts

Backward Compatibility

  • No breaking changes
  • Existing save/load functionality unchanged
  • New settings are optional

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

- Add chat.enableAutoSave and chat.autoSavePath settings
- Implement AutoSaveManager for session-based auto-saving
- Auto-save triggers after AI response completion
- Silent error handling to avoid interrupting conversations
- Opt-in by default (disabled)

Closes aws#3322
@NB3025 NB3025 force-pushed the feature/auto-save branch from 783eb17 to 95b5a29 Compare November 1, 2025 13:40
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