Skip to content

bug: prevent thread message-store #8019

@enjoyandlove

Description

@enjoyandlove

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

  1. Create a thread with multiple messages.
  2. Trigger modify_message or delete_message for that thread.
  3. Force-close/kill app process during rewrite window.
  4. Re-open app and load the thread.
  5. Observe message loading failure for the whole thread.

Operating System

  • MacOS
  • Windows
  • Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No fields configured for Bug.

    Projects

    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions