Shut down resumed descendants when archiving thread trees (#40179)

## Why

Collaboration can resume an archived descendant without unarchiving its
rollout. Archiving the parent again previously skipped shutdown for that
descendant because only rollouts newly marked as archived were prepared.

## What changed

Prepare every loaded thread in the spawn subtree for archival, including
descendants whose rollouts are already archived, before updating archive
state.

## Testing

Add an app-server integration test that resumes an archived child through its
parent and verifies that archiving the parent unloads the entire subtree.

GitOrigin-RevId: aca8c0d6ddb8900aad16becbeb594426cea1e3a6
This commit is contained in:
Owen Lin
2026-08-23 03:25:56 +00:00
committed by copyberry
parent 546eed94ac
commit a1d4aea265
2 changed files with 182 additions and 2 deletions
@@ -1644,8 +1644,10 @@ impl ThreadRequestProcessor {
}
archive_thread_ids[1..].reverse();
for &thread_id_to_archive in &archive_thread_ids {
self.prepare_thread_for_archive(thread_id_to_archive).await;
// Collaboration may resume an archived descendant without unarchiving it.
self.prepare_thread_for_archive(thread_id).await;
for &descendant_thread_id in subtree_thread_ids.iter().skip(1).rev() {
self.prepare_thread_for_archive(descendant_thread_id).await;
}
let archived_thread_ids = self