use super::super::*;
use super::support::*;
#[test]
fn alt_a_works_with_help_but_modal_precedence_blocks_it() {
let mut state = state_with_activity();
state.show_help = true;
handle_key(
modified_key(KeyCode::Char('a'), KeyModifiers::ALT),
&mut state,
);
assert!(!state.activity_column_visible());
assert!(state.show_help);
state.open_system_prompt_modal("modal content".to_string());
handle_key(
modified_key(KeyCode::Char('a'), KeyModifiers::ALT),
&mut state,
);
assert!(!state.activity_column_visible());
assert!(state.system_prompt_modal_visible());
}
#[test]
fn system_prompt_modal_alt_arrows_scroll_modal_and_suppress_underlying_state() {
let mut state = state_with_activity();
state.focus_prompt();
state.set_prompt_text("line one\nline two", "line one\nline two".len());
state.set_scroll_offset(&state.scroll_views.transcript, 2);
state.set_scroll_offset(&state.scroll_views.activity_tree, 3);
state.set_scroll_offset(&state.scroll_views.detail, 4);
state.open_system_prompt_modal(
(0..12)
.map(|line| format!("modal line {line}"))
.collect::<Vec<_>>()
.join("\n"),
);
let viewport = Some(SystemPromptViewport {
visible_rows: 3,
wrap_width: 80,
});
assert!(matches!(
handle_key_with_all_viewports(
modified_key(KeyCode::Down, KeyModifiers::ALT),
&mut state,
KeyViewports {
system_prompt: viewport,
..KeyViewports::default()
},
&[]
),
InputAction::None
));
assert_eq!(state.scroll_offset(&state.scroll_views.system_prompt), 1);
assert_eq!(state.prompt_cursor(), "line one\nline two".len());
assert_eq!(state.transcript_scroll_offset(), 2);
assert_eq!(state.activity_scroll_offset(), 3);
assert_eq!(state.detail_offset(), 4);
assert!(matches!(
handle_key_with_all_viewports(
modified_key(KeyCode::Up, KeyModifiers::ALT),
&mut state,
KeyViewports {
system_prompt: viewport,
..KeyViewports::default()
},
&[]
),
InputAction::None
));
assert_eq!(state.scroll_offset(&state.scroll_views.system_prompt), 0);
assert_eq!(state.prompt_cursor(), "line one\nline two".len());
assert_eq!(state.transcript_scroll_offset(), 2);
assert_eq!(state.activity_scroll_offset(), 3);
assert_eq!(state.detail_offset(), 4);
}