Skip to content

[Feature] Implement Persistent Chat History with Auto-Save and Daily Archives #2

@JStaRFilms

Description

@JStaRFilms

Description:

Problem:
The current chat history is only saved when the application is cleanly quit. If the app crashes or the system shuts down unexpectedly, all history from the current session is lost. Furthermore, there is no backup mechanism.

Proposed Solution:
Refactor the HistoryManager to be more robust by implementing an auto-save feature and a daily archiving system.

Implementation Details:

  1. Auto-Save:
    • In hotkey_manager.py, after a successful LLM response, ensure the history_manager.save_history() method is called immediately after adding the new user and assistant turns to the history deque.
  2. Daily Archiving:
    • In history_manager.py, create a new function archive_history_if_needed().
    • This function should be called once on application startup (main.py).
    • It will check the "last modified" timestamp of chat_history.json.
    • If the date of the timestamp is before the current date, it will:
      a. Create an archive sub-directory in the AppData/Blink folder if it doesn't exist.
      b. Copy the current chat_history.json into the archive folder, renaming it with the previous day's date (e.g., chat_history-YYYY-MM-DD.json).

Acceptance Criteria:

  • After each query, the chat_history.json file on disk is immediately updated.
  • If the app is force-closed via Task Manager, the conversation history up to the last query is preserved on restart.
  • When the app is launched for the first time on a new day, it creates a dated backup of the previous day's history in an archive folder.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions