diff options
| author | Can Celik <ogulcancelik@gmail.com> | 2026-08-15 15:09:53 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-08-15 15:09:53 +0300 |
| commit | 15539d3dec40bcc40e6f4bb0eaa4f073ad26b74f (patch) | |
| tree | 2ff7cf0353d3c3228f32d5d7756b45ba2486edb2 /src/config | |
| parent | b660cad80450147610091e0e5758faa6276e5983 (diff) | |
feat: make headless terminal size configurable (#2829)
refs #2828
Diffstat (limited to 'src/config')
| -rw-r--r-- | src/config/io.rs | 9 | ||||
| -rw-r--r-- | src/config/model.rs | 58 |
2 files changed, 67 insertions, 0 deletions
diff --git a/src/config/io.rs b/src/config/io.rs index 7ed82395..898cf077 100644 --- a/src/config/io.rs +++ b/src/config/io.rs @@ -10,6 +10,7 @@ const KNOWN_TOP_LEVEL_CONFIG_KEYS: &[&str] = &[ "keys", "onboarding", "remote", + "server", "session", "terminal", "theme", @@ -294,6 +295,14 @@ fn load_live_config_from_str(content: &str) -> Result<LoadedConfig, Vec<String>> ); load_live_section( table, + "server", + "server config", + &mut diagnostics, + &mut invalid_sections, + |section| config.server = section, + ); + load_live_section( + table, "update", "update config", &mut diagnostics, diff --git a/src/config/model.rs b/src/config/model.rs index 6d6083ad..ad779d26 100644 --- a/src/config/model.rs +++ b/src/config/model.rs @@ -315,6 +315,7 @@ pub struct Config { pub theme: ThemeConfig, pub terminal: TerminalConfig, pub session: SessionConfig, + pub server: ServerConfig, pub update: UpdateConfig, pub keys: KeysConfig, pub ui: UiConfig, @@ -940,6 +941,15 @@ impl ImeCursorShape { #[derive(Debug, Deserialize)] #[serde(default)] +pub struct ServerConfig { + /// Virtual terminal width used when no client is attached. Default: 120. + pub headless_cols: u16, + /// Virtual terminal height used when no client is attached. Default: 40. + pub headless_rows: u16, +} + +#[derive(Debug, Deserialize)] +#[serde(default)] pub struct AdvancedConfig { /// Maximum scrollback buffer size in bytes retained per pane terminal. Default: 10000000. #[serde(alias = "scrollback_lines")] @@ -1200,6 +1210,15 @@ impl<'de> Deserialize<'de> for ToastConfig { } } +impl Default for ServerConfig { + fn default() -> Self { + Self { + headless_cols: crate::config::DEFAULT_HEADLESS_COLS, + headless_rows: crate::config::DEFAULT_HEADLESS_ROWS, + } + } +} + impl Default for AdvancedConfig { fn default() -> Self { Self { @@ -1818,6 +1837,45 @@ delay_seconds = {} } #[test] + fn server_headless_size_defaults_and_parses() { + let default_config = Config::default(); + assert_eq!( + default_config.server.headless_cols, + crate::config::DEFAULT_HEADLESS_COLS + ); + assert_eq!( + default_config.server.headless_rows, + crate::config::DEFAULT_HEADLESS_ROWS + ); + + let config: Config = toml::from_str( + r#"[server] +headless_cols = 160 +headless_rows = 50 +"#, + ) + .unwrap(); + assert_eq!(config.server.headless_cols, 160); + assert_eq!(config.server.headless_rows, 50); + + let invalid: Config = toml::from_str( + r#"[server] +headless_cols = 0 +headless_rows = 50 +"#, + ) + .unwrap(); + assert!(invalid.invalid_headless_size_diagnostic().is_some()); + assert_eq!( + invalid.headless_size(), + ( + crate::config::DEFAULT_HEADLESS_COLS, + crate::config::DEFAULT_HEADLESS_ROWS + ) + ); + } + + #[test] fn advanced_defaults_include_scrollback_limit_bytes() { let config = Config::default(); assert_eq!( |
