Conversation
💡 Codex Reviewcodex/codex-rs/tui/src/chatwidget/input_submission.rs Lines 337 to 342 in dce8018 This changes submitted user turns from carrying the concrete ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
viyatb-oai
left a comment
There was a problem hiding this comment.
Small API-shape suggestion below. Not blocking, but it seems aligned with the goal of this refactor.
| @@ -343,25 +327,11 @@ impl Permissions { | |||
| pub fn replace_permission_profile_from_session_snapshot( | |||
There was a problem hiding this comment.
This still leaves the replacement path with two sources of truth: callers pass both a constrained PermissionProfile and a PermissionProfileSnapshot. Since the only current caller builds Constrained::allow_only(session.permission_profile.clone()), could this API take only the snapshot and derive that constraint internally? That would make the “snapshot is the coherent unit” story complete here too.
| pub fn replace_permission_profile_from_session_snapshot( | |
| pub fn replace_permission_profile_from_session_snapshot( | |
| &mut self, | |
| snapshot: PermissionProfileSnapshot, | |
| ) -> ConstraintResult<()> { | |
| let permission_profile = | |
| Constrained::allow_only(snapshot.permission_profile().clone()); | |
| self.permission_profile_state = PermissionProfileState::from_constrained_resolved( | |
| permission_profile, | |
| snapshot.into_resolved_permission_profile(), | |
| )?; | |
| Ok(()) | |
| } |
There was a problem hiding this comment.
Addressed in the latest revision: replace_permission_profile_from_session_snapshot() now takes only PermissionProfileSnapshot and derives Constrained::allow_only(snapshot.permission_profile().clone()) internally, so the replacement path uses the snapshot as the single coherent source.
Why
#22891 moved the TUI turn-command path to pass
ActivePermissionProfileinstead of the fullPermissionProfile, but the remaining config/session bridge still accepted the concretePermissionProfileand active profile id as separate arguments. That shape made it too easy for future callers to update the concrete profile and active profile id out of sync.This PR makes the trusted session snapshot path pass one coherent value into
Permissions, while keepingrequirements.tomlenforcement owned by the existing constrained permission state.What Changed
PermissionProfileSnapshotas the public snapshot value for trusted session/config synchronization.Permissions::set_permission_profile_from_session_snapshot()andreplace_permission_profile_from_session_snapshot()to take aPermissionProfileSnapshot.PermissionProfilefrom the snapshot, so callers cannot pass a separate profile that disagrees with the snapshot.PermissionProfileState::set_active_permission_profile()mutation path.How To Review
codex-rs/core/src/config/resolved_permission_profile.rs;PermissionProfileSnapshotis the public wrapper, whileResolvedPermissionProfilestays internal.codex-rs/core/src/config/mod.rsto confirm both session-snapshot setters validate throughPermissionProfileStateand no longer accept loose profile/id pairs.codex-rs/core/src/session/session.rsfor the session projection path; it now builds the snapshot before installing it.Verification
cargo test -p codex-core permission_snapshot_setter_preserves_permission_constraintscargo test -p codex-tui status_permissions_cargo test -p codex-tui session_configured_preserves_profile_workspace_rootsjust fix -p codex-core -p codex-tui