Skip to content

[Bug]: Deleting a thread deletes the attachments its forks still show #30017

Description

@Entrpi

What happens

A fork shows its source's earlier turns by reading them from the source thread. When the source is deleted, the server queues an attachment.cleanup for every attachment in the source's messages, and the files are removed. The fork's inherited turns then show broken images and files.

Steps to reproduce (main cefb544af3)

  1. Send a prompt with an image attached (any provider that accepts images).
  2. Fork the thread from the reply.
  3. Delete the original thread.
  4. Open the fork. The inherited prompt's image no longer loads, and its file is gone from userdata/attachments.

Expected

Deleting a thread leaves the fork's history intact, including its attachments. The files go when the last thread that can show them is deleted.

Where

planThreadDeletion (apps/server/src/orchestration-v2/ThreadDeletion.ts) gets its ids from getThreadAttachmentIds, which lists the deleted thread's own files without checking for live forks that read through it. Project delete (ProjectService.ts) uses the same read.

I have a fix with a failing-first test, proven on web and Android. I can open a PR if you want one.

Activity

  1. changed the title [-]Deleting a thread deletes the attachments its forks still show[/-] [+][Bug]: Deleting a thread deletes the attachments its forks still show[/+] on Nov 3, 2026
  2. Entrpi commented on Nov 3, 2026

    @Entrpi
    ContributorAuthor

    The fix is on our fork as one commit on top of main (cefb544): 8ee2934 (compare).

    It includes the failing test in ThreadFork.execution.test.ts, which fails on main for this reason. Happy to open it as a PR if you want it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions