Skip to content

Commit 3ac2fd0

Browse files
JoeJoe
authored andcommitted
Keep full access reviewer update session-scoped
1 parent d0047de commit 3ac2fd0

4 files changed

Lines changed: 30 additions & 4 deletions

File tree

‎codex-rs/tui/src/app.rs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5444,6 +5444,9 @@ impl App {
54445444
}
54455445
}
54465446
}
5447+
AppEvent::UpdateApprovalsReviewerForSession(policy) => {
5448+
self.set_approvals_reviewer_in_app_and_widget(policy);
5449+
}
54475450
AppEvent::UpdateApprovalsReviewer(policy) => {
54485451
self.config.approvals_reviewer = policy;
54495452
self.chat_widget.set_approvals_reviewer(policy);

‎codex-rs/tui/src/app_event.rs‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,10 @@ pub(crate) enum AppEvent {
459459
/// Update the current sandbox policy in the running app and widget.
460460
UpdateSandboxPolicy(SandboxPolicy),
461461

462-
/// Update the current approvals reviewer in the running app and widget.
462+
/// Update the current approvals reviewer in the running app and widget for this session only.
463+
UpdateApprovalsReviewerForSession(ApprovalsReviewer),
464+
465+
/// Update the current approvals reviewer and persist it to config.toml.
463466
UpdateApprovalsReviewer(ApprovalsReviewer),
464467

465468
/// Update feature flags and persist them to the top-level config.

‎codex-rs/tui/src/chatwidget.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8599,7 +8599,7 @@ impl ChatWidget {
85998599
));
86008600
tx.send(AppEvent::UpdateAskForApprovalPolicy(approval));
86018601
tx.send(AppEvent::UpdateSandboxPolicy(sandbox_clone));
8602-
tx.send(AppEvent::UpdateApprovalsReviewer(approvals_reviewer));
8602+
tx.send(AppEvent::UpdateApprovalsReviewerForSession(approvals_reviewer));
86038603
tx.send(AppEvent::InsertHistoryCell(Box::new(
86048604
history_cell::new_info_event(
86058605
format!("Permissions updated to {label}"),

‎codex-rs/tui/src/chatwidget/tests/permissions.rs‎

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ async fn permissions_selection_can_disable_guardian_approvals() {
565565
assert!(
566566
events.iter().any(|event| matches!(
567567
event,
568-
AppEvent::UpdateApprovalsReviewer(ApprovalsReviewer::User)
568+
AppEvent::UpdateApprovalsReviewerForSession(ApprovalsReviewer::User)
569569
)),
570570
"expected selecting Default from Guardian Approvals to switch back to manual approval review: {events:?}"
571571
);
@@ -693,7 +693,27 @@ async fn permissions_full_access_history_cell_emitted_only_after_confirmation()
693693
);
694694

695695
chat.handle_key_event(KeyEvent::from(KeyCode::Enter));
696-
let cells_after_confirmation = drain_insert_history(&mut rx);
696+
let events_after_confirmation = std::iter::from_fn(|| rx.try_recv().ok()).collect::<Vec<_>>();
697+
assert!(
698+
events_after_confirmation.iter().any(|event| matches!(
699+
event,
700+
AppEvent::UpdateApprovalsReviewerForSession(ApprovalsReviewer::User)
701+
)),
702+
"expected full access confirmation to update the reviewer for this session: {events_after_confirmation:?}"
703+
);
704+
assert!(
705+
!events_after_confirmation
706+
.iter()
707+
.any(|event| matches!(event, AppEvent::UpdateApprovalsReviewer(_))),
708+
"session-only full access confirmation must not persist approvals_reviewer: {events_after_confirmation:?}"
709+
);
710+
let cells_after_confirmation = events_after_confirmation
711+
.into_iter()
712+
.filter_map(|event| match event {
713+
AppEvent::InsertHistoryCell(cell) => Some(cell.display_lines(/*width*/ 80)),
714+
_ => None,
715+
})
716+
.collect::<Vec<_>>();
697717
let total_history_cells = cells_before_confirmation.len() + cells_after_confirmation.len();
698718
assert_eq!(
699719
total_history_cells, 1,

0 commit comments

Comments
 (0)