GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Let users open the command center from provider error screens (#62335) · openai/codex@58ad62c

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • codex-rs/tui/src
    • app.rs
    • app
      • input.rs
      • tests
        • agents_navigation_tests.rs
    • chatwidget
      • provider_error.rs
      • read_only.rs
      • rendering.rs
      • snapshots
        • codex_tui__chatwidget__rendering__tests__provider_errors.snap
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎codex-rs/tui/src/app.rs‎

Copy file name to clipboardExpand all lines: codex-rs/tui/src/app.rs
+5-4Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,10 +1294,11 @@ impl App {
12941294
{
12951295
if self.overlay.is_none()
12961296
&& 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))
13011302
{
13021303
self.open_agents_overview(app_server);
13031304
} else if self
Collapse file

‎codex-rs/tui/src/app/input.rs‎

Copy file name to clipboardExpand all lines: codex-rs/tui/src/app/input.rs
+8-9Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -708,18 +708,17 @@ impl App {
708708
return;
709709
}
710710

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)
719715
{
720716
self.open_agents_overview(app_server);
717+
return;
718+
}
719+
if self.chat_widget.is_read_only_view() {
720+
return;
721721
}
722-
return;
723722
}
724723

725724
if self.should_handle_unavailable_thread_key(key_event) {
Collapse file

‎codex-rs/tui/src/app/tests/agents_navigation_tests.rs‎

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 numberDiff line numberDiff line change
@@ -133,6 +133,51 @@ async fn externally_archived_thread_keeps_advertised_agents_navigation() -> Resu
133133
Ok(())
134134
}
135135

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+
136181
#[tokio::test]
137182
async fn pending_windows_sandbox_setup_blocks_thread_replacement() -> Result<()> {
138183
use crate::app_event::WindowsSandboxEnableMode;
Collapse file

‎codex-rs/tui/src/chatwidget/provider_error.rs‎

Copy file name to clipboardExpand all lines: codex-rs/tui/src/chatwidget/provider_error.rs
-77Lines changed: 0 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,7 @@
11
//! Provider admission failures keep history readable and drafts recoverable.
22
33
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;
84
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-
}
825

836
impl ChatWidget {
847
pub(super) fn provider_error_message(&self, error: &ModelProviderError) -> String {
Collapse file

‎codex-rs/tui/src/chatwidget/read_only.rs‎

Copy file name to clipboardExpand all lines: codex-rs/tui/src/chatwidget/read_only.rs
+28Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
//! Frozen transcript views preserve drafts while their live attachment is unavailable.
22
33
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+
}
412

513
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
614
pub(crate) enum ReadOnlyThread {
@@ -25,6 +33,26 @@ impl ReadOnlyThread {
2533
}
2634

2735
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+
2856
pub(crate) fn show_external_writer_thread(&mut self) {
2957
self.show_read_only_thread(ReadOnlyThread::ExternalWriter);
3058
}

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.