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:
- 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.
- 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:
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
HistoryManagerto be more robust by implementing an auto-save feature and a daily archiving system.Implementation Details:
hotkey_manager.py, after a successful LLM response, ensure thehistory_manager.save_history()method is called immediately after adding the new user and assistant turns to the history deque.history_manager.py, create a new functionarchive_history_if_needed().main.py).chat_history.json.a. Create an
archivesub-directory in theAppData/Blinkfolder if it doesn't exist.b. Copy the current
chat_history.jsoninto thearchivefolder, renaming it with the previous day's date (e.g.,chat_history-YYYY-MM-DD.json).Acceptance Criteria:
chat_history.jsonfile on disk is immediately updated.archivefolder.