Skip to content

Commit c89229d

Browse files
1 parent d3820f4 commit c89229d

File tree

23 files changed

+39
-56
lines changed

23 files changed

+39
-56
lines changed

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ impl ChatComposer {
149149
paste_burst: PasteBurst::default(),
150150
disable_paste_burst: false,
151151
custom_prompts: Vec::new(),
152-
footer_mode: FooterMode::ShortcutPrompt,
152+
footer_mode: FooterMode::ShortcutSummary,
153153
footer_hint_override: None,
154154
context_window_percent: None,
155155
};
@@ -1345,8 +1345,8 @@ impl ChatComposer {
13451345
FooterMode::EscHint => FooterMode::EscHint,
13461346
FooterMode::ShortcutOverlay => FooterMode::ShortcutOverlay,
13471347
FooterMode::CtrlCReminder => FooterMode::CtrlCReminder,
1348-
FooterMode::ShortcutPrompt if self.ctrl_c_quit_hint => FooterMode::CtrlCReminder,
1349-
FooterMode::ShortcutPrompt if !self.is_empty() => FooterMode::Empty,
1348+
FooterMode::ShortcutSummary if self.ctrl_c_quit_hint => FooterMode::CtrlCReminder,
1349+
FooterMode::ShortcutSummary if !self.is_empty() => FooterMode::ContextOnly,
13501350
other => other,
13511351
}
13521352
}
@@ -1779,11 +1779,11 @@ mod tests {
17791779

17801780
// Toggle back to prompt mode so subsequent typing captures characters.
17811781
let _ = composer.handle_key_event(KeyEvent::new(KeyCode::Char('?'), KeyModifiers::NONE));
1782-
assert_eq!(composer.footer_mode, FooterMode::ShortcutPrompt);
1782+
assert_eq!(composer.footer_mode, FooterMode::ShortcutSummary);
17831783

17841784
type_chars_humanlike(&mut composer, &['h']);
17851785
assert_eq!(composer.textarea.text(), "h");
1786-
assert_eq!(composer.footer_mode(), FooterMode::Empty);
1786+
assert_eq!(composer.footer_mode(), FooterMode::ContextOnly);
17871787

17881788
let (result, needs_redraw) =
17891789
composer.handle_key_event(KeyEvent::new(KeyCode::Char('?'), KeyModifiers::NONE));
@@ -1792,8 +1792,8 @@ mod tests {
17921792
std::thread::sleep(ChatComposer::recommended_paste_flush_delay());
17931793
let _ = composer.flush_paste_burst_if_due();
17941794
assert_eq!(composer.textarea.text(), "h?");
1795-
assert_eq!(composer.footer_mode, FooterMode::ShortcutPrompt);
1796-
assert_eq!(composer.footer_mode(), FooterMode::Empty);
1795+
assert_eq!(composer.footer_mode, FooterMode::ShortcutSummary);
1796+
assert_eq!(composer.footer_mode(), FooterMode::ContextOnly);
17971797
}
17981798

17991799
#[test]

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

Lines changed: 21 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ pub(crate) struct FooterProps {
2323
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
2424
pub(crate) enum FooterMode {
2525
CtrlCReminder,
26-
ShortcutPrompt,
26+
ShortcutSummary,
2727
ShortcutOverlay,
2828
EscHint,
29-
Empty,
29+
ContextOnly,
3030
}
3131

3232
pub(crate) fn toggle_shortcut_mode(current: FooterMode, ctrl_c_hint: bool) -> FooterMode {
@@ -35,7 +35,7 @@ pub(crate) fn toggle_shortcut_mode(current: FooterMode, ctrl_c_hint: bool) -> Fo
3535
}
3636

3737
match current {
38-
FooterMode::ShortcutOverlay | FooterMode::CtrlCReminder => FooterMode::ShortcutPrompt,
38+
FooterMode::ShortcutOverlay | FooterMode::CtrlCReminder => FooterMode::ShortcutSummary,
3939
_ => FooterMode::ShortcutOverlay,
4040
}
4141
}
@@ -53,7 +53,7 @@ pub(crate) fn reset_mode_after_activity(current: FooterMode) -> FooterMode {
5353
FooterMode::EscHint
5454
| FooterMode::ShortcutOverlay
5555
| FooterMode::CtrlCReminder
56-
| FooterMode::Empty => FooterMode::ShortcutPrompt,
56+
| FooterMode::ContextOnly => FooterMode::ShortcutSummary,
5757
other => other,
5858
}
5959
}
@@ -72,26 +72,29 @@ pub(crate) fn render_footer(area: Rect, buf: &mut Buffer, props: FooterProps) {
7272
}
7373

7474
fn footer_lines(props: FooterProps) -> Vec<Line<'static>> {
75+
// Show the context indicator on the left, appended after the primary hint
76+
// (e.g., "? for shortcuts"). Keep it visible even when typing (i.e., when
77+
// the shortcut hint is hidden). Hide it only for the multi-line
78+
// ShortcutOverlay.
7579
match props.mode {
7680
FooterMode::CtrlCReminder => vec![ctrl_c_reminder_line(CtrlCReminderState {
7781
is_task_running: props.is_task_running,
7882
})],
79-
FooterMode::ShortcutPrompt => {
80-
if props.is_task_running {
81-
vec![context_window_line(props.context_window_percent)]
82-
} else {
83-
vec![Line::from(vec![
84-
key_hint::plain(KeyCode::Char('?')).into(),
85-
" for shortcuts".dim(),
86-
])]
87-
}
83+
FooterMode::ShortcutSummary => {
84+
let mut line = context_window_line(props.context_window_percent);
85+
line.push_span(" · ".dim());
86+
line.extend(vec![
87+
key_hint::plain(KeyCode::Char('?')).into(),
88+
" for shortcuts".dim(),
89+
]);
90+
vec![line]
8891
}
8992
FooterMode::ShortcutOverlay => shortcut_overlay_lines(ShortcutsState {
9093
use_shift_enter_hint: props.use_shift_enter_hint,
9194
esc_backtrack_hint: props.esc_backtrack_hint,
9295
}),
9396
FooterMode::EscHint => vec![esc_hint_line(props.esc_backtrack_hint)],
94-
FooterMode::Empty => Vec::new(),
97+
FooterMode::ContextOnly => vec![context_window_line(props.context_window_percent)],
9598
}
9699
}
97100

@@ -219,18 +222,8 @@ fn build_columns(entries: Vec<Line<'static>>) -> Vec<Line<'static>> {
219222
}
220223

221224
fn context_window_line(percent: Option<u8>) -> Line<'static> {
222-
let mut spans: Vec<Span<'static>> = Vec::new();
223-
match percent {
224-
Some(percent) => {
225-
spans.push(format!("{percent}%").dim());
226-
spans.push(" context left".dim());
227-
}
228-
None => {
229-
spans.push(key_hint::plain(KeyCode::Char('?')).into());
230-
spans.push(" for shortcuts".dim());
231-
}
232-
}
233-
Line::from(spans)
225+
let percent = percent.unwrap_or(100);
226+
Line::from(vec![Span::from(format!("{percent}% context left")).dim()])
234227
}
235228

236229
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
@@ -402,7 +395,7 @@ mod tests {
402395
snapshot_footer(
403396
"footer_shortcuts_default",
404397
FooterProps {
405-
mode: FooterMode::ShortcutPrompt,
398+
mode: FooterMode::ShortcutSummary,
406399
esc_backtrack_hint: false,
407400
use_shift_enter_hint: false,
408401
is_task_running: false,
@@ -468,7 +461,7 @@ mod tests {
468461
snapshot_footer(
469462
"footer_shortcuts_context_running",
470463
FooterProps {
471-
mode: FooterMode::ShortcutPrompt,
464+
mode: FooterMode::ShortcutSummary,
472465
esc_backtrack_hint: false,
473466
use_shift_enter_hint: false,
474467
is_task_running: true,

codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__chat_composer__tests__backspace_after_pastes.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ expression: terminal.backend()
1111
" "
1212
" "
1313
" "
14-
" "
14+
" 100% context left "

codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__chat_composer__tests__empty.snap

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
---
22
source: tui/src/bottom_pane/chat_composer.rs
3-
assertion_line: 1938
43
expression: terminal.backend()
54
---
65
" "
@@ -12,4 +11,4 @@ expression: terminal.backend()
1211
" "
1312
" "
1413
" "
15-
" ? for shortcuts "
14+
" 100% context left · ? for shortcuts "

codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__chat_composer__tests__footer_mode_ctrl_c_interrupt.snap

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
---
22
source: tui/src/bottom_pane/chat_composer.rs
3-
assertion_line: 1497
43
expression: terminal.backend()
54
---
65
" "

codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__chat_composer__tests__footer_mode_ctrl_c_quit.snap

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
---
22
source: tui/src/bottom_pane/chat_composer.rs
3-
assertion_line: 1497
43
expression: terminal.backend()
54
---
65
" "

codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__chat_composer__tests__footer_mode_ctrl_c_then_esc_hint.snap

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
---
22
source: tui/src/bottom_pane/chat_composer.rs
3-
assertion_line: 1497
43
expression: terminal.backend()
54
---
65
" "

codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__chat_composer__tests__footer_mode_esc_hint_backtrack.snap

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
---
22
source: tui/src/bottom_pane/chat_composer.rs
3-
assertion_line: 1497
43
expression: terminal.backend()
54
---
65
" "

codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__chat_composer__tests__footer_mode_esc_hint_from_overlay.snap

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
---
22
source: tui/src/bottom_pane/chat_composer.rs
3-
assertion_line: 1497
43
expression: terminal.backend()
54
---
65
" "

codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__chat_composer__tests__footer_mode_hidden_while_typing.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ expression: terminal.backend()
1010
" "
1111
" "
1212
" "
13+
" 100% context left "

0 commit comments

Comments
 (0)