Repository navigation
Description
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_backreturns 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:
- Derive it in the read model.
projectLinkedSessionTreealready detects the missing parent. Route those sessions into the archived projection instead ofroots. No writes, no deletion-path fan-out, and it retroactively covers orphans that already exist in users' data. - 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
- Cascading deletion.
- Changing child-session runtime, storage, or permission semantics.
- The navigation work in feat(desktop): surface linked child sessions in the session workbar #1457.
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.
Activity
feat(desktop): warn that deleting a parent keeps and archives its sub…
feat(desktop): warn that deleting a parent keeps and archives its sub…
feat(desktop): warn that deleting a parent keeps and archives its sub…
feat(desktop): warn that deleting a parent keeps and archives its sub…
feat(desktop): warn that deleting a parent keeps and archives its sub…
feat(desktop): warn that deleting a parent keeps and archives its sub…
feat(desktop): warn that deleting a parent keeps and archives its sub…
feat(desktop): warn that deleting a parent keeps and archives its sub…
feat(desktop): warn that deleting a parent keeps and archives its sub…
feat(desktop): warn that deleting a parent keeps and archives its sub…
feat(desktop): warn that deleting a parent keeps and archives its sub…
feat(desktop): warn that deleting a parent keeps and archives its sub…
feat(desktop): warn that deleting a parent keeps and archives its sub…
feat(desktop): warn that deleting a parent keeps and archives its sub…
feat(desktop): warn that deleting a parent keeps and archives its sub…