Skip to content

fix(review,modes): retain resolved model and defer picker until user responds#71

Merged
vegardx merged 4 commits intomainfrom
fix/defer-picker-until-user-responds
May 8, 2026
Merged

fix(review,modes): retain resolved model and defer picker until user responds#71
vegardx merged 4 commits intomainfrom
fix/defer-picker-until-user-responds

Conversation

@vegardx
Copy link
Copy Markdown
Owner

@vegardx vegardx commented May 7, 2026

Fixes two issues in the auto-review post-execution flow:

  1. Registry re-lookup race — The orchestrator phase called ctx.modelRegistry.find() after resolveTierModel had already resolved the model. Custom providers that re-register their model list asynchronously (e.g. radicalai gateway refresh) could cause the second lookup to fail. Now retains the Model<Api> reference from initial resolution and passes it directly.

  2. Picker pops before user responds — The post-exec picker appeared immediately after the agent presented discussion findings, before the user could address them. Adds an "awaiting-discussion" phase that holds the picker until a user-initiated turn completes.

Other changes:

  • Removed duplicated provider/modelId fields from ResolvedTierModel (derive from model.provider/model.id)
  • Suppressed redundant /review offers in the picker and /commit when auto-review already ran
  • npm audit fix for transitive dependency vulnerabilities

vegardx added 4 commits May 7, 2026 22:37
The orchestrator phase re-did ctx.modelRegistry.find() after
resolveTierModel had already resolved the model. Custom providers that
re-register their model list asynchronously (e.g. radicalai gateway
refresh) could cause the second lookup to fail. Retain the Model<Api>
reference from initial resolution instead.
Removes provider/modelId strings that duplicated model.provider/model.id.
Updates all call sites to derive from the retained Model reference.
Narrows the doc comment to accurately scope the fix.
The post-exec picker popped immediately after the agent presented
auto-review discussion findings, before the user could respond.

Adds an "awaiting-discussion" phase that holds the picker until a
user-initiated turn completes. Also suppresses redundant /review
offers (in the picker and in /commit) when auto-review already ran.
Copilot AI review requested due to automatic review settings May 7, 2026 20:58
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adjusts the post-execution auto-review flow in the review and modes extensions to (1) avoid a model-registry re-lookup race by retaining the resolved Model reference, and (2) prevent the post-exec picker from appearing before the user has had a chance to respond to surfaced auto-review findings. It also updates the lockfile via npm audit fix.

Changes:

  • Retain the resolved Model<Api> in ResolvedTierModel and pass it directly into the orchestrator session (avoids a second registry lookup).
  • Add an awaiting-discussion phase in modes to defer the post-exec picker until after a user-initiated response turn completes, and suppress redundant /review offers when auto-review already ran.
  • Update package-lock.json with patched transitive dependency versions.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 3 comments.

File Description
packages/review/auto-review.ts Keeps the resolved model object and threads it through orchestrator/reviewer invocations to avoid registry re-lookup races.
packages/modes/index.ts Introduces awaiting-discussion, adds autoReviewRan suppression logic, and adjusts picker/commit dispatch to avoid redundant review prompts.
package-lock.json Applies dependency updates from npm audit fix.

Comment thread packages/modes/index.ts
Comment on lines 940 to +941
pi.on("before_agent_start", async () => {
userInitiatedTurn = true;
Comment thread packages/modes/index.ts
Comment on lines +1275 to +1293
const hasSurfaced = (result.surfaced?.length ?? 0) > 0;
const hasAutoApplied = (result.autoApplied?.length ?? 0) > 0;
if (hasSurfaced || hasAutoApplied) {
if (modeState) {
modeState.autoReviewRan = true;
// Discussion findings need user interaction before
// the picker pops. Fix-only can proceed immediately.
modeState.phase = hasSurfaced
? "awaiting-discussion"
: "awaiting-fix";
}
persist();
updateWidget(ctx);
return;
}
if (result.ran && modeState) {
modeState.autoReviewRan = true;
persist();
}
Comment on lines 27 to 33
import { readFileSync } from "node:fs";
import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";
import type { Api, Model } from "@mariozechner/pi-ai";
import {
createAgentSession,
DefaultResourceLoader,
@vegardx vegardx merged commit ab31aaa into main May 8, 2026
5 checks passed
@vegardx vegardx deleted the fix/defer-picker-until-user-responds branch May 8, 2026 05:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants