Skip to content

feat(desktop,mobile): a conversation delete takes its child sessions - #866

Merged
huichen merged 2 commits into
mainfrom
feat/delete-cascade-children
Sep 26, 2026
Merged

huichen merged 2 commits into
mainfrom
feat/delete-cascade-children

Conversation

@huichen

@huichen huichen commented Sep 26, 2026

Copy link
Copy Markdown
Collaborator

Deleting a parent conversation left its children behind: each child re-rooted in
the sidebar as a conversation whose lineage pointed at a session the user had
just removed. Deleting a conversation from the desktop GUI or the phone now
takes its descendants with it, recursively, including each child's temporary
chat workspace.

Store

  • store::delete_thread_tree deletes a thread and every descendant it parents in
    one transaction: each removed thread's Agent session is tombstoned, each
    chat-mode thread's temporary workspace is flagged for cleanup (and its
    directory removed when delete_files is set, exactly like the root's).
  • The lineage walk is keyed by Agent session id (parent_session_id holds the
    parent's session id, not its thread id) via a recursive UNION CTE, so a
    malformed cycle terminates instead of recursing forever, and archived /
    legacy soft-deleted children are not left behind as rows.
  • store::delete_thread keeps its single-thread meaning on purpose: the orphan
    sweep and the reaction to a session deleted outside the GUI (TUI/CLI) must not
    take live children with them — a child is a projection of its own Agent
    session and keeps working. docs/internals/desktop/ER.md now says which path
    cascades and which does not.

Desktop

  • The delete path resolves store::thread_delete_closure before touching
    anything, so every removed thread's shells close and every active run stops
    before the rows go (a busy child cancels the delete, exactly like a busy root).
  • The batch command no longer reports a selected child of a selected parent as a
    failed deletion (the parent's cascade already removed it).

Mobile

  • The desktop's delete_session reply is idempotent: already gone is success.
    The phone walks a selection one session at a time, so with a cascade that
    sequence naturally contains a child the parent already removed.
  • The phone's catalogue drops the deleted session's local subtree (pinned
    children included — a pin moves a child in the list, not in the lineage) and
    closes the conversation when the selected session was one of them.

Tests

  • store: descendants (child, grandchild, pinned child) removed and each session
    tombstoned, unrelated thread kept; the single-thread delete keeps the child and
    its lineage; each chat workspace directory removed; a lineage cycle terminates.
  • commands: GUI delete cascades; a batch containing parent + child reports no
    failure; the remote delete_session reply is idempotent on a repeat.
  • mobile: deleteSession drops the subtree and closes a selected descendant.

Local checks (Windows): cargo fmt --check clean; desktop cargo test 1291
passed with the same 4 pre-existing platform failures seen on a pristine tree
(\\?\ canonicalization, ~ expansion, POSIX shell) plus one flaky
timing test that passes in isolation; clippy reports nothing outside the
pre-existing Windows-only dead-code items in src/terminal. Mobile: tsc --noEmit and eslint clean, src/remote 50 suites / 1115 tests pass.

Deleting a parent conversation left its children behind, re-rooted in the
sidebar with a lineage pointing at a session the user had just removed.
Desktop and phone deletes are now recursive.

- `store::delete_thread_tree` deletes a thread and every descendant it
  parents in one transaction (tombstoning each removed thread's Agent
  session, flagging each chat thread's temporary workspace, and removing
  those directories when `delete_files`). The lineage is walked by Agent
  session id (`parent_session_id`) with a recursive `UNION` CTE, so a
  malformed cycle terminates instead of recursing forever.
- `store::delete_thread` keeps its single-thread meaning: the orphan sweep
  and the reaction to a session deleted outside the GUI must not take live
  children with them - a child is a projection of its own Agent session.
- The desktop delete path resolves `store::thread_delete_closure` first, so
  every removed thread's shells close and its active run stops before the
  rows go. The batch command no longer reports a selected child of a
  selected parent as a failed deletion.
- The phone's `delete_session` reply is idempotent (already gone is
  success), because the phone walks a selection one session at a time.
- Mobile drops the deleted session's local subtree (pinned children
  included) and closes the conversation when the selection was one of them.

Docs: PRODUCT/ER now state that a user delete is recursive and which paths
are not.
@huichen
huichen enabled auto-merge (squash) September 26, 2026 05:20
@huichen
huichen merged commit 0229791 into main Sep 26, 2026
12 checks passed
@huichen
huichen deleted the feat/delete-cascade-children branch September 26, 2026 05:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant