Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion codex-rs/tui/src/startup_hooks_review.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub(crate) async fn maybe_run_startup_hooks_review(
}
};
let entry = hooks_list_entry_for_cwd(response, &cwd);
if review_needed_count(&entry) == 0 {
if !review_is_needed(config.bypass_hook_trust, &entry) {
Comment thread
etraut-openai marked this conversation as resolved.
Resolved
Comment thread
etraut-openai marked this conversation as resolved.
Resolved
return Ok(StartupHooksReviewOutcome::Continue);
}

Expand Down Expand Up @@ -223,6 +223,10 @@ fn review_needed_count(entry: &HooksListEntry) -> usize {
.count()
}

fn review_is_needed(bypass_hook_trust: bool, entry: &HooksListEntry) -> bool {
!bypass_hook_trust && review_needed_count(entry) > 0
}

fn selection_item(name: &str, is_disabled: bool) -> SelectionItem {
SelectionItem {
name: name.to_string(),
Expand Down Expand Up @@ -259,6 +263,7 @@ impl WidgetRef for &StandaloneSelectionView<'_> {

#[cfg(test)]
mod tests {
use super::review_is_needed;
use super::selection_view;
use crate::app_event::AppEvent;
use crate::app_event_sender::AppEventSender;
Expand Down Expand Up @@ -333,6 +338,16 @@ mod tests {
.join("\n")
}

#[test]
fn bypass_hook_trust_suppresses_startup_review() {
assert!(!review_is_needed(/*bypass_hook_trust*/ true, &entry()));
}

#[test]
fn untrusted_hooks_need_review_without_bypass() {
assert!(review_is_needed(/*bypass_hook_trust*/ false, &entry()));
}

#[test]
fn renders_prompt() {
let (tx_raw, _rx) = unbounded_channel::<AppEvent>();
Expand Down
Loading