mirror of
https://github.com/openai/codex.git
synced 2026-11-26 07:26:11 +00:00
Add keybindings for cycling TUI permission modes (#39873)
## What changed - Add unbound `previous_permission_mode` and `next_permission_mode` actions to `tui.keymap.chat` so users can configure shortcuts that cycle through the available built-in permission modes. - Apply shortcut selections only to the active session, without writing them to `config.toml`, and report update failures in the transcript. - Exclude modes disallowed by managed requirements or platform safety checks, reject printable-key bindings, and ignore these bindings in project config. ## Testing - Cover mode cycling, unavailable modes, session-only updates, server errors, stale threads, keymap validation, and project-config sanitization. GitOrigin-RevId: c3cfdf1e732b7b7bfe8f53fcac19a37e593bbfab
This commit is contained in:
1 parent
44e95c857f
commit
2aaefa32b0
32 files changed
+708
-47
No files matched your search
@@ -33,6 +33,31 @@ pub(crate) fn cyber_model_approval_reviewer(config: &Config) -> Option<Approvals
|
||||
}
|
||||
|
||||
impl ChatWidget {
|
||||
pub(super) fn permission_mode_disabled_reason(
|
||||
&self,
|
||||
preset: &ApprovalPreset,
|
||||
approval_policy: AskForApproval,
|
||||
) -> Option<String> {
|
||||
self.config
|
||||
.permissions
|
||||
.approval_policy
|
||||
.can_set(&approval_policy.to_core())
|
||||
.and_then(|()| {
|
||||
self.config
|
||||
.permissions
|
||||
.can_set_permission_profile(&preset.permission_profile)
|
||||
})
|
||||
.err()
|
||||
.map(|err| err.to_string())
|
||||
.or_else(|| {
|
||||
(!self.config.is_permission_profile_allowed(
|
||||
&preset.active_permission_profile.id,
|
||||
&preset.permission_profile,
|
||||
))
|
||||
.then(|| "Disabled by requirements.".to_string())
|
||||
})
|
||||
}
|
||||
|
||||
pub(super) fn open_permission_profiles_popup(&mut self) {
|
||||
let active_profile_id = self
|
||||
.config
|
||||
@@ -161,26 +186,7 @@ impl ChatWidget {
|
||||
/*return_to_permissions*/ true,
|
||||
),
|
||||
dismiss_on_select: true,
|
||||
disabled_reason: self
|
||||
.config
|
||||
.permissions
|
||||
.approval_policy
|
||||
.can_set(&approval_policy.to_core())
|
||||
.err()
|
||||
.map(|err| err.to_string())
|
||||
.or_else(|| {
|
||||
self.config
|
||||
.permissions
|
||||
.can_set_permission_profile(&preset.permission_profile)
|
||||
.err()
|
||||
.map(|err| err.to_string())
|
||||
})
|
||||
.or_else(|| {
|
||||
(!self
|
||||
.config
|
||||
.is_permission_profile_allowed(id, &preset.permission_profile))
|
||||
.then(|| "Disabled by requirements.".to_string())
|
||||
}),
|
||||
disabled_reason: self.permission_mode_disabled_reason(preset, approval_policy),
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user