dedrisian-oai
2025-10-08 14:32:54 -07:00
committed by GitHub
parent d3820f4782
commit c89229db97
23 changed files with 39 additions and 56 deletions

View File

@@ -149,7 +149,7 @@ impl ChatComposer {
paste_burst: PasteBurst::default(), paste_burst: PasteBurst::default(),
disable_paste_burst: false, disable_paste_burst: false,
custom_prompts: Vec::new(), custom_prompts: Vec::new(),
footer_mode: FooterMode::ShortcutPrompt, footer_mode: FooterMode::ShortcutSummary,
footer_hint_override: None, footer_hint_override: None,
context_window_percent: None, context_window_percent: None,
}; };
@@ -1345,8 +1345,8 @@ impl ChatComposer {
FooterMode::EscHint => FooterMode::EscHint, FooterMode::EscHint => FooterMode::EscHint,
FooterMode::ShortcutOverlay => FooterMode::ShortcutOverlay, FooterMode::ShortcutOverlay => FooterMode::ShortcutOverlay,
FooterMode::CtrlCReminder => FooterMode::CtrlCReminder, FooterMode::CtrlCReminder => FooterMode::CtrlCReminder,
FooterMode::ShortcutPrompt if self.ctrl_c_quit_hint => FooterMode::CtrlCReminder, FooterMode::ShortcutSummary if self.ctrl_c_quit_hint => FooterMode::CtrlCReminder,
FooterMode::ShortcutPrompt if !self.is_empty() => FooterMode::Empty, FooterMode::ShortcutSummary if !self.is_empty() => FooterMode::ContextOnly,
other => other, other => other,
} }
} }
@@ -1779,11 +1779,11 @@ mod tests {
// Toggle back to prompt mode so subsequent typing captures characters. // Toggle back to prompt mode so subsequent typing captures characters.
let _ = composer.handle_key_event(KeyEvent::new(KeyCode::Char('?'), KeyModifiers::NONE)); let _ = composer.handle_key_event(KeyEvent::new(KeyCode::Char('?'), KeyModifiers::NONE));
assert_eq!(composer.footer_mode, FooterMode::ShortcutPrompt); assert_eq!(composer.footer_mode, FooterMode::ShortcutSummary);
type_chars_humanlike(&mut composer, &['h']); type_chars_humanlike(&mut composer, &['h']);
assert_eq!(composer.textarea.text(), "h"); assert_eq!(composer.textarea.text(), "h");
assert_eq!(composer.footer_mode(), FooterMode::Empty); assert_eq!(composer.footer_mode(), FooterMode::ContextOnly);
let (result, needs_redraw) = let (result, needs_redraw) =
composer.handle_key_event(KeyEvent::new(KeyCode::Char('?'), KeyModifiers::NONE)); composer.handle_key_event(KeyEvent::new(KeyCode::Char('?'), KeyModifiers::NONE));
@@ -1792,8 +1792,8 @@ mod tests {
std::thread::sleep(ChatComposer::recommended_paste_flush_delay()); std::thread::sleep(ChatComposer::recommended_paste_flush_delay());
let _ = composer.flush_paste_burst_if_due(); let _ = composer.flush_paste_burst_if_due();
assert_eq!(composer.textarea.text(), "h?"); assert_eq!(composer.textarea.text(), "h?");
assert_eq!(composer.footer_mode, FooterMode::ShortcutPrompt); assert_eq!(composer.footer_mode, FooterMode::ShortcutSummary);
assert_eq!(composer.footer_mode(), FooterMode::Empty); assert_eq!(composer.footer_mode(), FooterMode::ContextOnly);
} }
#[test] #[test]

View File

@@ -23,10 +23,10 @@ pub(crate) struct FooterProps {
#[derive(Clone, Copy, Debug, Eq, PartialEq)] #[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub(crate) enum FooterMode { pub(crate) enum FooterMode {
CtrlCReminder, CtrlCReminder,
ShortcutPrompt, ShortcutSummary,
ShortcutOverlay, ShortcutOverlay,
EscHint, EscHint,
Empty, ContextOnly,
} }
pub(crate) fn toggle_shortcut_mode(current: FooterMode, ctrl_c_hint: bool) -> FooterMode { 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
} }
match current { match current {
FooterMode::ShortcutOverlay | FooterMode::CtrlCReminder => FooterMode::ShortcutPrompt, FooterMode::ShortcutOverlay | FooterMode::CtrlCReminder => FooterMode::ShortcutSummary,
_ => FooterMode::ShortcutOverlay, _ => FooterMode::ShortcutOverlay,
} }
} }
@@ -53,7 +53,7 @@ pub(crate) fn reset_mode_after_activity(current: FooterMode) -> FooterMode {
FooterMode::EscHint FooterMode::EscHint
| FooterMode::ShortcutOverlay | FooterMode::ShortcutOverlay
| FooterMode::CtrlCReminder | FooterMode::CtrlCReminder
| FooterMode::Empty => FooterMode::ShortcutPrompt, | FooterMode::ContextOnly => FooterMode::ShortcutSummary,
other => other, other => other,
} }
} }
@@ -72,26 +72,29 @@ pub(crate) fn render_footer(area: Rect, buf: &mut Buffer, props: FooterProps) {
} }
fn footer_lines(props: FooterProps) -> Vec<Line<'static>> { fn footer_lines(props: FooterProps) -> Vec<Line<'static>> {
// Show the context indicator on the left, appended after the primary hint
// (e.g., "? for shortcuts"). Keep it visible even when typing (i.e., when
// the shortcut hint is hidden). Hide it only for the multi-line
// ShortcutOverlay.
match props.mode { match props.mode {
FooterMode::CtrlCReminder => vec![ctrl_c_reminder_line(CtrlCReminderState { FooterMode::CtrlCReminder => vec![ctrl_c_reminder_line(CtrlCReminderState {
is_task_running: props.is_task_running, is_task_running: props.is_task_running,
})], })],
FooterMode::ShortcutPrompt => { FooterMode::ShortcutSummary => {
if props.is_task_running { let mut line = context_window_line(props.context_window_percent);
vec![context_window_line(props.context_window_percent)] line.push_span(" · ".dim());
} else { line.extend(vec![
vec![Line::from(vec![ key_hint::plain(KeyCode::Char('?')).into(),
key_hint::plain(KeyCode::Char('?')).into(), " for shortcuts".dim(),
" for shortcuts".dim(), ]);
])] vec![line]
}
} }
FooterMode::ShortcutOverlay => shortcut_overlay_lines(ShortcutsState { FooterMode::ShortcutOverlay => shortcut_overlay_lines(ShortcutsState {
use_shift_enter_hint: props.use_shift_enter_hint, use_shift_enter_hint: props.use_shift_enter_hint,
esc_backtrack_hint: props.esc_backtrack_hint, esc_backtrack_hint: props.esc_backtrack_hint,
}), }),
FooterMode::EscHint => vec![esc_hint_line(props.esc_backtrack_hint)], FooterMode::EscHint => vec![esc_hint_line(props.esc_backtrack_hint)],
FooterMode::Empty => Vec::new(), FooterMode::ContextOnly => vec![context_window_line(props.context_window_percent)],
} }
} }
@@ -219,18 +222,8 @@ fn build_columns(entries: Vec<Line<'static>>) -> Vec<Line<'static>> {
} }
fn context_window_line(percent: Option<u8>) -> Line<'static> { fn context_window_line(percent: Option<u8>) -> Line<'static> {
let mut spans: Vec<Span<'static>> = Vec::new(); let percent = percent.unwrap_or(100);
match percent { Line::from(vec![Span::from(format!("{percent}% context left")).dim()])
Some(percent) => {
spans.push(format!("{percent}%").dim());
spans.push(" context left".dim());
}
None => {
spans.push(key_hint::plain(KeyCode::Char('?')).into());
spans.push(" for shortcuts".dim());
}
}
Line::from(spans)
} }
#[derive(Clone, Copy, Debug, Eq, PartialEq)] #[derive(Clone, Copy, Debug, Eq, PartialEq)]
@@ -402,7 +395,7 @@ mod tests {
snapshot_footer( snapshot_footer(
"footer_shortcuts_default", "footer_shortcuts_default",
FooterProps { FooterProps {
mode: FooterMode::ShortcutPrompt, mode: FooterMode::ShortcutSummary,
esc_backtrack_hint: false, esc_backtrack_hint: false,
use_shift_enter_hint: false, use_shift_enter_hint: false,
is_task_running: false, is_task_running: false,
@@ -468,7 +461,7 @@ mod tests {
snapshot_footer( snapshot_footer(
"footer_shortcuts_context_running", "footer_shortcuts_context_running",
FooterProps { FooterProps {
mode: FooterMode::ShortcutPrompt, mode: FooterMode::ShortcutSummary,
esc_backtrack_hint: false, esc_backtrack_hint: false,
use_shift_enter_hint: false, use_shift_enter_hint: false,
is_task_running: true, is_task_running: true,

View File

@@ -11,4 +11,4 @@ expression: terminal.backend()
" " " "
" " " "
" " " "
" " " 100% context left "

View File

@@ -1,6 +1,5 @@
--- ---
source: tui/src/bottom_pane/chat_composer.rs source: tui/src/bottom_pane/chat_composer.rs
assertion_line: 1938
expression: terminal.backend() expression: terminal.backend()
--- ---
" " " "
@@ -12,4 +11,4 @@ expression: terminal.backend()
" " " "
" " " "
" " " "
" ? for shortcuts " " 100% context left · ? for shortcuts "

View File

@@ -1,6 +1,5 @@
--- ---
source: tui/src/bottom_pane/chat_composer.rs source: tui/src/bottom_pane/chat_composer.rs
assertion_line: 1497
expression: terminal.backend() expression: terminal.backend()
--- ---
" " " "

View File

@@ -1,6 +1,5 @@
--- ---
source: tui/src/bottom_pane/chat_composer.rs source: tui/src/bottom_pane/chat_composer.rs
assertion_line: 1497
expression: terminal.backend() expression: terminal.backend()
--- ---
" " " "

View File

@@ -1,6 +1,5 @@
--- ---
source: tui/src/bottom_pane/chat_composer.rs source: tui/src/bottom_pane/chat_composer.rs
assertion_line: 1497
expression: terminal.backend() expression: terminal.backend()
--- ---
" " " "

View File

@@ -1,6 +1,5 @@
--- ---
source: tui/src/bottom_pane/chat_composer.rs source: tui/src/bottom_pane/chat_composer.rs
assertion_line: 1497
expression: terminal.backend() expression: terminal.backend()
--- ---
" " " "

View File

@@ -1,6 +1,5 @@
--- ---
source: tui/src/bottom_pane/chat_composer.rs source: tui/src/bottom_pane/chat_composer.rs
assertion_line: 1497
expression: terminal.backend() expression: terminal.backend()
--- ---
" " " "

View File

@@ -10,3 +10,4 @@ expression: terminal.backend()
" " " "
" " " "
" " " "
" 100% context left "

View File

@@ -1,6 +1,5 @@
--- ---
source: tui/src/bottom_pane/chat_composer.rs source: tui/src/bottom_pane/chat_composer.rs
assertion_line: 1497
expression: terminal.backend() expression: terminal.backend()
--- ---
" " " "

View File

@@ -11,4 +11,4 @@ expression: terminal.backend()
" " " "
" " " "
" " " "
" " " 100% context left "

View File

@@ -11,4 +11,4 @@ expression: terminal.backend()
" " " "
" " " "
" " " "
" " " 100% context left "

View File

@@ -11,4 +11,4 @@ expression: terminal.backend()
" " " "
" " " "
" " " "
" " " 100% context left "

View File

@@ -1,6 +1,5 @@
--- ---
source: tui/src/bottom_pane/footer.rs source: tui/src/bottom_pane/footer.rs
assertion_line: 389
expression: terminal.backend() expression: terminal.backend()
--- ---
" ctrl + c again to quit " " ctrl + c again to quit "

View File

@@ -1,6 +1,5 @@
--- ---
source: tui/src/bottom_pane/footer.rs source: tui/src/bottom_pane/footer.rs
assertion_line: 389
expression: terminal.backend() expression: terminal.backend()
--- ---
" ctrl + c again to interrupt " " ctrl + c again to interrupt "

View File

@@ -1,6 +1,5 @@
--- ---
source: tui/src/bottom_pane/footer.rs source: tui/src/bottom_pane/footer.rs
assertion_line: 389
expression: terminal.backend() expression: terminal.backend()
--- ---
" esc esc to edit previous message " " esc esc to edit previous message "

View File

@@ -1,6 +1,5 @@
--- ---
source: tui/src/bottom_pane/footer.rs source: tui/src/bottom_pane/footer.rs
assertion_line: 389
expression: terminal.backend() expression: terminal.backend()
--- ---
" esc again to edit previous message " " esc again to edit previous message "

View File

@@ -2,4 +2,4 @@
source: tui/src/bottom_pane/footer.rs source: tui/src/bottom_pane/footer.rs
expression: terminal.backend() expression: terminal.backend()
--- ---
" 72% context left " " 72% context left · ? for shortcuts "

View File

@@ -1,6 +1,5 @@
--- ---
source: tui/src/bottom_pane/footer.rs source: tui/src/bottom_pane/footer.rs
assertion_line: 389
expression: terminal.backend() expression: terminal.backend()
--- ---
" ? for shortcuts " " 100% context left · ? for shortcuts "

View File

@@ -8,4 +8,4 @@ expression: "render_snapshot(&pane, area)"
Ask Codex to do anything Ask Codex to do anything
? for shortcuts 100% context left · ? for sh

View File

@@ -13,3 +13,4 @@ expression: term.backend().vt100().screen().contents()
Summarize recent commits Summarize recent commits
100% context left

View File

@@ -9,4 +9,4 @@ expression: terminal.backend()
" " " "
" Ask Codex to do anything " " Ask Codex to do anything "
" " " "
" ? for shortcuts " " 100% context left · ? for shortcuts "