feat(staged): pass agent preference to autoreviews and validate on adoption#639
feat(staged): pass agent preference to autoreviews and validate on adoption#639
Conversation
…option Autoreviews now use the committing session's agent provider instead of always defaulting to None, and tryAdoptAutoReview checks that the autoreview's agent matches the user's current preference before adopting. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Project-level agent tracking was broken, so simplify to use only the global last-used agent preference everywhere. Removes setProjectAiAgent, getPreferredAgentForProject, projectAgents state, and the projectId prop from AgentSelector. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…inate double-fetch Expand resolve_session_status() to return the session provider as a fourth tuple element, removing the redundant get_session() call in the reviews timeline builder that previously fetched the session twice. Also simplify the agent comparison in tryAdoptAutoReview by removing the redundant `?? null` coercion — both sides are already `string | null`, so strict equality handles the null match correctly. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…truct Address code review feedback from fbb77e6: - Replace the unwieldy 4-tuple (Option<String>, Option<String>, Option<String>, Option<String>) returned by resolve_session_status() with a self-documenting ResolvedSession struct, making each field's purpose clear at all 6 call sites in timeline.rs. - Eliminate the extra getSession IPC round-trip in tryAdoptAutoReview() by looking up the review's sessionProvider from the already-fetched timeline data instead of making a redundant backend call. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cf7096cb17
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| const timelineReview = this.getTimeline()?.reviews.find((r) => r.id === review.id); | ||
| const reviewProvider = timelineReview?.sessionProvider ?? null; | ||
| if (preferredAgent !== reviewProvider) { |
There was a problem hiding this comment.
Resolve auto-review provider from source of truth
This provider check reads from this.getTimeline()?.reviews instead of the freshly fetched review/session, but BranchCard intentionally does not call loadTimeline() for isAutoReview running events, so the timeline is often stale when adoption is attempted. In that common path, timelineReview is missing, reviewProvider becomes null, and adoption is incorrectly skipped even when the auto-review was generated with the preferred agent, which then triggers an unnecessary new review run.
Useful? React with 👍 / 👎.
…f stale timeline The timeline is intentionally not refreshed during auto-review lifecycle events, so the previous timeline-based provider lookup always resolved to null—causing adoption to be skipped whenever the user had an agent selected. Fix by fetching the session's provider in the backend find_fresh_auto_review query and returning it on the Review payload, removing the stale-timeline dependency entirely. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ssion lookup Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
(session_id, status, completion_reason)tuple with aResolvedSessionstruct and include the provider fieldsetProjectAiAgent,getPreferredAgentForProject) in favor of the single global preferenceTest plan
🤖 Generated with Claude Code