mirror of
https://github.com/openai/codex.git
synced 2026-11-26 07:26:11 +00:00
Discover permission profiles from the app server (#42453)
## Why The permissions menu needs to reflect the profiles and configuration requirements available in the active app-server scope, including remote workspaces. ## What changed - Load permission profiles and configuration requirements asynchronously when opening the permissions menu, using the active thread working directory. - Render loading, retry, empty-catalog, and unsupported-server states, and fall back to the legacy permissions menu when explicit profiles are not configured. - Disable profiles rejected by server requirements or unavailable in the catalog. Remote custom profiles remain visible but cannot yet be selected. - Bound pagination and request time, reject malformed catalogs, and ignore responses made stale by account, thread, or modal changes. ## Testing - Cover local, session-only, remote, legacy, empty, unsupported, pagination, malformed-response, and timeout discovery paths. - Add TUI tests for loading, failures, retries, empty results, remote catalogs, stale responses, and working-directory changes. GitOrigin-RevId: 3e2ab53a4eae1179587d064f9a4c605765ea7880
This commit is contained in:
1 parent
8b8ee28a9b
commit
c9fecd3fa0
19 files changed
+797
-22
No files matched your search
@@ -1,4 +1,7 @@
|
||||
//! Named permission choices from the server catalog, using the existing selection actions.
|
||||
|
||||
use super::*;
|
||||
use crate::permission_discovery::PermissionDiscovery;
|
||||
use codex_protocol::models::BUILT_IN_PERMISSION_PROFILE_DANGER_FULL_ACCESS;
|
||||
|
||||
pub(crate) fn auto_review_available(config: &Config) -> bool {
|
||||
@@ -58,7 +61,7 @@ impl ChatWidget {
|
||||
})
|
||||
}
|
||||
|
||||
pub(super) fn open_permission_profiles_popup(&mut self) {
|
||||
pub(super) fn open_permission_profiles_popup(&mut self, discovery: PermissionDiscovery) {
|
||||
let active_profile_id = self
|
||||
.config
|
||||
.permissions
|
||||
@@ -85,6 +88,7 @@ impl ChatWidget {
|
||||
};
|
||||
let mut items = vec![
|
||||
self.builtin_permission_mode_selection_item(
|
||||
&discovery,
|
||||
default,
|
||||
":workspace",
|
||||
default
|
||||
@@ -96,6 +100,7 @@ impl ChatWidget {
|
||||
];
|
||||
if self.config.features.enabled(Feature::GuardianApproval) {
|
||||
items.push(self.builtin_permission_mode_selection_item(
|
||||
&discovery,
|
||||
default,
|
||||
":workspace",
|
||||
AUTO_REVIEW_DESCRIPTION.to_string(),
|
||||
@@ -104,6 +109,7 @@ impl ChatWidget {
|
||||
));
|
||||
}
|
||||
items.push(self.builtin_permission_mode_selection_item(
|
||||
&discovery,
|
||||
full_access,
|
||||
BUILT_IN_PERMISSION_PROFILE_DANGER_FULL_ACCESS,
|
||||
full_access.description.to_string(),
|
||||
@@ -111,6 +117,7 @@ impl ChatWidget {
|
||||
ApprovalsReviewer::User,
|
||||
));
|
||||
items.push(self.builtin_permission_mode_selection_item(
|
||||
&discovery,
|
||||
read_only,
|
||||
":read-only",
|
||||
read_only.description.to_string(),
|
||||
@@ -118,9 +125,10 @@ impl ChatWidget {
|
||||
ApprovalsReviewer::User,
|
||||
));
|
||||
items.extend(
|
||||
self.config
|
||||
.custom_permission_profiles
|
||||
discovery
|
||||
.profiles
|
||||
.iter()
|
||||
.filter(|profile| !profile.id.starts_with(':'))
|
||||
.map(|profile| {
|
||||
Self::permission_profile_selection_item(
|
||||
&profile.id,
|
||||
@@ -130,12 +138,36 @@ impl ChatWidget {
|
||||
.as_deref()
|
||||
.unwrap_or("Configured permission profile."),
|
||||
active_profile_id.as_deref(),
|
||||
profile.allowed,
|
||||
discovery.disabled_reason(
|
||||
&profile.id,
|
||||
/*approval*/ None,
|
||||
/*reviewer*/ None,
|
||||
),
|
||||
)
|
||||
}),
|
||||
);
|
||||
|
||||
if discovery.profiles.is_empty() {
|
||||
items.clear();
|
||||
}
|
||||
if let Some(id) = active_profile_id.as_deref()
|
||||
&& !discovery.profiles.iter().any(|profile| profile.id == id)
|
||||
&& !items.iter().any(|item| item.is_current)
|
||||
{
|
||||
items.push(Self::permission_profile_selection_item(
|
||||
id,
|
||||
id,
|
||||
"Current permission profile.",
|
||||
Some(id),
|
||||
Some("Not available on this server.".to_string()),
|
||||
));
|
||||
}
|
||||
self.bottom_pane.show_selection_view(SelectionViewParams {
|
||||
view_id: Some(super::permission_discovery::VIEW_ID),
|
||||
subtitle: discovery
|
||||
.profiles
|
||||
.is_empty()
|
||||
.then(|| "No permission profiles returned by the server.".to_string()),
|
||||
title: Some("Update Model Permissions".to_string()),
|
||||
footer_hint: Some(standard_popup_hint_line()),
|
||||
items,
|
||||
@@ -146,6 +178,7 @@ impl ChatWidget {
|
||||
|
||||
fn builtin_permission_mode_selection_item(
|
||||
&self,
|
||||
discovery: &PermissionDiscovery,
|
||||
preset: &ApprovalPreset,
|
||||
id: &str,
|
||||
description: String,
|
||||
@@ -186,7 +219,9 @@ impl ChatWidget {
|
||||
/*return_to_permissions*/ true,
|
||||
),
|
||||
dismiss_on_select: true,
|
||||
disabled_reason: self.permission_mode_disabled_reason(preset, approval_policy),
|
||||
disabled_reason: discovery
|
||||
.disabled_reason(id, Some(approval_policy), Some(approvals_reviewer.into()))
|
||||
.or_else(|| self.permission_mode_disabled_reason(preset, approval_policy)),
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
@@ -196,7 +231,7 @@ impl ChatWidget {
|
||||
id: &str,
|
||||
description: &str,
|
||||
active_profile_id: Option<&str>,
|
||||
allowed: bool,
|
||||
disabled_reason: Option<String>,
|
||||
) -> SelectionItem {
|
||||
let id_for_action = id.to_string();
|
||||
let selection = PermissionProfileSelection {
|
||||
@@ -211,7 +246,7 @@ impl ChatWidget {
|
||||
is_current: active_profile_id == Some(id),
|
||||
actions: Self::permission_profile_selection_actions(selection),
|
||||
dismiss_on_select: true,
|
||||
disabled_reason: (!allowed).then(|| "Disabled by requirements.".to_string()),
|
||||
disabled_reason,
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user