mirror of
https://github.com/openai/codex.git
synced 2026-04-29 17:06:51 +00:00
correctly recognize WorkspaceWrite policy on /approvals (#7301)
the `/approvals` popup fails to recognize that the CLI is in WorkspaceWrite mode if that policy has extra bits, like `writable_roots` etc. This change matches the policy, ignoring additional config aspects.
This commit is contained in:
@@ -1567,6 +1567,29 @@ fn approvals_selection_popup_snapshot() {
|
||||
assert_snapshot!("approvals_selection_popup", popup);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn preset_matching_ignores_extra_writable_roots() {
|
||||
let preset = builtin_approval_presets()
|
||||
.into_iter()
|
||||
.find(|p| p.id == "auto")
|
||||
.expect("auto preset exists");
|
||||
let current_sandbox = SandboxPolicy::WorkspaceWrite {
|
||||
writable_roots: vec![PathBuf::from("C:\\extra")],
|
||||
network_access: false,
|
||||
exclude_tmpdir_env_var: false,
|
||||
exclude_slash_tmp: false,
|
||||
};
|
||||
|
||||
assert!(
|
||||
ChatWidget::preset_matches_current(AskForApproval::OnRequest, ¤t_sandbox, &preset),
|
||||
"WorkspaceWrite with extra roots should still match the Agent preset"
|
||||
);
|
||||
assert!(
|
||||
!ChatWidget::preset_matches_current(AskForApproval::Never, ¤t_sandbox, &preset),
|
||||
"approval mismatch should prevent matching the preset"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn full_access_confirmation_popup_snapshot() {
|
||||
let (mut chat, _rx, _op_rx) = make_chatwidget_manual();
|
||||
|
||||
Reference in New Issue
Block a user