Repository navigation
feat(daemon): cascade archive/delete onto subagents - #568
Merged
Merged
Conversation
Archiving or deleting a session left its subagents behind as orphaned
rows pointing at a parent that no longer existed — list clutter, held
worktrees/adapters, and dangling @{session:<id>} refs with no owner to
collect them.
SessionManager::archive and ::delete now sweep the session's child
subagents (matched by parent_session_id + SessionKind::Subagent),
recursing through each child's own archive/delete so nested subagents
follow. A failure on one child is logged and never aborts the rest or
the parent's removal. This routes through the daemon's single
archive/delete entry points, so every client surface (TUI, CLI, MCP)
and subagent-scoped removal inherits the cascade.
Adds spec 0052 and cross-references it from 0047.
edwin-zvs
added a commit
that referenced
this pull request
Jun 29, 2026
…053, break pending_block_signatures compat main advanced with #569 (keep run shimmer alive past owning-session idle), which reworked the same shimmer lifecycle and added agent_managed to ProgramRunProgress, plus #563/#568 (specs 0051 custom-templates, 0052 session-removal-cascades). Reconcile: - protocol: keep pending_block_ids rename + the declared-shimmer types alongside #569's agent_managed field; DROP the pending_block_signatures serde alias (clean break, per request) and remove the legacy-compat test. - daemon: fold #569's agent_managed + inactivity-backstop refresh into the declaration-based narrow_program_run and set_program_run_pending so a complete/partial declaration also marks the run agent-managed; #569's AwaitingInput/terminal stop-signal split is preserved. Adapt #569's two lifecycle tests to the id-based API. - specs 0042/0048: combine #569's stop-signal model with the declared per-block-id model; my new spec collides with main's 0051/0052, renumbered to specs/0053-program-shimmer-block-addressing and all references updated. cargo test --workspace green.
This was referenced Jun 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Archiving or deleting a session now cascades onto the subagents it owns: archive archives them, delete deletes them, recursively down the ownership tree.
Previously neither operation touched subagents — they were left as orphaned rows pointing at a parent that no longer existed (list clutter, held worktrees/adapters, dangling
@{session:<id>}refs with no owner to collect them). The only existing cascade was the optionaldelete_membersflag on group delete; the tighter parent/subagent bond had nothing.How
SessionManager::child_subagent_ids(parent)collects direct children matched byparent_session_idandSessionKind::Subagent(so an unrelated top-level session is never swept).SessionManager::archiveand::deletesnapshot their child subagents, do their existing work, then cascade viaBox::pin(self.archive/delete(child))— recursing through each child's own removal so nested subagents follow. A failure on one child is logged and never aborts the siblings or the parent.construct_subagent_archive/construct_subagent_delete).Behavior matrix
delete(parent)archive(parent)Archive's reversibility guarantee extends through the cascade: cascade-archived subagents keep transcript + worktree and can be restarted.
Tests
delete_cascades_to_subagents— parent + two subagents + a nested subagent all deleted; an unrelated user session survives.archive_cascades_to_subagents— parent + nested subagent archived recursively; a subagent owned by a different parent is untouched.archive_marks_terminal_and_keeps_session/archive_and_delete_return_quickly_without_blocking_callerstill pass.Full
session::module: 46 passed. Clippy clean on the changed region.Spec
Adds
specs/0052-session-removal-cascades-to-subagents.mdand cross-references it from0047-archive-vs-delete-session-lifecycle.md.Notes for reviewer
Daemon-only logic, no user-visible render surface → no recording (per AGENTS.md judgment call). The change lives entirely in
crates/daemon→ relevant binary isconstruct(the daemon is served by the sameconstructbinary viaconstruct daemon run).