Skip to content

Commit 98aa544

Browse files
committed
Sync footer note and input enabled plumbing
1 parent e74520c commit 98aa544

File tree

4 files changed

+68
-4
lines changed

4 files changed

+68
-4
lines changed

codex-rs/tui/src/bottom_pane/chat_composer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1881,7 +1881,7 @@ impl ChatComposer {
18811881
self.has_focus = has_focus;
18821882
}
18831883

1884-
#[cfg_attr(not(target_os = "windows"), allow(dead_code))]
1884+
#[allow(dead_code)]
18851885
pub(crate) fn set_input_enabled(&mut self, enabled: bool, placeholder: Option<String>) {
18861886
self.input_enabled = enabled;
18871887
self.input_disabled_placeholder = if enabled { None } else { placeholder };

codex-rs/tui/src/bottom_pane/list_selection_view.rs

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ use ratatui::widgets::Block;
1313
use ratatui::widgets::Paragraph;
1414
use ratatui::widgets::Widget;
1515

16+
use super::selection_popup_common::wrap_styled_line;
1617
use crate::app_event_sender::AppEventSender;
1718
use crate::key_hint::KeyBinding;
1819
use crate::render::Insets;
1920
use crate::render::RectExt as _;
2021
use crate::render::renderable::ColumnRenderable;
2122
use crate::render::renderable::Renderable;
2223
use crate::style::user_message_style;
23-
use super::selection_popup_common::wrap_styled_line;
2424

2525
use super::CancellationEvent;
2626
use super::bottom_pane_view::BottomPaneView;
@@ -654,6 +654,38 @@ mod tests {
654654
assert_snapshot!("list_selection_spacing_with_subtitle", render_lines(&view));
655655
}
656656

657+
#[test]
658+
fn snapshot_footer_note_wraps() {
659+
let (tx_raw, _rx) = unbounded_channel::<AppEvent>();
660+
let tx = AppEventSender::new(tx_raw);
661+
let items = vec![SelectionItem {
662+
name: "Read Only".to_string(),
663+
description: Some("Codex can read files".to_string()),
664+
is_current: true,
665+
dismiss_on_select: true,
666+
..Default::default()
667+
}];
668+
let footer_note = Line::from(vec![
669+
"Note: ".dim(),
670+
"Use /setup-elevated-sandbox".cyan(),
671+
" to allow network access.".dim(),
672+
]);
673+
let view = ListSelectionView::new(
674+
SelectionViewParams {
675+
title: Some("Select Approval Mode".to_string()),
676+
footer_note: Some(footer_note),
677+
footer_hint: Some(standard_popup_hint_line()),
678+
items,
679+
..Default::default()
680+
},
681+
tx,
682+
);
683+
assert_snapshot!(
684+
"list_selection_footer_note_wraps",
685+
render_lines_with_width(&view, 40)
686+
);
687+
}
688+
657689
#[test]
658690
fn renders_search_query_line_when_enabled() {
659691
let (tx_raw, _rx) = unbounded_channel::<AppEvent>();

codex-rs/tui2/src/bottom_pane/chat_composer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1833,7 +1833,7 @@ impl ChatComposer {
18331833
self.has_focus = has_focus;
18341834
}
18351835

1836-
#[cfg_attr(not(target_os = "windows"), allow(dead_code))]
1836+
#[allow(dead_code)]
18371837
pub(crate) fn set_input_enabled(&mut self, enabled: bool, placeholder: Option<String>) {
18381838
self.input_enabled = enabled;
18391839
self.input_disabled_placeholder = if enabled { None } else { placeholder };

codex-rs/tui2/src/bottom_pane/list_selection_view.rs

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ use ratatui::widgets::Block;
1313
use ratatui::widgets::Paragraph;
1414
use ratatui::widgets::Widget;
1515

16+
use super::selection_popup_common::wrap_styled_line;
1617
use crate::app_event_sender::AppEventSender;
1718
use crate::key_hint::KeyBinding;
1819
use crate::render::Insets;
1920
use crate::render::RectExt as _;
2021
use crate::render::renderable::ColumnRenderable;
2122
use crate::render::renderable::Renderable;
2223
use crate::style::user_message_style;
23-
use super::selection_popup_common::wrap_styled_line;
2424

2525
use super::CancellationEvent;
2626
use super::bottom_pane_view::BottomPaneView;
@@ -611,6 +611,38 @@ mod tests {
611611
assert_snapshot!("list_selection_spacing_with_subtitle", render_lines(&view));
612612
}
613613

614+
#[test]
615+
fn snapshot_footer_note_wraps() {
616+
let (tx_raw, _rx) = unbounded_channel::<AppEvent>();
617+
let tx = AppEventSender::new(tx_raw);
618+
let items = vec![SelectionItem {
619+
name: "Read Only".to_string(),
620+
description: Some("Codex can read files".to_string()),
621+
is_current: true,
622+
dismiss_on_select: true,
623+
..Default::default()
624+
}];
625+
let footer_note = Line::from(vec![
626+
"Note: ".dim(),
627+
"Use /setup-elevated-sandbox".cyan(),
628+
" to allow network access.".dim(),
629+
]);
630+
let view = ListSelectionView::new(
631+
SelectionViewParams {
632+
title: Some("Select Approval Mode".to_string()),
633+
footer_note: Some(footer_note),
634+
footer_hint: Some(standard_popup_hint_line()),
635+
items,
636+
..Default::default()
637+
},
638+
tx,
639+
);
640+
assert_snapshot!(
641+
"list_selection_footer_note_wraps",
642+
render_lines_with_width(&view, 40)
643+
);
644+
}
645+
614646
#[test]
615647
fn renders_search_query_line_when_enabled() {
616648
let (tx_raw, _rx) = unbounded_channel::<AppEvent>();

0 commit comments

Comments
 (0)