Skip to content

Order orchestration pills by status (attention first, done by recency)#11363

Open
advait-m wants to merge 3 commits into
masterfrom
advait/orchestration-pill-status-ordering
Open

Order orchestration pills by status (attention first, done by recency)#11363
advait-m wants to merge 3 commits into
masterfrom
advait/orchestration-pill-status-ordering

Conversation

@advait-m
Copy link
Copy Markdown
Member

@advait-m advait-m commented May 19, 2026

Loom: https://www.loom.com/share/e011f21848864c4282c699fa426780a4
Fixes https://linear.app/warpdotdev/issue/QUALITY-739/move-done-agents-to-the-end-of-pill-bar

Description

The orchestration pill bar should surface attention-needing agents and push inert agents out of the way, rather than rendering everything in spawn order.

This PR sorts both the pinned and unpinned sections of the pill bar by a status-priority key. The orchestrator pill is still first, the pinned/unpinned divider still appears between the two sections — only the order within each section changes.

Ordering rules

Lower = closer to the start of each section (= more important to the user):

  1. Blocked — waiting on the user, highest urgency
  2. Error — needs the user to look
  3. InProgress — running
  4. Done (Cancelled + Success combined into a single bucket)

Within the non-done buckets the tiebreaker is spawn order, so freshly-spawned siblings stay where they were and don't shuffle while they run.

Within the done bucket the tiebreaker is recency: the most recently finished agent renders leftmost (based on the conversation's last_modified_at — latest exchange's finish_time). Pills with no known finish time sort to the trailing edge of the done section. Cancelled and Success share the same bucket key on purpose — once an agent is done, the only signal that matters for ordering is how recently it finished, not how it finished.

Why these specific rules

  • Blocked > Error — pills that explicitly need user input outrank pills that merely need attention.
  • Done bucket merged + sorted by recency — a 5-minute-old Cancelled should sink behind a fresh Success. The user wants "left = more important", which for completed agents maps to "most recently active".
  • Re-sort on every render — the pill bar already re-renders on BlocklistAIHistoryEvent::UpdatedConversationStatus, so status transitions (Blocked → InProgress when permission is granted, InProgress → Success when an agent finishes) reflect in the bar immediately. No extra plumbing needed.
  • Pinned section uses the same sort — kept consistent with the unpinned section so users see the same ordering principle everywhere; pinned still wins the section-level ordering.

Implementation

  • New pill_status_sort_key(Option<&ConversationStatus>) -> u8 helper (Blocked=0, Error=1, InProgress=2, Done=3).
  • New pill_done_recency_key(Option<i64>) -> i64 helper that returns the negation of the last-modified epoch-ms so larger timestamps (newer) sort first; missing timestamps sort last.
  • PillSpec gains a last_modified_ms: Option<i64> field, populated via AIConversation::last_modified_at().
  • Render loop now collects (status_key, secondary_key, spawn_index, Box<dyn Element>) tuples per bucket and sort_by_keys each independently. secondary_key is the recency key for done pills and 0 everywhere else, so spawn order is the natural tiebreaker outside the done bucket.

Testing

Five unit tests in orchestration_pill_bar_tests.rs:

  • pill_status_sort_key_orders_attention_then_in_progress_then_done — Blocked < Error < InProgress < Done, with Cancelled == Success.
  • pill_status_sort_key_treats_none_as_in_progress — orchestrator's None status safety default.
  • pill_done_recency_key_puts_most_recent_first_and_unknown_last — direction of the recency key + None handling.
  • sort_pills_bubbles_attention_in_progress_keeps_spawn_done_uses_recency — end-to-end mixed-status sort with recency tiebreaking inside done.
  • sort_pills_is_stable_within_in_progress_bucket — InProgress pills keep spawn order regardless of input order.
  • sort_pills_done_bucket_orders_by_recency_regardless_of_completion_type — an old Cancelled sinks behind a fresh Success.

Sorts both the pinned and unpinned sections of the orchestration pill
bar by a status-priority key so attention-needing agents bubble to the
start and finished agents sink to the end. Within the trailing 'done'
section (Cancelled + Success share one bucket), the tiebreaker is the
conversation's most-recent activity timestamp so the freshest finish
renders leftmost.

Co-Authored-By: Oz <oz-agent@warp.dev>
@cla-bot cla-bot Bot added the cla-signed label May 19, 2026
advait-m and others added 2 commits May 19, 2026 16:26
Co-Authored-By: Oz <oz-agent@warp.dev>
- Pull DONE_STATUS_KEY into a named const so render code and tests
  share one source of truth.
- Factor pill_secondary_sort_key so the render loop and tests use the
  same helper instead of parallel implementations.
- saturating_neg for the recency key so an unrealistic i64::MIN
  timestamp can't panic.
- Restore the per-field unused-orchestrator comments.
- Add the missing blank line below pill_done_recency_key.
- Use (.., pill) tuple destructure in the row push loops.

Co-Authored-By: Oz <oz-agent@warp.dev>
@advait-m advait-m marked this pull request as ready for review May 20, 2026 20:50
@oz-for-oss
Copy link
Copy Markdown
Contributor

oz-for-oss Bot commented May 20, 2026

@advait-m

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

Copy link
Copy Markdown
Contributor

@oz-for-oss oz-for-oss Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overview

This PR updates the orchestration pill bar to sort pinned and unpinned child pills by attention state first and by completion recency inside the done bucket, while preserving the orchestrator-first and pinned-divider layout. The implementation adds focused sort-key helpers, carries last-modified timestamps into pill specs, and covers the intended ordering rules with unit tests.

Concerns

  • No blocking correctness, security, or spec-alignment concerns found.

Verdict

Found: 0 critical, 0 important, 0 suggestions

Approve

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

@advait-m advait-m requested a review from cephalonaut May 20, 2026 22:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant