Describe the Bug
Editing or deleting a message can corrupt a thread's messages.jsonl when the app/process is interrupted mid-write.
Current flow rewrites the entire file using truncate-first semantics. If interruption happens between truncate and full rewrite completion, the file can end up partially written. On next read, one malformed/truncated line causes full read failure for that thread.
This is a critical stability issue because it can make existing chat threads unreadable after a crash/power loss/forced close during normal operations (modify_message / delete_message).
Steps to Reproduce
- Create a thread with multiple messages.
- Trigger
modify_message or delete_message for that thread.
- Force-close/kill app process during rewrite window.
- Re-open app and load the thread.
- Observe message loading failure for the whole thread.
Operating System
Describe the Bug
Editing or deleting a message can corrupt a thread's
messages.jsonlwhen the app/process is interrupted mid-write.Current flow rewrites the entire file using truncate-first semantics. If interruption happens between truncate and full rewrite completion, the file can end up partially written. On next read, one malformed/truncated line causes full read failure for that thread.
This is a critical stability issue because it can make existing chat threads unreadable after a crash/power loss/forced close during normal operations (
modify_message/delete_message).Steps to Reproduce
modify_messageordelete_messagefor that thread.Operating System