Skip to content

feat(server): archive and unarchive cascade to subagent threads - #18668

Closed
florin-szilagyi wants to merge 2 commits into
pingdotgg:mainfrom
florin-szilagyi:archive-subagent-descendants
Closed

florin-szilagyi wants to merge 2 commits into
pingdotgg:mainfrom
florin-szilagyi:archive-subagent-descendants

Conversation

@florin-szilagyi

@florin-szilagyi florin-szilagyi commented Oct 12, 2026 •

Copy link
Copy Markdown

feat(server): archive and unarchive cascade to subagent threads

Discussion: #18656

Problem

Archiving a thread leaves its subagent threads behind in the active list. They render as orphaned flat rows. The undo toast unarchives only the parent, so they stay buried.

What changed

ThreadManagementService.dispatch now cascades thread.archive and thread.unarchive: the command dispatches to every transitive subagent descendant first, parent before child, and to the target last. A descendant failure aborts the operation before the target is touched. Forks are not touched.

Descendant commands derive their command id from the input one (<commandId>:<threadId>), because the orchestrator replays receipts by command id and a shared id would collide.

The cascade lives in dispatch because every client transport routes through it (the websocket handler goes via ThreadMessageIntake.dispatchCommand). A higher-level service would only cover the callers that remember to use it.

The legacy sidebar's multi-select archive skips entries whose subagent ancestor is also selected, since the cascade already covers them. Without this, the redundant child dispatch fails as "already archived" and aborts the batch.

One deliberate trade-off: unarchiving a parent also restores subagent threads the user archived individually.

Testing

  • ./node_modules/.bin/vp test run apps/server/src/orchestration-v2/ThreadManagementService.test.ts apps/server/src/orchestration-v2/ThreadLifecycleService.test.ts apps/web/src/components/Sidebar.logic.test.ts: 192 passed. Covers cascade order for archive and unarchive (including a subagent grandchild, a fork, and an unrelated thread that must not be dispatched), abort on descendant failure, and the multi-select dedupe.
  • pnpm run typecheck in apps/server and apps/web: no errors.

Built and tested with Claude Code (GLM 5.3 Flash and Kimi K3).

@github-actions github-actions Bot added vouch:unvouched Author is not yet trusted in the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Oct 12, 2026
The cascade lived in ThreadLifecycleService, which no client transport
calls: the websocket handler routes commands through ThreadMessageIntake
into ThreadManagementService.dispatch, so archiving from any client
archived only the target thread.

Move the cascade into ThreadManagementService.dispatch. Archive and
unarchive commands now dispatch to transitive subagent descendants first
(parent before child, derived command ids) and to the target last. The
legacy sidebar's multi-select skips entries a selected ancestor's cascade
already covers, so a hand-selected parent+child batch no longer fails on
the child's redundant dispatch.
@github-actions github-actions Bot added size:L 100-499 changed lines (additions + deletions). and removed size:M 30-99 changed lines (additions + deletions). labels Oct 13, 2026
@t3dotgg

t3dotgg commented Oct 14, 2026

Copy link
Copy Markdown
Member

Note

🤖 Claude Opus 5.5 responding on behalf of Theo

Closing because this PR states that GLM and Kimi wrote code in it:

Built and tested with Claude Code (GLM 5.3 Flash and Kimi K3).

We do not accept code written by GLM, Kimi, MiniMax, Mistral, Gemini, or alpha models, or by Muse models other than Muse Wonder Full. See Models we do not accept.

To have this considered again, open a new PR with the code written by a different model and link this one.

@t3dotgg t3dotgg closed this Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:unvouched Author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants