-
Notifications
You must be signed in to change notification settings - Fork 6.6k
whitelist command prefix integration in core and tui #7033
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
683bc5f to
1273f94
Compare
9cb7ed0 to
80c63d3
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. 👍 ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
| commands: &[Vec<String>], | ||
| features: &Features, | ||
| ) -> Option<Vec<String>> { | ||
| if features.enabled(Feature::ExecPolicy) && commands.len() == 1 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't love the solution I came up with here w.r.t only persisting allow prefix if ExecPolicy is enabled. I think a better solution would be to change the way we store Policy in session state. We should store either an enum indicating whether ExecPolicy is enabled or store Policy as an optional. However, I think this is fit for a followup PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this relates to my long comment above on NeedsApproval.
|
@codex review |
|
Codex Review: Didn't find any major issues. Nice work! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
| features: Features, | ||
| /// Execpolicy policy, applied only when enabled by feature flag. | ||
| exec_policy: Arc<ExecPolicy>, | ||
| exec_policy: Arc<RwLock<ExecPolicy>>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, this feels slightly undesirable since SessionConfiguration is already generally wrapped in a mutex, but maybe this is OK, I'm not sure yet...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #7540
| } | ||
|
|
||
| #[derive(Debug, Clone, Deserialize, Serialize, JsonSchema, TS)] | ||
| pub struct ExecApprovalRequestEvent { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will need to update the v2 app server protocol as well, I expect. /cc @owenlin0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zhao-oai yes that'd be great if we can keep app-server at feature-parity (but can be done as a followup PR). We'd probably want to add a field here: https://github.com/openai/codex/blob/main/codex-rs/app-server-protocol/src/protocol/v2.rs#L1428 and wire it up
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gotcha. let's do this as a followup
| let approval_requirement = { | ||
| let exec_policy = context.session.current_exec_policy().await; | ||
| create_approval_requirement_for_command( | ||
| &exec_policy, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if instead of adding current_exec_policy(), we just pass &context.exec_policy to create_approval_requirement_for_command()?
Is the issue that context.session.state is held by a tokio::sync::mutex and so we need to clone the values while holding the lock so we can pass them into create_approval_requirement_for_command() because it is not async?
If so, should we make create_approval_requirement_for_command() async?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, merged. Rebase and rejoice!
I think this might help with #7033 because `create_approval_requirement_for_command()` will soon need access to `Session.state`, which is a `tokio::sync::Mutex` that needs to be accessed via `async`.
d23f506 to
312ceb4
Compare
| features: Features, | ||
| /// Execpolicy policy, applied only when enabled by feature flag. | ||
| exec_policy: Arc<ExecPolicy>, | ||
| exec_policy: Arc<RwLock<ExecPolicy>>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #7540
| commands: &[Vec<String>], | ||
| features: &Features, | ||
| ) -> Option<Vec<String>> { | ||
| if features.enabled(Feature::ExecPolicy) && commands.len() == 1 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this relates to my long comment above on NeedsApproval.
86b1d98 to
31c5e11
Compare
bolinfest
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sure to rebase on #7540 when cleaning up merge conflicts!
Add explicit prefix-approval decision and wire it through execpolicy/UI snapshots update doc mutating in memory policy instead of reloading using RW locks clippy refactor: adding allow_prefix into ApprovedAllowPrefix fmt do not send allow_prefix if execpolicy is disabled moving args around cleanup exec_policy getters undo diff fixing rw lock bug causing tui to hang updating phrasing integration test . fix compile fix flaky test fix compile error running test with single thread fixup allow_prefix_if_applicable fix formatting fix approvals test only cloning when needed docs add docstring fix rebase bug fixing rebase issues Revert "fixing rebase issues" This reverts commit 79ce7e1. fix rebase errors
this PR enables TUI to approve commands and add their prefixes to an allowlist:

note: we only show the option to whitelist the command when
git add -A && git commit -m 'hello world')