Skip to content

fix(desktop): archive child sessions whose parent was deleted #1467

Closed

Description

@Astro-Han

Summary

When a parent session is deleted, its linked children currently surface as ordinary top-level rows. Deleting one large-swarm parent can drop up to 32 headless rows into the conversation list. They should be treated as archived instead.

Split out of #1457, which covers navigation presentation. This one changes what deletion means for a child, so it is reviewed separately.

Current behaviour

Session deletion cascades over the revision family only (app-shell-session-row-actions.ts:119-120); linked children are untouched. projectLinkedSessionTree then hits its missing-parent branch (packages/core/src/session.ts:430), the child never enters childrenByParentId, and it falls through into roots — a plain top-level row.

That fail-open behaviour is deliberate (#1400: "Keep orphaned or cyclic relations visible as roots") and the intent is right: a child must never become unreachable. The problem is only that "reachable" is currently implemented as "in the main list".

Why not cascade delete

  • Session deletion is permanent and tombstoned against reuse, so the id cannot be rewritten afterwards (session-metadata-transfer.ts:65, sqlite-session-metadata-store.ts:159, :177).
  • A child owns its own artifacts, stored under ${sessionId}/${id}-${name} (artifact-store.ts:65). Cascading would destroy files the parent never held.
  • write_back returns only a summary or a patch to the parent; the child's full transcript and outputs live with the child.

A child is an independent record with its own outputs, not a fragment of the parent. Irreversibly destroying it as a side effect of deleting the parent is the wrong default.

Proposal

Treat a child whose parent no longer exists as archived: absent from the main conversation list, present in the archive view, labelled so it reads as an orphan rather than an ordinary conversation. A user who genuinely wants it gone deletes it from there.

Two implementations, preferred first:

  1. Derive it in the read model. projectLinkedSessionTree already detects the missing parent. Route those sessions into the archived projection instead of roots. No writes, no deletion-path fan-out, and it retroactively covers orphans that already exist in users' data.
  2. Persist it on delete. Walk the children when the parent is deleted and set isArchived. Explicit and inspectable in storage, but it adds a batch write to the delete path and leaves pre-existing orphans untouched.

Open question for (1): archived state becomes partly derived and partly persisted, so the projection has to present a single answer. Also, a derived orphan cannot be un-archived — acceptable for an abnormal state, but worth stating deliberately.

Non-goals

Validation

  • Delete a parent with one child, then with a 32-item swarm: the main list gains no rows, the archive view gains the children.
  • Cyclic lineage still fails open and stays inspectable.
  • An orphan created before this change is handled the same way as one created after.

References

Activity

  1. self-assigned this
    on Jul 25, 2026
  2. removed their assignment
    on Aug 17, 2026
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