Skip to content

Commit ceaba36

Browse files
fix ctr-n hint (#4566)
don't show or enable ctr-n to choose best of n while not in the composer
1 parent d94e8ba commit ceaba36

File tree

2 files changed

+24
-13
lines changed

2 files changed

+24
-13
lines changed

codex-rs/cloud-tasks/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -839,6 +839,9 @@ pub async fn run_main(_cli: Cli, _codex_linux_sandbox_exe: Option<PathBuf>) -> a
839839
&& matches!(key.code, KeyCode::Char('n') | KeyCode::Char('N'))
840840
|| matches!(key.code, KeyCode::Char('\u{000E}'));
841841
if is_ctrl_n {
842+
if app.new_task.is_none() {
843+
continue;
844+
}
842845
if app.best_of_modal.is_some() {
843846
app.best_of_modal = None;
844847
needs_redraw = true;

codex-rs/cloud-tasks/src/ui.rs

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -262,9 +262,9 @@ fn draw_footer(frame: &mut Frame, area: Rect, app: &mut App) {
262262
help.push(": Apply ".dim());
263263
}
264264
help.push("o : Set Env ".dim());
265-
help.push("Ctrl+N".dim());
266-
help.push(format!(": Attempts {}x ", app.best_of_n).dim());
267265
if app.new_task.is_some() {
266+
help.push("Ctrl+N".dim());
267+
help.push(format!(": Attempts {}x ", app.best_of_n).dim());
268268
help.push("(editing new task) ".dim());
269269
} else {
270270
help.push("n : New Task ".dim());
@@ -1004,32 +1004,40 @@ pub fn draw_best_of_modal(frame: &mut Frame, area: Rect, app: &mut App) {
10041004
use ratatui::widgets::Wrap;
10051005

10061006
let inner = overlay_outer(area);
1007+
const MAX_WIDTH: u16 = 40;
1008+
const MIN_WIDTH: u16 = 20;
1009+
const MAX_HEIGHT: u16 = 12;
1010+
const MIN_HEIGHT: u16 = 6;
1011+
let modal_width = inner.width.min(MAX_WIDTH).max(inner.width.min(MIN_WIDTH));
1012+
let modal_height = inner
1013+
.height
1014+
.min(MAX_HEIGHT)
1015+
.max(inner.height.min(MIN_HEIGHT));
1016+
let modal_x = inner.x + (inner.width.saturating_sub(modal_width)) / 2;
1017+
let modal_y = inner.y + (inner.height.saturating_sub(modal_height)) / 2;
1018+
let modal_area = Rect::new(modal_x, modal_y, modal_width, modal_height);
10071019
let title = Line::from(vec!["Parallel Attempts".magenta().bold()]);
10081020
let block = overlay_block().title(title);
10091021

1010-
frame.render_widget(Clear, inner);
1011-
frame.render_widget(block.clone(), inner);
1012-
let content = overlay_content(inner);
1022+
frame.render_widget(Clear, modal_area);
1023+
frame.render_widget(block.clone(), modal_area);
1024+
let content = overlay_content(modal_area);
10131025

10141026
let rows = Layout::default()
10151027
.direction(Direction::Vertical)
10161028
.constraints([Constraint::Length(2), Constraint::Min(1)])
10171029
.split(content);
10181030

1019-
let hint = Paragraph::new(Line::from(
1020-
"Use ↑/↓ to choose, 1-4 jump; Enter confirm, Esc cancel"
1021-
.cyan()
1022-
.dim(),
1023-
))
1024-
.wrap(Wrap { trim: true });
1031+
let hint = Paragraph::new(Line::from("Use ↑/↓ to choose, 1-4 jump".cyan().dim()))
1032+
.wrap(Wrap { trim: true });
10251033
frame.render_widget(hint, rows[0]);
10261034

10271035
let selected = app.best_of_modal.as_ref().map(|m| m.selected).unwrap_or(0);
10281036
let options = [1usize, 2, 3, 4];
10291037
let mut items: Vec<ListItem> = Vec::new();
10301038
for &attempts in &options {
1031-
let mut spans: Vec<ratatui::text::Span> =
1032-
vec![format!("{attempts} attempt{}", if attempts == 1 { "" } else { "s" }).into()];
1039+
let noun = if attempts == 1 { "attempt" } else { "attempts" };
1040+
let mut spans: Vec<ratatui::text::Span> = vec![format!("{attempts} {noun:<8}").into()];
10331041
spans.push(" ".into());
10341042
spans.push(format!("{attempts}x parallel").dim());
10351043
if attempts == app.best_of_n {

0 commit comments

Comments
 (0)