GeezerVison is showing github.com — Let users open the command center from provider error screens (#62335) · openai/codex@58ad62c
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: codex-rs/tui/src/app.rs +5-4Lines changed: 5 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1294,10 +1294,11 @@ impl App { | 1294 | 1294 | { | 1295 | 1295 | if self.overlay.is_none() | 1296 | 1296 | && self.chat_widget.no_modal_or_popup_active() | 1297 | | - && self.chat_widget.is_read_only_view() | 1298 | | - && (crate::key_hint::plain(KeyCode::Esc).is_press(*key) | 1299 | | - || (crate::key_hint::plain(KeyCode::Left).is_press(*key) | 1300 | | - && self.chat_widget.agents_navigation_key_available())) | | 1297 | + && ((self.chat_widget.is_read_only_view() | | 1298 | + && crate::key_hint::plain(KeyCode::Esc).is_press(*key)) | | 1299 | + || self | | 1300 | + .chat_widget | | 1301 | + .blocked_thread_command_center_key_pressed(*key)) | 1301 | 1302 | { | 1302 | 1303 | self.open_agents_overview(app_server); | 1303 | 1304 | } else if self | |
Collapse file Copy file name to clipboardExpand all lines: codex-rs/tui/src/app/input.rs +8-9Lines changed: 8 additions & 9 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -708,18 +708,17 @@ impl App { | 708 | 708 | return; | 709 | 709 | } | 710 | 710 |
| 711 | | - if self.chat_widget.is_read_only_view() | 712 | | - && self.overlay.is_none() | 713 | | - && self.chat_widget.no_modal_or_popup_active() | 714 | | - { | 715 | | - if key_event.kind == KeyEventKind::Press | 716 | | - && key_event.code == KeyCode::Left | 717 | | - && key_event.modifiers == KeyModifiers::NONE | 718 | | - && self.chat_widget.agents_navigation_key_available() | | 711 | + if self.overlay.is_none() && self.chat_widget.no_modal_or_popup_active() { | | 712 | + if self | | 713 | + .chat_widget | | 714 | + .blocked_thread_command_center_key_pressed(key_event) | 719 | 715 | { | 720 | 716 | self.open_agents_overview(app_server); | | 717 | + return; | | 718 | + } | | 719 | + if self.chat_widget.is_read_only_view() { | | 720 | + return; | 721 | 721 | } | 722 | | - return; | 723 | 722 | } | 724 | 723 |
| 725 | 724 | if self.should_handle_unavailable_thread_key(key_event) { | |
Collapse file Copy file name to clipboardExpand all lines: codex-rs/tui/src/app/tests/agents_navigation_tests.rs +45Lines changed: 45 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -133,6 +133,51 @@ async fn externally_archived_thread_keeps_advertised_agents_navigation() -> Resu | 133 | 133 | Ok(()) | 134 | 134 | } | 135 | 135 |
| | 136 | +#[tokio::test] | | 137 | +async fn provider_error_opens_command_center_with_left() -> Result<()> { | | 138 | + for offline in [false, true] { | | 139 | + let (mut app, _, _) = make_test_app_with_channels().await; | | 140 | + app.chat_widget.insert_str("Retained draft"); | | 141 | + app.chat_widget.show_provider_error( | | 142 | + codex_app_server_protocol::ModelProviderError::ModelProviderNotConfigured { | | 143 | + model_provider: "missing".into(), | | 144 | + }, | | 145 | + /*rejected_message_id*/ None, | | 146 | + ); | | 147 | + app.reconnect.offline = offline; | | 148 | + let mut app_server = start_config_write_test_app_server(&app).await?; | | 149 | + let mut tui = crate::tui::test_support::make_test_tui()?; | | 150 | + tui.set_owned_screen(/*owned*/ true)?; | | 151 | + assert!(render_bottom_popup(&app.chat_widget, /*width*/ 96).contains("← command center")); | | 152 | + | | 153 | + app.handle_tui_event( | | 154 | + &mut tui, | | 155 | + &mut app_server, | | 156 | + TuiEvent::Key(KeyEvent::new_with_kind( | | 157 | + KeyCode::Left, | | 158 | + KeyModifiers::NONE, | | 159 | + KeyEventKind::Repeat, | | 160 | + )), | | 161 | + ) | | 162 | + .await?; | | 163 | + assert!(app.chat_widget.no_modal_or_popup_active()); | | 164 | + app.handle_tui_event( | | 165 | + &mut tui, | | 166 | + &mut app_server, | | 167 | + TuiEvent::Key(KeyCode::Left.into()), | | 168 | + ) | | 169 | + .await?; | | 170 | + assert!(app.chat_widget.active_view_is(AGENTS_OVERVIEW_VIEW_ID)); | | 171 | + assert_eq!( | | 172 | + app.chat_widget.composer_text_with_pending(), | | 173 | + "Retained draft" | | 174 | + ); | | 175 | + tui.set_owned_screen(/*owned*/ false)?; | | 176 | + app_server.shutdown().await?; | | 177 | + } | | 178 | + Ok(()) | | 179 | +} | | 180 | + | 136 | 181 | #[tokio::test] | 137 | 182 | async fn pending_windows_sandbox_setup_blocks_thread_replacement() -> Result<()> { | 138 | 183 | use crate::app_event::WindowsSandboxEnableMode; | |
Collapse file Copy file name to clipboardExpand all lines: codex-rs/tui/src/chatwidget/provider_error.rs -77Lines changed: 0 additions & 77 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | //! Provider admission failures keep history readable and drafts recoverable. | 2 | 2 |
| 3 | 3 | use super::*; | 4 | | -use crate::render::renderable::ColumnRenderable; | 5 | | -use crate::wrapping::RtOptions; | 6 | | -use crate::wrapping::adaptive_wrap_lines; | 7 | | -use crate::wrapping::word_wrap_lines; | 8 | 4 | use codex_app_server_protocol::ModelProviderError; | 9 | | -use ratatui::widgets::Block; | 10 | | -use ratatui::widgets::Padding; | 11 | | - | 12 | | -pub(super) struct ProviderErrorNotice { | 13 | | - pub(super) title: &'static str, | 14 | | - pub(super) message: String, | 15 | | - pub(super) configuration_location: Option<String>, | 16 | | - pub(super) can_continue: bool, | 17 | | -} | 18 | | - | 19 | | -impl Renderable for ProviderErrorNotice { | 20 | | - fn render(&self, area: Rect, buf: &mut Buffer) { | 21 | | - self.as_renderable(area.width).render(area, buf); | 22 | | - } | 23 | | - | 24 | | - fn desired_height(&self, width: u16) -> u16 { | 25 | | - self.as_renderable(width).desired_height(width) | 26 | | - } | 27 | | -} | 28 | | - | 29 | | -impl ProviderErrorNotice { | 30 | | - fn as_renderable(&self, width: u16) -> ColumnRenderable<'_> { | 31 | | - let content_width = usize::from(width.saturating_sub(/*rhs*/ 4)); | 32 | | - let mut lines = word_wrap_lines( | 33 | | - &[Line::from(vec!["🔒 ".into(), self.title.bold()])], | 34 | | - content_width, | 35 | | - ); | 36 | | - let mut description = vec![Line::from(self.message.as_str().dim())]; | 37 | | - if let Some(location) = &self.configuration_location { | 38 | | - description.push(Line::from(location.as_str().dim())); | 39 | | - } | 40 | | - lines.extend(adaptive_wrap_lines( | 41 | | - &description, | 42 | | - RtOptions::new(content_width) | 43 | | - .initial_indent(" ".into()) | 44 | | - .subsequent_indent(" ".into()), | 45 | | - )); | 46 | | - let mut notice = ColumnRenderable::new(); | 47 | | - notice.push( | 48 | | - Paragraph::new(lines).block( | 49 | | - Block::default() | 50 | | - .style(crate::style::user_message_style()) | 51 | | - .padding(Padding::new( | 52 | | - /*left*/ 2, /*right*/ 2, /*top*/ 1, /*bottom*/ 1, | 53 | | - )), | 54 | | - ), | 55 | | - ); | 56 | | - let mut shortcuts = Vec::new(); | 57 | | - if self.can_continue { | 58 | | - shortcuts.extend([ | 59 | | - crate::key_hint::plain(KeyCode::Char('c')).into(), | 60 | | - " continue in new chat · ".into(), | 61 | | - ]); | 62 | | - } | 63 | | - shortcuts.extend([ | 64 | | - crate::key_hint::plain(KeyCode::Char('n')).into(), | 65 | | - " start fresh · ".into(), | 66 | | - crate::key_hint::plain(KeyCode::Esc).into(), | 67 | | - " other chats".into(), | 68 | | - ]); | 69 | | - let footer = Line::from(shortcuts).style(crate::style::secondary_text_style()); | 70 | | - notice.push( | 71 | | - Paragraph::new(word_wrap_lines( | 72 | | - &[footer], | 73 | | - usize::from(width.saturating_sub(/*rhs*/ 2)), | 74 | | - )) | 75 | | - .inset(Insets::tlbr( | 76 | | - /*top*/ 0, /*left*/ 2, /*bottom*/ 0, /*right*/ 0, | 77 | | - )), | 78 | | - ); | 79 | | - notice | 80 | | - } | 81 | | -} | 82 | 5 |
| 83 | 6 | impl ChatWidget { | 84 | 7 | pub(super) fn provider_error_message(&self, error: &ModelProviderError) -> String { | |
Collapse file Copy file name to clipboardExpand all lines: codex-rs/tui/src/chatwidget/read_only.rs +28Lines changed: 28 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | //! Frozen transcript views preserve drafts while their live attachment is unavailable. | 2 | 2 |
| 3 | 3 | use super::*; | | 4 | +use codex_app_server_protocol::ModelProviderError; | | 5 | + | | 6 | +/// The blocked transcript notice currently replacing the composer. | | 7 | +#[derive(Clone, Copy)] | | 8 | +pub(super) enum BlockedThreadView<'a> { | | 9 | + ProviderError(&'a ModelProviderError), | | 10 | + ReadOnly(ReadOnlyThread), | | 11 | +} | 4 | 12 |
| 5 | 13 | #[derive(Clone, Copy, Debug, PartialEq, Eq)] | 6 | 14 | pub(crate) enum ReadOnlyThread { | @@ -25,6 +33,26 @@ impl ReadOnlyThread { | 25 | 33 | } | 26 | 34 |
| 27 | 35 | impl ChatWidget { | | 36 | + pub(super) fn blocked_thread_view(&self) -> Option<BlockedThreadView<'_>> { | | 37 | + self.provider_error | | 38 | + .as_ref() | | 39 | + .map(BlockedThreadView::ProviderError) | | 40 | + .or_else(|| self.read_only_thread.map(BlockedThreadView::ReadOnly)) | | 41 | + } | | 42 | + | | 43 | + pub(super) fn blocked_thread_command_center_key(&self) -> Option<crate::key_hint::KeyBinding> { | | 44 | + self.blocked_thread_view()?; | | 45 | + self.agents_navigation_key_available() | | 46 | + .then(|| crate::key_hint::plain(KeyCode::Left)) | | 47 | + } | | 48 | + | | 49 | + pub(crate) fn blocked_thread_command_center_key_pressed(&self, key: KeyEvent) -> bool { | | 50 | + key.kind == KeyEventKind::Press | | 51 | + && self | | 52 | + .blocked_thread_command_center_key() | | 53 | + .is_some_and(|binding| binding.is_press(key)) | | 54 | + } | | 55 | + | 28 | 56 | pub(crate) fn show_external_writer_thread(&mut self) { | 29 | 57 | self.show_read_only_thread(ReadOnlyThread::ExternalWriter); | 30 | 58 | } | |
|