From 3511908812e5b8a51db5b9a4d9186dde91c9338a Mon Sep 17 00:00:00 2001 From: canvrno-oai Date: Fri, 29 May 2026 11:21:07 -0700 Subject: [PATCH] address feedback --- codex-rs/tui/src/app/tests.rs | 33 ++++++++++--------- codex-rs/tui/src/app/thread_routing.rs | 21 ++++-------- ...warnings_emit_once_until_errors_clear.snap | 7 ++++ 3 files changed, 30 insertions(+), 31 deletions(-) create mode 100644 codex-rs/tui/src/snapshots/codex_tui__app__tests__repeated_skill_load_warnings_emit_once_until_errors_clear.snap diff --git a/codex-rs/tui/src/app/tests.rs b/codex-rs/tui/src/app/tests.rs index 0fd7e76c23..55132cb7ac 100644 --- a/codex-rs/tui/src/app/tests.rs +++ b/codex-rs/tui/src/app/tests.rs @@ -2301,12 +2301,16 @@ async fn repeated_skill_load_warnings_emit_once_until_errors_clear() { app.handle_skills_list_response(response.clone()); app.handle_skills_list_response(response.clone()); - assert_eq!( - drain_insert_history_transcripts(&mut app_event_rx), - vec![ - "⚠ Skipped loading 1 skill(s) due to invalid SKILL.md files.".to_string(), - format!("⚠ {expected_path}: invalid YAML"), - ], + let warnings = drain_insert_history_cells(&mut app_event_rx); + assert_eq!(warnings.len(), 2); + app.transcript_cells.extend(warnings); + let rendered = lines_to_single_string(&crate::terminal_hyperlinks::visible_lines( + app.render_transcript_lines_for_reflow(/*width*/ 80).lines, + )) + .replace(&expected_path, "/tmp/user/skills/planning/SKILL.md"); + assert_app_snapshot!( + "repeated_skill_load_warnings_emit_once_until_errors_clear", + rendered, ); app.handle_skills_list_response(codex_app_server_protocol::SkillsListResponse { @@ -2316,25 +2320,22 @@ async fn repeated_skill_load_warnings_emit_once_until_errors_clear() { errors: Vec::new(), }], }); - assert_eq!( - drain_insert_history_transcripts(&mut app_event_rx), - Vec::::new(), - ); + assert!(drain_insert_history_cells(&mut app_event_rx).is_empty()); app.handle_skills_list_response(response); - assert_eq!(drain_insert_history_transcripts(&mut app_event_rx).len(), 2); + assert_eq!(drain_insert_history_cells(&mut app_event_rx).len(), 2); } -fn drain_insert_history_transcripts( +fn drain_insert_history_cells( app_event_rx: &mut tokio::sync::mpsc::UnboundedReceiver, -) -> Vec { - let mut transcripts = Vec::new(); +) -> Vec> { + let mut cells = Vec::new(); while let Ok(event) = app_event_rx.try_recv() { if let AppEvent::InsertHistoryCell(cell) = event { - transcripts.push(lines_to_single_string(&cell.transcript_lines(/*width*/ 80))); + cells.push(cell.into()); } } - transcripts + cells } #[tokio::test] diff --git a/codex-rs/tui/src/app/thread_routing.rs b/codex-rs/tui/src/app/thread_routing.rs index 1b58df2fed..8fbb7f4fca 100644 --- a/codex-rs/tui/src/app/thread_routing.rs +++ b/codex-rs/tui/src/app/thread_routing.rs @@ -1341,27 +1341,18 @@ impl App { pub(super) fn handle_skills_list_response(&mut self, response: SkillsListResponse) { let cwd = self.chat_widget.config_ref().cwd.clone(); let errors = errors_for_cwd(&cwd, &response); - self.emit_skill_load_warnings_if_changed(&cwd, errors); - self.chat_widget.handle_skills_list_response(response); - } - - fn emit_skill_load_warnings_if_changed(&mut self, cwd: &Path, errors: Vec) { if errors.is_empty() { - self.skill_load_warnings_by_cwd.remove(cwd); - return; - } - - if self + self.skill_load_warnings_by_cwd.remove(&cwd); + } else if !self .skill_load_warnings_by_cwd - .get(cwd) + .get(&cwd) .is_some_and(|previous_errors| previous_errors == &errors) { - return; + emit_skill_load_warnings(&self.app_event_tx, &errors); + self.skill_load_warnings_by_cwd.insert(cwd, errors); } - emit_skill_load_warnings(&self.app_event_tx, &errors); - self.skill_load_warnings_by_cwd - .insert(cwd.to_path_buf(), errors); + self.chat_widget.handle_skills_list_response(response); } pub(super) async fn handle_thread_rollback_response( diff --git a/codex-rs/tui/src/snapshots/codex_tui__app__tests__repeated_skill_load_warnings_emit_once_until_errors_clear.snap b/codex-rs/tui/src/snapshots/codex_tui__app__tests__repeated_skill_load_warnings_emit_once_until_errors_clear.snap new file mode 100644 index 0000000000..677f2ea2db --- /dev/null +++ b/codex-rs/tui/src/snapshots/codex_tui__app__tests__repeated_skill_load_warnings_emit_once_until_errors_clear.snap @@ -0,0 +1,7 @@ +--- +source: tui/src/app/tests.rs +expression: rendered +--- +⚠ Skipped loading 1 skill(s) due to invalid SKILL.md files. + +⚠ /tmp/user/skills/planning/SKILL.md: invalid YAML