Recompute the approval reviewer when switching models (#59893)

## Why

Switching away from a model that requires automatic review should restore the user's requested approval reviewer instead of retaining the model's enforced reviewer.

## What changed

Recompute the reviewer from the requested preference and model requirements when the model changes without an explicit reviewer update, unless the session uses a trusted guardian reviewer. Preserve an explicit automatic-review preference across subsequent model switches.

## Testing

Extend the app-server settings regression test to cover restoring user review after leaving a protected model and retaining an explicit automatic-review choice across repeated model switches.

GitOrigin-RevId: a5672d1ebe94c2fac201ad460b4789d11df03b1a
This commit is contained in:
jif
2026-11-06 12:04:44 +00:00
committed by copyberry
parent b1a0dff158
commit f49ae52079
2 changed files with 51 additions and 1 deletions
+18
View File
@@ -604,6 +604,24 @@ impl SessionConfiguration {
Arc::make_mut(&mut next_configuration.original_config_do_not_use)
.requested_approvals_reviewer = Some(reviewer);
}
if !next_configuration.trusted_guardian_reviewer
&& updates.step_settings.approvals_reviewer.is_none()
&& self.step_settings.collaboration_mode.model()
!= next_configuration.step_settings.collaboration_mode.model()
{
let reviewer = crate::config::resolve_guardian_reviewer(
next_configuration
.original_config_do_not_use
.requested_approvals_reviewer
.unwrap_or(self.step_settings.approvals_reviewer),
Some(next_configuration.step_settings.collaboration_mode.model()),
next_configuration
.original_config_do_not_use
.config_layer_stack
.requirements(),
)?;
Arc::make_mut(&mut next_configuration.step_settings).approvals_reviewer = reviewer;
}
Ok(next_configuration)
}