aboutsummaryrefslogtreecommitdiff
path: root/src/app
diff options
context:
space:
mode:
Diffstat (limited to 'src/app')
-rw-r--r--src/app/mod.rs12
-rw-r--r--src/app/state.rs16
2 files changed, 26 insertions, 2 deletions
diff --git a/src/app/mod.rs b/src/app/mod.rs
index 49a905ae..35244115 100644
--- a/src/app/mod.rs
+++ b/src/app/mod.rs
@@ -619,6 +619,7 @@ impl App {
outer_terminal_focus: None,
prefix_code,
prefix_mods,
+ headless_size: config.headless_size(),
default_sidebar_width: config.ui.sidebar_width,
sidebar_width,
sidebar_min_width,
@@ -1539,6 +1540,14 @@ impl App {
}
}
+ if !invalid_section("server") {
+ if let Some(diagnostic) = config.invalid_headless_size_diagnostic() {
+ diagnostics.push(format!("{diagnostic}; keeping current [server] settings"));
+ } else {
+ self.state.headless_size = config.headless_size();
+ }
+ }
+
if !invalid_section("advanced") {
self.state.pane_scrollback_limit_bytes = config.advanced.scrollback_limit_bytes;
}
@@ -2974,7 +2983,7 @@ mod tests {
std::fs::create_dir_all(path.parent().unwrap()).unwrap();
std::fs::write(
&path,
- "[terminal]\ndefault_shell = \"nu\"\nshell_mode = \"non_login\"\nnew_cwd = \"home\"\n[keys]\nnew_workspace = \"prefix+m\"\nprefix = \"ctrl+a\"\n[update]\nversion_check = false\nmanifest_check = false\n[ui]\nagent_panel_sort = \"priority\"\nredraw_on_focus_gained = false\ncopy_on_select = false\nright_click_passthrough_modifier = \"ctrl\"\nprompt_new_workspace_name = true\n[ui.toast]\ndelivery = \"herdr\"\n[experimental]\nswitch_ascii_input_source_in_prefix = true\n",
+ "[terminal]\ndefault_shell = \"nu\"\nshell_mode = \"non_login\"\nnew_cwd = \"home\"\n[keys]\nnew_workspace = \"prefix+m\"\nprefix = \"ctrl+a\"\n[update]\nversion_check = false\nmanifest_check = false\n[server]\nheadless_cols = 160\nheadless_rows = 50\n[ui]\nagent_panel_sort = \"priority\"\nredraw_on_focus_gained = false\ncopy_on_select = false\nright_click_passthrough_modifier = \"ctrl\"\nprompt_new_workspace_name = true\n[ui.toast]\ndelivery = \"herdr\"\n[experimental]\nswitch_ascii_input_source_in_prefix = true\n",
)
.unwrap();
std::env::set_var(crate::config::CONFIG_PATH_ENV_VAR, &path);
@@ -3008,6 +3017,7 @@ mod tests {
let report = app.reload_config();
assert_eq!(report.status, crate::config::ConfigReloadStatus::Applied);
+ assert_eq!(app.state.headless_size, (160, 50));
assert_eq!(app.state.prefix_code, KeyCode::Char('a'));
assert_eq!(app.state.prefix_mods, KeyModifiers::CONTROL);
assert!(app
diff --git a/src/app/state.rs b/src/app/state.rs
index ea550472..e03d90a9 100644
--- a/src/app/state.rs
+++ b/src/app/state.rs
@@ -1428,6 +1428,8 @@ pub struct AppState {
// Config
pub prefix_code: KeyCode,
pub prefix_mods: KeyModifiers,
+ /// Virtual terminal size (columns, rows) used when no client is attached.
+ pub(crate) headless_size: (u16, u16),
pub default_sidebar_width: u16,
pub sidebar_width: u16,
pub sidebar_min_width: u16,
@@ -1618,7 +1620,7 @@ impl AppState {
if let Some(info) = self.view.pane_infos.first() {
(info.rect.height, info.rect.width)
} else {
- (24, 80)
+ (self.headless_size.1, self.headless_size.0)
}
}
@@ -1800,6 +1802,10 @@ impl AppState {
outer_terminal_focus: None,
prefix_code: KeyCode::Char('b'),
prefix_mods: KeyModifiers::CONTROL,
+ headless_size: (
+ crate::config::DEFAULT_HEADLESS_COLS,
+ crate::config::DEFAULT_HEADLESS_ROWS,
+ ),
default_sidebar_width: 26,
sidebar_width: 26,
sidebar_min_width: 18,
@@ -2243,6 +2249,14 @@ mod tests {
use crossterm::event::KeyEvent;
#[test]
+ fn pane_size_estimate_uses_headless_size_before_first_view() {
+ let mut state = AppState::test_new();
+ state.headless_size = (132, 41);
+
+ assert_eq!(state.estimate_pane_size(), (41, 132));
+ }
+
+ #[test]
fn agent_terminal_keeps_final_child_cursor_exposed() {
let mut state = AppState::test_new();
let ws = crate::workspace::Workspace::test_new("test");