mirror of
https://github.com/openai/codex.git
synced 2026-11-22 07:13:50 +00:00
Improve hooks trust flow in TUI (#21755)
# Why Hooks that need trust review were easy to miss, and the existing TUI flow made users discover `/hooks` manually before they could decide whether to inspect or trust them. # What - add a startup review prompt for new or changed hooks before normal composer use - add a top-level `t` shortcut in `/hooks` to trust every review-needed hook at once - make pending-review rows and helper copy use warning styling ## TUI ### Startup review interstitial ```text Hooks need review 2 hooks are new or changed. Hooks can run outside the sandbox after you trust them. › 1. Review hooks 2. Trust all and continue 3. Continue without trusting (hooks won't run) ``` ### Top-level `/hooks` page when review is needed ```text Hooks Lifecycle hooks from config and enabled plugins. ⚠ 1 hook needs review before it can run. Event Installed Active Review Description PreToolUse 1 0 1 Before a tool executes ... Press t to trust all; enter to review hooks; esc to close ```
This commit is contained in:
1 parent
53468b97f6
commit
6d747db7d8
16 files changed
+846
-209
No files matched your search
@@ -1,8 +1,8 @@
|
||||
use codex_app_server_protocol::HookErrorInfo;
|
||||
use codex_app_server_protocol::HookEventName;
|
||||
use codex_app_server_protocol::HookMetadata;
|
||||
use codex_app_server_protocol::HookSource;
|
||||
use codex_app_server_protocol::HookTrustStatus;
|
||||
use codex_app_server_protocol::HooksListEntry;
|
||||
use crossterm::event::KeyCode;
|
||||
use crossterm::event::KeyEvent;
|
||||
use crossterm::event::KeyModifiers;
|
||||
@@ -26,6 +26,8 @@ use super::scroll_state::ScrollState;
|
||||
use super::selection_popup_common::render_menu_surface;
|
||||
use crate::app_event::AppEvent;
|
||||
use crate::app_event_sender::AppEventSender;
|
||||
use crate::hooks_rpc::HookTrustUpdate;
|
||||
use crate::hooks_rpc::hook_needs_review;
|
||||
use crate::key_hint;
|
||||
use crate::line_truncation::truncate_line_with_ellipsis_if_overflow;
|
||||
use crate::render::renderable::Renderable;
|
||||
@@ -43,9 +45,7 @@ enum HooksBrowserPage {
|
||||
}
|
||||
|
||||
pub(crate) struct HooksBrowserView {
|
||||
hooks: Vec<HookMetadata>,
|
||||
warnings: Vec<String>,
|
||||
errors: Vec<HookErrorInfo>,
|
||||
entry: HooksListEntry,
|
||||
page: HooksBrowserPage,
|
||||
state: ScrollState,
|
||||
complete: bool,
|
||||
@@ -53,17 +53,28 @@ pub(crate) struct HooksBrowserView {
|
||||
}
|
||||
|
||||
impl HooksBrowserView {
|
||||
#[cfg(test)]
|
||||
pub(crate) fn new(
|
||||
mut hooks: Vec<HookMetadata>,
|
||||
hooks: Vec<HookMetadata>,
|
||||
warnings: Vec<String>,
|
||||
errors: Vec<HookErrorInfo>,
|
||||
errors: Vec<codex_app_server_protocol::HookErrorInfo>,
|
||||
app_event_tx: AppEventSender,
|
||||
) -> Self {
|
||||
hooks.sort_by_key(|hook| hook.display_order);
|
||||
Self::from_entry(
|
||||
HooksListEntry {
|
||||
cwd: std::path::PathBuf::new(),
|
||||
hooks,
|
||||
warnings,
|
||||
errors,
|
||||
},
|
||||
app_event_tx,
|
||||
)
|
||||
}
|
||||
|
||||
pub(crate) fn from_entry(mut entry: HooksListEntry, app_event_tx: AppEventSender) -> Self {
|
||||
entry.hooks.sort_by_key(|hook| hook.display_order);
|
||||
let mut view = Self {
|
||||
hooks,
|
||||
warnings,
|
||||
errors,
|
||||
entry,
|
||||
page: HooksBrowserPage::Events,
|
||||
state: ScrollState::new(),
|
||||
complete: false,
|
||||
@@ -85,16 +96,19 @@ impl HooksBrowserView {
|
||||
.map(|event_name| {
|
||||
let event_name: HookEventName = event_name.into();
|
||||
let installed = self
|
||||
.entry
|
||||
.hooks
|
||||
.iter()
|
||||
.filter(|hook| hook.event_name == event_name)
|
||||
.count();
|
||||
let active = self
|
||||
.entry
|
||||
.hooks
|
||||
.iter()
|
||||
.filter(|hook| hook.event_name == event_name && hook_is_active(hook))
|
||||
.count();
|
||||
let needs_review = self
|
||||
.entry
|
||||
.hooks
|
||||
.iter()
|
||||
.filter(|hook| hook.event_name == event_name && hook_needs_review(hook))
|
||||
@@ -110,7 +124,8 @@ impl HooksBrowserView {
|
||||
}
|
||||
|
||||
fn handlers_for_event(&self, event_name: HookEventName) -> impl Iterator<Item = &HookMetadata> {
|
||||
self.hooks
|
||||
self.entry
|
||||
.hooks
|
||||
.iter()
|
||||
.filter(move |hook| hook.event_name == event_name)
|
||||
}
|
||||
@@ -124,7 +139,8 @@ impl HooksBrowserView {
|
||||
|
||||
fn selected_hook_index(&self, event_name: HookEventName) -> Option<usize> {
|
||||
let selected_visible_idx = self.state.selected_idx?;
|
||||
self.hooks
|
||||
self.entry
|
||||
.hooks
|
||||
.iter()
|
||||
.enumerate()
|
||||
.filter(|(_, hook)| hook.event_name == event_name)
|
||||
@@ -134,7 +150,7 @@ impl HooksBrowserView {
|
||||
|
||||
fn selected_hook(&self, event_name: HookEventName) -> Option<&HookMetadata> {
|
||||
self.selected_hook_index(event_name)
|
||||
.and_then(|idx| self.hooks.get(idx))
|
||||
.and_then(|idx| self.entry.hooks.get(idx))
|
||||
}
|
||||
|
||||
fn move_up(&mut self) {
|
||||
@@ -175,7 +191,7 @@ impl HooksBrowserView {
|
||||
let Some(idx) = self.selected_hook_index(event_name) else {
|
||||
return;
|
||||
};
|
||||
let Some(hook) = self.hooks.get_mut(idx) else {
|
||||
let Some(hook) = self.entry.hooks.get_mut(idx) else {
|
||||
return;
|
||||
};
|
||||
if hook.is_managed {
|
||||
@@ -196,7 +212,7 @@ impl HooksBrowserView {
|
||||
let Some(idx) = self.selected_hook_index(event_name) else {
|
||||
return;
|
||||
};
|
||||
let Some(hook) = self.hooks.get_mut(idx) else {
|
||||
let Some(hook) = self.entry.hooks.get_mut(idx) else {
|
||||
return;
|
||||
};
|
||||
if !hook_needs_review(hook) {
|
||||
@@ -210,6 +226,24 @@ impl HooksBrowserView {
|
||||
});
|
||||
}
|
||||
|
||||
fn trust_all_hooks(&mut self) {
|
||||
let mut updates = Vec::new();
|
||||
for hook in &mut self.entry.hooks {
|
||||
if !hook_needs_review(hook) {
|
||||
continue;
|
||||
}
|
||||
|
||||
hook.trust_status = HookTrustStatus::Trusted;
|
||||
updates.push(HookTrustUpdate {
|
||||
key: hook.key.clone(),
|
||||
current_hash: hook.current_hash.clone(),
|
||||
});
|
||||
}
|
||||
if !updates.is_empty() {
|
||||
self.app_event_tx.send(AppEvent::TrustHooks { updates });
|
||||
}
|
||||
}
|
||||
|
||||
fn close(&mut self) {
|
||||
self.complete = true;
|
||||
}
|
||||
@@ -238,23 +272,27 @@ impl HooksBrowserView {
|
||||
]
|
||||
}
|
||||
|
||||
fn review_needed_total_count(&self) -> usize {
|
||||
self.entry
|
||||
.hooks
|
||||
.iter()
|
||||
.filter(|hook| hook_needs_review(hook))
|
||||
.count()
|
||||
}
|
||||
|
||||
#[allow(clippy::disallowed_methods)]
|
||||
fn handler_header_lines(
|
||||
event_name: HookEventName,
|
||||
review_needed_count: usize,
|
||||
) -> Vec<Line<'static>> {
|
||||
let mut lines = vec![format!("{} hooks", event_label(event_name)).bold().into()];
|
||||
match review_needed_count {
|
||||
0 => lines.push(
|
||||
match review_needed_message(review_needed_count) {
|
||||
None => lines.push(
|
||||
"Turn hooks on or off. Your changes are saved automatically."
|
||||
.dim()
|
||||
.into(),
|
||||
),
|
||||
1 => lines.push("1 hook needs review before it can run.".dim().into()),
|
||||
count => lines.push(
|
||||
format!("{count} hooks need review before they can run.")
|
||||
.dim()
|
||||
.into(),
|
||||
),
|
||||
Some(message) => lines.push(message.yellow().into()),
|
||||
}
|
||||
lines
|
||||
}
|
||||
@@ -265,6 +303,7 @@ impl HooksBrowserView {
|
||||
.count()
|
||||
}
|
||||
|
||||
#[allow(clippy::disallowed_methods)]
|
||||
fn event_table_lines(&self) -> Vec<Line<'static>> {
|
||||
let rows = self.event_rows();
|
||||
let show_review = rows.iter().any(|row| row.needs_review > 0);
|
||||
@@ -280,59 +319,59 @@ impl HooksBrowserView {
|
||||
header.push("Description".into());
|
||||
lines.push(Line::from(header));
|
||||
for (idx, row) in rows.into_iter().enumerate() {
|
||||
if self.state.selected_idx == Some(idx) {
|
||||
let style = accent_style();
|
||||
let mut row_line = vec![
|
||||
Span::from(format!(
|
||||
"{:<EVENT_COLUMN_WIDTH$}",
|
||||
event_label(row.event_name)
|
||||
))
|
||||
.set_style(style),
|
||||
Span::from(format!("{:<COUNT_COLUMN_WIDTH$}", row.installed)).set_style(style),
|
||||
Span::from(format!("{:<COUNT_COLUMN_WIDTH$}", row.active)).set_style(style),
|
||||
];
|
||||
if show_review {
|
||||
row_line.push(
|
||||
Span::from(format!("{:<COUNT_COLUMN_WIDTH$}", row.needs_review))
|
||||
.set_style(style),
|
||||
);
|
||||
}
|
||||
row_line.push(Span::from(event_description(row.event_name)).set_style(style));
|
||||
lines.push(Line::from(row_line));
|
||||
} else {
|
||||
let mut row_line = vec![
|
||||
Span::from(format!(
|
||||
"{:<EVENT_COLUMN_WIDTH$}",
|
||||
event_label(row.event_name)
|
||||
)),
|
||||
Span::from(format!("{:<COUNT_COLUMN_WIDTH$}", row.installed)).dim(),
|
||||
Span::from(format!("{:<COUNT_COLUMN_WIDTH$}", row.active)).dim(),
|
||||
];
|
||||
if show_review {
|
||||
row_line.push(
|
||||
Span::from(format!("{:<COUNT_COLUMN_WIDTH$}", row.needs_review)).dim(),
|
||||
);
|
||||
}
|
||||
row_line.push(Span::from(event_description(row.event_name)).dim());
|
||||
lines.push(Line::from(row_line));
|
||||
let selected = self.state.selected_idx == Some(idx);
|
||||
let needs_review = row.needs_review > 0;
|
||||
let mut row_line = vec![
|
||||
Span::from(format!(
|
||||
"{:<EVENT_COLUMN_WIDTH$}",
|
||||
event_label(row.event_name)
|
||||
)),
|
||||
Span::from(format!("{:<COUNT_COLUMN_WIDTH$}", row.installed)),
|
||||
Span::from(format!("{:<COUNT_COLUMN_WIDTH$}", row.active)),
|
||||
];
|
||||
if show_review {
|
||||
let review_count = Span::from(format!("{:<COUNT_COLUMN_WIDTH$}", row.needs_review));
|
||||
row_line.push(if needs_review {
|
||||
review_count.yellow()
|
||||
} else {
|
||||
review_count
|
||||
});
|
||||
}
|
||||
row_line.push(Span::from(event_description(row.event_name)));
|
||||
|
||||
if selected {
|
||||
let style = accent_style();
|
||||
for span in &mut row_line {
|
||||
*span = span.clone().set_style(style);
|
||||
}
|
||||
} else {
|
||||
row_line[1] = row_line[1].clone().dim();
|
||||
row_line[2] = row_line[2].clone().dim();
|
||||
if show_review && !needs_review {
|
||||
row_line[3] = row_line[3].clone().dim();
|
||||
}
|
||||
let description_idx = row_line.len() - 1;
|
||||
row_line[description_idx] = row_line[description_idx].clone().dim();
|
||||
}
|
||||
lines.push(Line::from(row_line));
|
||||
}
|
||||
lines
|
||||
}
|
||||
|
||||
fn event_issue_lines(&self) -> Vec<Line<'static>> {
|
||||
let mut lines = Vec::new();
|
||||
if self.warnings.is_empty() && self.errors.is_empty() {
|
||||
if self.entry.warnings.is_empty() && self.entry.errors.is_empty() {
|
||||
return lines;
|
||||
}
|
||||
|
||||
lines.push("Issues".bold().into());
|
||||
lines.extend(
|
||||
self.warnings
|
||||
self.entry
|
||||
.warnings
|
||||
.iter()
|
||||
.map(|warning| format!("⚠ {warning}").into()),
|
||||
);
|
||||
lines.extend(self.errors.iter().map(|error| {
|
||||
lines.extend(self.entry.errors.iter().map(|error| {
|
||||
format!("■ {}: {}", error.path.display(), error.message)
|
||||
.red()
|
||||
.into()
|
||||
@@ -340,10 +379,16 @@ impl HooksBrowserView {
|
||||
lines
|
||||
}
|
||||
|
||||
#[allow(clippy::disallowed_methods)]
|
||||
fn event_page_lines(&self) -> Vec<Line<'static>> {
|
||||
let mut lines = Self::event_header_lines();
|
||||
lines.push(Line::default());
|
||||
|
||||
if let Some(message) = review_needed_message(self.review_needed_total_count()) {
|
||||
lines.push(format!("⚠ {message}").yellow().into());
|
||||
lines.push(Line::default());
|
||||
}
|
||||
|
||||
let issue_lines = self.event_issue_lines();
|
||||
if !issue_lines.is_empty() {
|
||||
lines.extend(issue_lines);
|
||||
@@ -354,6 +399,7 @@ impl HooksBrowserView {
|
||||
lines
|
||||
}
|
||||
|
||||
#[allow(clippy::disallowed_methods)]
|
||||
fn handler_row_lines(&self, event_name: HookEventName, width: usize) -> Vec<Line<'static>> {
|
||||
self.handlers_for_event(event_name)
|
||||
.enumerate()
|
||||
@@ -376,11 +422,17 @@ impl HooksBrowserView {
|
||||
};
|
||||
let mut line = Line::from(row);
|
||||
line = truncate_line_with_ellipsis_if_overflow(line, width);
|
||||
if hook.is_managed {
|
||||
line = line.dim();
|
||||
}
|
||||
let needs_review = hook_needs_review(hook);
|
||||
if self.state.selected_idx == Some(idx) {
|
||||
line = line.patch_style(accent_style());
|
||||
if needs_review {
|
||||
line = line.yellow().bold();
|
||||
} else {
|
||||
line = line.patch_style(accent_style());
|
||||
}
|
||||
} else if needs_review {
|
||||
line = line.yellow();
|
||||
} else if hook.is_managed {
|
||||
line = line.dim();
|
||||
}
|
||||
line
|
||||
})
|
||||
@@ -423,6 +475,15 @@ impl HooksBrowserView {
|
||||
height: area.height,
|
||||
};
|
||||
let footer = match self.page {
|
||||
HooksBrowserPage::Events if self.review_needed_total_count() > 0 => Line::from(vec![
|
||||
"Press ".into(),
|
||||
key_hint::plain(KeyCode::Char('t')).into(),
|
||||
" to trust all; ".into(),
|
||||
key_hint::plain(KeyCode::Enter).into(),
|
||||
" to review hooks; ".into(),
|
||||
key_hint::plain(KeyCode::Esc).into(),
|
||||
" to close".into(),
|
||||
]),
|
||||
HooksBrowserPage::Events => Line::from(vec![
|
||||
"Press ".into(),
|
||||
key_hint::plain(KeyCode::Enter).into(),
|
||||
@@ -516,11 +577,10 @@ impl BottomPaneView for HooksBrowserView {
|
||||
code: KeyCode::Char('t'),
|
||||
modifiers: KeyModifiers::NONE,
|
||||
..
|
||||
} => {
|
||||
if let HooksBrowserPage::Handlers(event_name) = self.page {
|
||||
self.trust_selected_hook(event_name);
|
||||
}
|
||||
}
|
||||
} => match self.page {
|
||||
HooksBrowserPage::Events => self.trust_all_hooks(),
|
||||
HooksBrowserPage::Handlers(event_name) => self.trust_selected_hook(event_name),
|
||||
},
|
||||
KeyEvent {
|
||||
code: KeyCode::Esc, ..
|
||||
} => match self.page {
|
||||
@@ -631,6 +691,14 @@ fn hook_is_active(hook: &HookMetadata) -> bool {
|
||||
)
|
||||
}
|
||||
|
||||
fn review_needed_message(count: usize) -> Option<String> {
|
||||
match count {
|
||||
0 => None,
|
||||
1 => Some("1 hook needs review before it can run.".to_string()),
|
||||
count => Some(format!("{count} hooks need review before they can run.")),
|
||||
}
|
||||
}
|
||||
|
||||
struct EventRow {
|
||||
event_name: HookEventName,
|
||||
installed: usize,
|
||||
@@ -638,13 +706,6 @@ struct EventRow {
|
||||
needs_review: usize,
|
||||
}
|
||||
|
||||
fn hook_needs_review(hook: &HookMetadata) -> bool {
|
||||
matches!(
|
||||
hook.trust_status,
|
||||
HookTrustStatus::Untrusted | HookTrustStatus::Modified
|
||||
)
|
||||
}
|
||||
|
||||
fn hook_trust_label(status: HookTrustStatus) -> &'static str {
|
||||
match status {
|
||||
HookTrustStatus::Managed => "Managed",
|
||||
@@ -784,6 +845,7 @@ mod tests {
|
||||
use crate::test_support::PathBufExt;
|
||||
use crate::test_support::test_path_buf;
|
||||
use crate::test_support::test_path_display;
|
||||
use codex_app_server_protocol::HookErrorInfo;
|
||||
use codex_app_server_protocol::HookEventName;
|
||||
use codex_app_server_protocol::HookHandlerType;
|
||||
use codex_app_server_protocol::HookMetadata;
|
||||
@@ -794,6 +856,7 @@ mod tests {
|
||||
use insta::assert_snapshot;
|
||||
use ratatui::buffer::Buffer;
|
||||
use ratatui::layout::Rect;
|
||||
use ratatui::style::Color;
|
||||
use ratatui::style::Modifier;
|
||||
use tokio::sync::mpsc::unbounded_channel;
|
||||
|
||||
@@ -959,6 +1022,16 @@ mod tests {
|
||||
"hooks_browser_events_with_review_column",
|
||||
render_lines(&view, /*width*/ 112)
|
||||
);
|
||||
assert_eq!(
|
||||
view.event_table_lines()[1].spans[3].style.fg,
|
||||
Some(Color::Cyan)
|
||||
);
|
||||
assert!(
|
||||
view.event_table_lines()[1].spans[3]
|
||||
.style
|
||||
.add_modifier
|
||||
.contains(ratatui::style::Modifier::BOLD)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -1015,6 +1088,62 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn review_needed_handler_rows_use_warning_color() {
|
||||
let (tx_raw, _rx) = unbounded_channel::<AppEvent>();
|
||||
let mut untrusted_hook = hook(
|
||||
"path:untrusted",
|
||||
HookEventName::PreToolUse,
|
||||
HookSource::User,
|
||||
/*plugin_id*/ None,
|
||||
"~/bin/untrusted.sh",
|
||||
/*enabled*/ false,
|
||||
/*is_managed*/ false,
|
||||
/*display_order*/ 1,
|
||||
);
|
||||
untrusted_hook.trust_status = HookTrustStatus::Untrusted;
|
||||
let mut view = HooksBrowserView::new(
|
||||
vec![
|
||||
hook(
|
||||
"path:trusted",
|
||||
HookEventName::PreToolUse,
|
||||
HookSource::User,
|
||||
/*plugin_id*/ None,
|
||||
"~/bin/trusted.sh",
|
||||
/*enabled*/ true,
|
||||
/*is_managed*/ false,
|
||||
/*display_order*/ 0,
|
||||
),
|
||||
untrusted_hook,
|
||||
],
|
||||
Vec::new(),
|
||||
Vec::new(),
|
||||
AppEventSender::new(tx_raw),
|
||||
);
|
||||
view.handle_key_event(KeyEvent::from(KeyCode::Enter));
|
||||
|
||||
assert_eq!(
|
||||
view.handler_row_lines(HookEventName::PreToolUse, /*width*/ 112)[1]
|
||||
.style
|
||||
.fg,
|
||||
Some(Color::Yellow)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn review_needed_handler_header_uses_warning_color() {
|
||||
assert_eq!(
|
||||
HooksBrowserView::handler_header_lines(
|
||||
HookEventName::PreToolUse,
|
||||
/*review_needed_count*/ 1,
|
||||
)[1]
|
||||
.spans[0]
|
||||
.style
|
||||
.fg,
|
||||
Some(Color::Yellow)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn renders_managed_handler_without_toggle_hint() {
|
||||
let mut view = view();
|
||||
@@ -1373,7 +1502,7 @@ mod tests {
|
||||
view.handle_key_event(KeyEvent::from(KeyCode::Enter));
|
||||
view.handle_key_event(KeyEvent::from(KeyCode::Char('t')));
|
||||
|
||||
let hook = view.hooks.first().expect("trusted hook");
|
||||
let hook = view.entry.hooks.first().expect("trusted hook");
|
||||
assert!(!hook.enabled);
|
||||
assert_eq!(hook.trust_status, HookTrustStatus::Trusted);
|
||||
match rx.try_recv().expect("trust event") {
|
||||
@@ -1388,6 +1517,84 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn trust_key_on_event_page_trusts_all_review_needed_hooks() {
|
||||
let (tx_raw, mut rx) = unbounded_channel::<AppEvent>();
|
||||
let mut untrusted_hook = hook(
|
||||
"path:untrusted",
|
||||
HookEventName::PreToolUse,
|
||||
HookSource::User,
|
||||
/*plugin_id*/ None,
|
||||
"/tmp/pre-tool-use-check.sh",
|
||||
/*enabled*/ false,
|
||||
/*is_managed*/ false,
|
||||
/*display_order*/ 0,
|
||||
);
|
||||
untrusted_hook.trust_status = HookTrustStatus::Untrusted;
|
||||
let mut modified_hook = hook(
|
||||
"path:modified",
|
||||
HookEventName::Stop,
|
||||
HookSource::User,
|
||||
/*plugin_id*/ None,
|
||||
"/tmp/stop-check.sh",
|
||||
/*enabled*/ false,
|
||||
/*is_managed*/ false,
|
||||
/*display_order*/ 1,
|
||||
);
|
||||
modified_hook.trust_status = HookTrustStatus::Modified;
|
||||
let mut view = HooksBrowserView::new(
|
||||
vec![
|
||||
untrusted_hook,
|
||||
modified_hook,
|
||||
hook(
|
||||
"path:trusted",
|
||||
HookEventName::PreToolUse,
|
||||
HookSource::User,
|
||||
/*plugin_id*/ None,
|
||||
"/tmp/trusted.sh",
|
||||
/*enabled*/ true,
|
||||
/*is_managed*/ false,
|
||||
/*display_order*/ 2,
|
||||
),
|
||||
],
|
||||
Vec::new(),
|
||||
Vec::new(),
|
||||
AppEventSender::new(tx_raw),
|
||||
);
|
||||
|
||||
view.handle_key_event(KeyEvent::from(KeyCode::Char('t')));
|
||||
|
||||
assert_eq!(
|
||||
view.entry
|
||||
.hooks
|
||||
.iter()
|
||||
.map(|hook| hook.trust_status)
|
||||
.collect::<Vec<_>>(),
|
||||
vec![
|
||||
HookTrustStatus::Trusted,
|
||||
HookTrustStatus::Trusted,
|
||||
HookTrustStatus::Trusted,
|
||||
]
|
||||
);
|
||||
match rx.try_recv().expect("trust event") {
|
||||
AppEvent::TrustHooks { updates } => assert_eq!(
|
||||
updates,
|
||||
vec![
|
||||
HookTrustUpdate {
|
||||
key: "path:untrusted".to_string(),
|
||||
current_hash: "sha256:current".to_string(),
|
||||
},
|
||||
HookTrustUpdate {
|
||||
key: "path:modified".to_string(),
|
||||
current_hash: "sha256:current".to_string(),
|
||||
},
|
||||
]
|
||||
),
|
||||
other => panic!("expected hook trust event, got {other:?}"),
|
||||
}
|
||||
assert!(rx.try_recv().is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn escape_returns_to_the_selected_event() {
|
||||
let mut view = view();
|
||||
|
||||
@@ -31,7 +31,7 @@ use crate::render::renderable::Renderable;
|
||||
use crate::render::renderable::RenderableItem;
|
||||
use crate::tui::FrameRequester;
|
||||
pub(crate) use bottom_pane_view::BottomPaneView;
|
||||
use bottom_pane_view::ViewCompletion;
|
||||
pub(crate) use bottom_pane_view::ViewCompletion;
|
||||
use codex_app_server_protocol::ToolRequestUserInputParams;
|
||||
use codex_core_skills::model::SkillMetadata;
|
||||
use codex_features::Features;
|
||||
@@ -104,7 +104,6 @@ pub(crate) use footer::GoalStatusIndicator;
|
||||
#[cfg(test)]
|
||||
pub(crate) use footer::goal_status_indicator_line;
|
||||
pub(crate) use list_selection_view::ColumnWidthMode;
|
||||
#[cfg(test)]
|
||||
pub(crate) use list_selection_view::ListSelectionView;
|
||||
pub(crate) use list_selection_view::SelectionRowDisplay;
|
||||
pub(crate) use list_selection_view::SelectionToggle;
|
||||
|
||||
+3
-1
@@ -6,6 +6,8 @@ expression: "render_lines(&view, 112)"
|
||||
Hooks
|
||||
Lifecycle hooks from config and enabled plugins.
|
||||
|
||||
⚠ 1 hook needs review before it can run.
|
||||
|
||||
Event Installed Active Review Description
|
||||
PreToolUse 1 0 1 Before a tool executes
|
||||
PermissionRequest 0 0 0 When permission is requested
|
||||
@@ -16,4 +18,4 @@ expression: "render_lines(&view, 112)"
|
||||
UserPromptSubmit 0 0 0 When the user submits a prompt
|
||||
Stop 0 0 0 Right before Codex ends its turn
|
||||
|
||||
Press enter to view hooks; esc to close
|
||||
Press t to trust all; enter to review hooks; esc to close
|
||||
Reference in new issue
Block a user