mirror of
https://github.com/openai/codex.git
synced 2026-12-02 00:31:03 +00:00
tui: show read-only permissions in WSL
This commit is contained in:
@@ -8127,7 +8127,11 @@ impl ChatWidget {
|
||||
|
||||
/// Open a popup to choose the permissions mode.
|
||||
pub(crate) fn open_permissions_popup(&mut self) {
|
||||
let include_read_only = cfg!(target_os = "windows");
|
||||
// The read-only preset should stay visible for native Windows and WSL.
|
||||
// WSL runs the Linux build, so a compile-target-only gate hides a valid
|
||||
// preset even though `sandbox_mode = "read-only"` still works there.
|
||||
let include_read_only =
|
||||
cfg!(target_os = "windows") || crate::clipboard_paste::is_probably_wsl();
|
||||
let current_approval =
|
||||
AskForApproval::from(self.config.permissions.approval_policy.value());
|
||||
let current_permission_profile = self.config.permissions.permission_profile();
|
||||
|
||||
@@ -65,6 +65,39 @@ async fn approvals_selection_popup_snapshot() {
|
||||
assert_chatwidget_snapshot!("approvals_selection_popup", popup);
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
#[tokio::test]
|
||||
#[serial]
|
||||
async fn approvals_selection_popup_includes_read_only_preset_under_wsl() {
|
||||
let (mut chat, _rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
|
||||
let previous_wsl_distro = std::env::var_os("WSL_DISTRO_NAME");
|
||||
struct EnvRestoreGuard {
|
||||
previous: Option<std::ffi::OsString>,
|
||||
}
|
||||
impl Drop for EnvRestoreGuard {
|
||||
fn drop(&mut self) {
|
||||
match &self.previous {
|
||||
Some(value) => unsafe { std::env::set_var("WSL_DISTRO_NAME", value) },
|
||||
None => unsafe { std::env::remove_var("WSL_DISTRO_NAME") },
|
||||
}
|
||||
}
|
||||
}
|
||||
let _guard = EnvRestoreGuard {
|
||||
previous: previous_wsl_distro,
|
||||
};
|
||||
unsafe {
|
||||
std::env::set_var("WSL_DISTRO_NAME", "Ubuntu");
|
||||
}
|
||||
|
||||
chat.open_approvals_popup();
|
||||
|
||||
let popup = render_bottom_popup(&chat, /*width*/ 80);
|
||||
assert!(
|
||||
popup.contains("Read Only"),
|
||||
"expected read-only preset in approvals popup: {popup}"
|
||||
);
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
#[tokio::test]
|
||||
#[serial]
|
||||
|
||||
Reference in New Issue
Block a user