Skip to content

Commit 88198ae

Browse files
authored
Add welcome screen exit shortcut (#356)
1 parent 9e1a7cd commit 88198ae

2 files changed

Lines changed: 24 additions & 3 deletions

File tree

crates/cli/src/app.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8210,6 +8210,10 @@ mod tests {
82108210
screen.contains("C-x C-f"),
82118211
"missing create shortcut:\n{screen}"
82128212
);
8213+
assert!(
8214+
screen.contains("exit agentd"),
8215+
"missing exit shortcut:\n{screen}"
8216+
);
82138217
assert!(
82148218
screen.contains("new: C-x C-f help: ? palette: C-x x"),
82158219
"missing modeline hint:\n{screen}"
@@ -8219,7 +8223,7 @@ mod tests {
82198223
"empty state should not include CLI examples:\n{screen}"
82208224
);
82218225
assert!(
8222-
app.layout.shortcut_hints.len() >= 3,
8226+
app.layout.shortcut_hints.len() >= 4,
82238227
"expected clickable shortcuts, got {:?}",
82248228
app.layout.shortcut_hints
82258229
);
@@ -8241,6 +8245,12 @@ mod tests {
82418245
.iter()
82428246
.any(|h| h.action == KeyAction::ToggleHelp)
82438247
);
8248+
assert!(
8249+
app.layout
8250+
.shortcut_hints
8251+
.iter()
8252+
.any(|h| h.action == KeyAction::Quit)
8253+
);
82448254
server.abort();
82458255
}
82468256

@@ -8291,6 +8301,11 @@ mod tests {
82918301
app.minibuffer.as_ref().map(|m| &m.intent),
82928302
Some(MinibufferIntent::NewSessionHarness)
82938303
));
8304+
app.minibuffer = None;
8305+
8306+
let (x, y) = click(&app, KeyAction::Quit);
8307+
app.handle_left_click(x, y).await;
8308+
assert!(app.should_quit);
82948309
server.abort();
82958310
}
82968311

crates/cli/src/ui.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2623,16 +2623,17 @@ fn render_detail(f: &mut Frame, area: Rect, app: &mut App, window_id: Option<u64
26232623
}
26242624

26252625
fn render_empty_session_state(f: &mut Frame, area: Rect, app: &mut App) {
2626-
let card = centered_rect(area, 72, 9);
2626+
let card = centered_rect(area, 72, 10);
26272627
let label_style = Style::default().fg(app.theme.accent);
26282628
let hover_style = label_style.add_modifier(Modifier::BOLD | Modifier::UNDERLINED);
26292629
let mouse = app.mouse_pos;
26302630
let shortcut_rows = [
26312631
(4_u16, 2_u16, "C-x C-f", KeyAction::OpenNewSession),
26322632
(5_u16, 2_u16, "C-x x", KeyAction::OpenCommandPalette),
26332633
(6_u16, 2_u16, "?", KeyAction::ToggleHelp),
2634+
(7_u16, 2_u16, "q", KeyAction::Quit),
26342635
];
2635-
let mut hovered = [false; 3];
2636+
let mut hovered = [false; 4];
26362637
for (i, (row, col, label, action)) in shortcut_rows.iter().enumerate() {
26372638
let x_start = card.x + *col;
26382639
let y = card.y + *row;
@@ -2680,6 +2681,11 @@ fn render_empty_session_state(f: &mut Frame, area: Rect, app: &mut App) {
26802681
Span::styled("?", if hovered[2] { hover_style } else { label_style }),
26812682
Span::raw(" show shortcuts and concepts"),
26822683
]),
2684+
Line::from(vec![
2685+
Span::raw(" "),
2686+
Span::styled("q", if hovered[3] { hover_style } else { label_style }),
2687+
Span::raw(" exit agentd"),
2688+
]),
26832689
];
26842690
let para = Paragraph::new(lines).wrap(Wrap { trim: false });
26852691
f.render_widget(para, card);

0 commit comments

Comments
 (0)