aboutsummaryrefslogtreecommitdiff
path: root/src/app
diff options
context:
space:
mode:
authorkangal-bot <kangal@herdr.dev>2026-05-27 15:09:31 +0300
committerGitHub <noreply@github.com>2026-05-27 15:09:31 +0300
commit858c36974bad616e9e6c1897882b8c9a97396bec (patch)
tree63a6b332599596708dc7a66cead14af474755fd2 /src/app
parent9a89e3dc181bdf35101c2066bea114394afb93e2 (diff)
feat: configure mobile width threshold (#317)
Diffstat (limited to 'src/app')
-rw-r--r--src/app/mod.rs29
-rw-r--r--src/app/state.rs2
2 files changed, 31 insertions, 0 deletions
diff --git a/src/app/mod.rs b/src/app/mod.rs
index cad09a71..12fb704e 100644
--- a/src/app/mod.rs
+++ b/src/app/mod.rs
@@ -478,6 +478,7 @@ impl App {
sidebar_width,
sidebar_min_width,
sidebar_max_width,
+ mobile_width_threshold: config.ui.mobile_width_threshold,
sidebar_width_source,
sidebar_width_auto: false,
sidebar_collapsed: false,
@@ -1079,6 +1080,7 @@ impl App {
}
self.state.sidebar_min_width = config.ui.sidebar_min_width;
self.state.sidebar_max_width = config.ui.sidebar_max_width;
+ self.state.mobile_width_threshold = config.ui.mobile_width_threshold;
// Re-clamp the live width to the new bounds. No source guard — bounds
// always apply, including to widths owned by Persisted or Manual.
self.state.sidebar_width = self
@@ -1778,6 +1780,10 @@ mod tests {
// Default bounds.
assert_eq!(app.state.sidebar_min_width, 18);
assert_eq!(app.state.sidebar_max_width, 36);
+ assert_eq!(
+ app.state.mobile_width_threshold,
+ crate::config::DEFAULT_MOBILE_WIDTH_THRESHOLD
+ );
// Manually set a width and flip the source so the existing
// sidebar_width-only-when-config-owned guard does NOT update it.
@@ -1818,6 +1824,29 @@ mod tests {
}
#[test]
+ fn reload_config_updates_mobile_width_threshold() {
+ let _guard = config_env_lock().lock().unwrap();
+ let path = temp_config_path("reload-config-mobile-width-threshold");
+ std::fs::create_dir_all(path.parent().unwrap()).unwrap();
+ std::env::set_var(crate::config::CONFIG_PATH_ENV_VAR, &path);
+
+ let mut app = test_app();
+ assert_eq!(
+ app.state.mobile_width_threshold,
+ crate::config::DEFAULT_MOBILE_WIDTH_THRESHOLD
+ );
+
+ std::fs::write(&path, "[ui]\nmobile_width_threshold = 96\n").unwrap();
+ let report = app.reload_config();
+
+ assert_eq!(report.status, crate::config::ConfigReloadStatus::Applied);
+ assert_eq!(app.state.mobile_width_threshold, 96);
+
+ std::env::remove_var(crate::config::CONFIG_PATH_ENV_VAR);
+ let _ = std::fs::remove_dir_all(path.parent().unwrap());
+ }
+
+ #[test]
fn app_new_falls_back_to_default_bounds_on_inverted_config() {
let mut config = Config::default();
config.ui.sidebar_min_width = 50;
diff --git a/src/app/state.rs b/src/app/state.rs
index de1db052..7c47973c 100644
--- a/src/app/state.rs
+++ b/src/app/state.rs
@@ -1119,6 +1119,7 @@ pub struct AppState {
pub sidebar_width: u16,
pub sidebar_min_width: u16,
pub sidebar_max_width: u16,
+ pub mobile_width_threshold: u16,
pub sidebar_width_source: SidebarWidthSource,
pub sidebar_width_auto: bool,
pub sidebar_collapsed: bool,
@@ -1424,6 +1425,7 @@ impl AppState {
sidebar_width: 26,
sidebar_min_width: 18,
sidebar_max_width: 36,
+ mobile_width_threshold: crate::config::DEFAULT_MOBILE_WIDTH_THRESHOLD,
sidebar_width_source: SidebarWidthSource::ConfigDefault,
sidebar_width_auto: false,
sidebar_collapsed: false,