Skip to content

Support multi-PR reviews per worker session #395

Description

@neversettle17-101

Summary

Extend AO reviews so one worker session can have multiple PRs reviewed by a single shared reviewer terminal. Keep review session-level because it represents the reviewer terminal/handle for the worker session. Store PR-specific review state in review_run.

Split the work into two PRs:

  1. Backend/storage/API/CLI support for multi-PR review execution.
  2. Frontend UI for showing eligible and up-to-date PR review state.

PR 1: Backend Multi-PR Review Support

  • Keep review as one row per worker session:
    • session_id remains unique.
    • reviewer_handle_id remains the single reviewer terminal handle.
    • review.pr_url should no longer drive behavior; leave it as legacy/deprecated or stop updating it.
  • Make review_run the PR-scoped record:
    • Always persist pr_url.
    • Add a migration replacing uniqueness with (session_id, pr_url, target_sha) where target_sha != "" AND status != "failed".
    • Rename store lookup from session/SHA to session/PR/SHA.
  • Add a pure planner in backend/internal/review:
    • Output per-PR items with prUrl, prNumber, targetSha, status, latestRun.
    • Status values: needs_review, running, up_to_date, changes_requested, ineligible.
    • Eligible PRs are open, non-draft, and not already AO-approved for the current pr_url + head_sha.
  • Update trigger flow:
    • Trigger(sessionID) evaluates all worker PRs.
    • Create runs for needs_review and current-head changes_requested.
    • Reuse/skip running and up_to_date.
    • Spawn one reviewer terminal if needed, then send one review task per created run to that same terminal.
    • Return batch results with reviewer handle, items, and created runs.
  • Update submit flow:
    • Keep ao review submit --session --run ....
    • runID identifies the PR through stored review_run.pr_url.
    • Worker changes-requested messages include the PR URL and GitHub review id.
  • Add API fields in an additive way:
    • ListReviewsResponse.items.
    • TriggerReviewResponse.items.
    • TriggerReviewResponse.createdReviews.
    • Keep reviewerHandleId and reviews history for compatibility.
  • Regenerate OpenAPI and frontend schema with npm run api.

PR 2: Reviews UI

  • Update the Reviews tab to consume items.
  • Show PR review rows/cards with status:
    • needs_review
    • running
    • changes_requested
    • up_to_date
    • optionally muted ineligible
  • Use one session-level action: Run needed reviews.
  • Keep one Open terminal action for the shared reviewer terminal.
  • Do not create terminal controls per PR.

Test Plan

  • Planner table tests for open, draft, merged, closed, approved-current-SHA, changes-requested-current-SHA, running-current-SHA, different SHA.
  • Trigger creates multiple runs for multiple eligible PRs.
  • Two PRs with the same head SHA do not collide.
  • Approved current-head PR is skipped.
  • Running current-head PR is reused.
  • Failed current-head PR is retryable.
  • Only one reviewer terminal is spawned per worker session.
  • Submit includes PR URL in changes-requested worker notification.
  • Storage test verifies unique index is (session_id, pr_url, target_sha).
  • API tests verify items and batch trigger response.
  • PR 2 frontend tests verify eligible/up-to-date display and one shared terminal.

Assumptions

  • AO approval means a completed AO review_run with verdict=approved for the current pr_url + head_sha.
  • External GitHub approval does not skip AO review unless explicitly added later.
  • Draft, merged, and closed PRs are ineligible in v1.

Metadata

Metadata

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions