[QUALITY-768] Fix orchestration session restoration after Warp restart
Description
This PR fixes several issues in orchestration session restoration that have been present since orchestration was introduced. Restarting Warp could surface child agents as "Unknown agent" in the orchestration pill bar, silently drop roughly half of persisted child conversations, leave restored remote-child panes showing a blank "New conversation" placeholder, and split orchestration trees on disk over time.
Eager hydration of orchestration children at startup. Restored child conversations were inserted into BlocklistAIHistoryModel::conversations_by_id only when the parent's fullscreen agent view was re-entered. Until then, the pill bar, transcript name resolver, and orchestration topology indexes couldn't find the child by id. initialize_historical_conversations now eagerly hydrates orchestration children into conversations_by_id alongside the existing topology indexes so downstream consumers find the conversation before pane materialization.
Direct AmbientAgentTask inspection for remote-child hydration. Loading the cloud transcript onto a restored remote-child placeholder used AgentConversationsModel::resolve_open_action, which returns "navigate to local" intent once the local placeholder is in conversations_by_id, preventing the transcript from ever being loaded. resolve_open_action is a navigation router shared with the conversation list UI and collapses both intents into the same variant once a local row exists; threading a new intent through it would widen every caller for a code path only the hydration cares about. The hydration path now inspects the AmbientAgentTask's active_live_session_state and conversation_id directly. The dispatch is extracted into a pure decide_remote_child_hydration_action returning a RemoteChildHydrationAction enum (live-attach, load-transcript, or fallback) for testability, and the post-merge tombstone is gated on whether the task is in a terminal state so still-running runs don't render as ended.
Optimistic-stub filter in the persistence restore path. Local-no-harness Oz child conversations persist both a 38-byte placeholder root task (assigned at conversation-creation time before the server-issued task id arrives) and the real upgraded root task. AgentConversation::is_restorable previously rejected such rows because they have two root-shaped tasks. The persistence layer now detects the exact "two root-shaped tasks, exactly one with zero messages" shape and excludes the placeholder from the restorability check and from the conversation reconstructed from disk. Disk rows are untouched.
Tree-aware persisted-conversation prune + retention bump. upsert_agent_conversation pruned the oldest individual rows when the persisted-conversation count exceeded its ceiling, evicting parents and children of the same orchestration session independently and leaving split trees on disk. The prune is now tree-aware: orchestration trees are treated as atomic units, sorted by max(member.last_modified_at), and kept greedily. The freshest tree is always retained in full even if it alone exceeds the ceiling. The ceiling is raised from 100 to 200 (alongside the in-memory cap) since orchestration sessions routinely produce 5–20 conversations.
A post-facto technical spec describing these changes as implemented lives at specs/QUALITY-768/TECH.md.
Testing
- [x] I have manually tested my changes locally with
./script/run
Manual validation: local-local restart shows correct agent names in the pill bar; local-remote restart shows the cloud transcript instead of a blank placeholder; prune keeps orchestration trees together on disk under the new ceiling; baseline single-conversation restore unchanged.
Automated coverage added:
- 5 unit tests in
app/src/pane_group/mod_tests.rsfordecide_remote_child_hydration_action(live-attach, load-transcript, fallback, ActiveUnattachable variant, empty-token). - 7 unit tests in
crates/persistence/src/model.rsfor the optimistic-stub filter. - 8 unit tests in
app/src/persistence/agent.rsforselect_conversations_to_evict. - 1 integration test in
app/src/ai/blocklist/history_model_tests.rs(merge_cloud_tasks_into_existing_conversation_preserves_placeholder_identity) exercising the load-transcript → merge seam end-to-end.
cargo fmt, cargo clippy --all-targets --features local_fs -- -D warnings, and cargo nextest run across the affected crates all pass.
Agent Mode
- [x] Warp Agent Mode - This PR was created via Warp's AI Agent Mode
CHANGELOG-BUG-FIX: Fixed orchestration session restoration so the pill bar, child transcript name resolution, and restored remote-child cloud transcripts all work correctly after a Warp restart.
@cephalonaut
I'm starting a first review of this pull request.
You can view the conversation on Warp.
I completed the review and no human review was requested for this pull request.
Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).
Powered by Oz