aboutsummaryrefslogtreecommitdiff
path: root/src/app
diff options
context:
space:
mode:
authorOgulcan Celik <ogulcancelik@gmail.com>2026-04-06 19:36:23 +0300
committerOgulcan Celik <ogulcancelik@gmail.com>2026-04-06 19:36:23 +0300
commitd859cf21f565e23503c6ba351c62c32c33153d77 (patch)
tree27bac56973e903da8d81820948c2a771e8d42ffe /src/app
parentcbe5c150baa147649912bb1bfad40522dc3c25f3 (diff)
fix: keep sidebar width stable and persist user resize
Diffstat (limited to 'src/app')
-rw-r--r--src/app/input.rs12
-rw-r--r--src/app/mod.rs26
-rw-r--r--src/app/state.rs4
3 files changed, 29 insertions, 13 deletions
diff --git a/src/app/input.rs b/src/app/input.rs
index 6af7cf0e..64731bf3 100644
--- a/src/app/input.rs
+++ b/src/app/input.rs
@@ -318,7 +318,8 @@ impl App {
self.last_sidebar_divider_click = Some(now);
if is_double_click {
- self.state.sidebar_width_auto = true;
+ self.state.sidebar_width = self.state.default_sidebar_width;
+ self.state.sidebar_width_auto = false;
self.state.drag = None;
return;
}
@@ -1918,7 +1919,6 @@ impl AppState {
self.drag = Some(DragState {
target: DragTarget::SidebarDivider,
});
- self.sidebar_width_auto = false;
self.set_manual_sidebar_width(mouse.column);
return None;
}
@@ -2154,7 +2154,6 @@ impl AppState {
}
}
DragTarget::SidebarDivider => {
- self.sidebar_width_auto = false;
self.set_manual_sidebar_width(mouse.column);
}
DragTarget::ReleaseNotesScrollbar { .. }
@@ -3734,21 +3733,20 @@ mod tests {
app.handle_mouse(mouse(MouseEventKind::Down(MouseButton::Left), 25, 5));
app.handle_mouse(mouse(MouseEventKind::Drag(MouseButton::Left), 30, 5));
- assert!(!app.state.sidebar_width_auto);
assert_eq!(app.state.sidebar_width, 31);
}
#[test]
- fn double_clicking_sidebar_divider_resets_auto_width() {
+ fn double_clicking_sidebar_divider_resets_default_width() {
let mut app = app_for_mouse_test();
- app.state.sidebar_width_auto = false;
+ app.state.default_sidebar_width = 26;
app.state.sidebar_width = 30;
app.handle_mouse(mouse(MouseEventKind::Down(MouseButton::Left), 25, 5));
app.handle_mouse(mouse(MouseEventKind::Up(MouseButton::Left), 25, 5));
app.handle_mouse(mouse(MouseEventKind::Down(MouseButton::Left), 25, 5));
- assert!(app.state.sidebar_width_auto);
+ assert_eq!(app.state.sidebar_width, 26);
assert!(app.state.drag.is_none());
}
diff --git a/src/app/mod.rs b/src/app/mod.rs
index f06bbb19..6d677b0c 100644
--- a/src/app/mod.rs
+++ b/src/app/mod.rs
@@ -157,12 +157,13 @@ impl App {
let render_dirty = Arc::new(AtomicBool::new(false));
// Try to restore previous session
- let (workspaces, active, selected, agent_panel_scope) = if no_session {
+ let (workspaces, active, selected, agent_panel_scope, sidebar_width) = if no_session {
(
Vec::new(),
None,
0,
state::AgentPanelScope::CurrentWorkspace,
+ config.ui.sidebar_width,
)
} else if let Some(snap) = crate::persist::load() {
let ws = crate::persist::restore(
@@ -175,12 +176,24 @@ impl App {
);
if ws.is_empty() {
info!("session file found but no workspaces restored");
- (Vec::new(), None, 0, snap.agent_panel_scope)
+ (
+ Vec::new(),
+ None,
+ 0,
+ snap.agent_panel_scope,
+ snap.sidebar_width.unwrap_or(config.ui.sidebar_width),
+ )
} else {
info!(count = ws.len(), "session restored");
let active = snap.active.filter(|&i| i < ws.len());
let selected = snap.selected.min(ws.len().saturating_sub(1));
- (ws, active, selected, snap.agent_panel_scope)
+ (
+ ws,
+ active,
+ selected,
+ snap.agent_panel_scope,
+ snap.sidebar_width.unwrap_or(config.ui.sidebar_width),
+ )
}
} else {
(
@@ -188,6 +201,7 @@ impl App {
None,
0,
state::AgentPanelScope::CurrentWorkspace,
+ config.ui.sidebar_width,
)
};
@@ -247,8 +261,9 @@ impl App {
toast: None,
prefix_code,
prefix_mods,
- sidebar_width: config.ui.sidebar_width,
- sidebar_width_auto: true,
+ default_sidebar_width: config.ui.sidebar_width,
+ sidebar_width,
+ sidebar_width_auto: false,
sidebar_collapsed: false,
agent_panel_scope,
confirm_close: config.ui.confirm_close,
@@ -434,6 +449,7 @@ impl App {
self.state.active,
self.state.selected,
self.state.agent_panel_scope,
+ self.state.sidebar_width,
);
crate::persist::save(&snap);
}
diff --git a/src/app/state.rs b/src/app/state.rs
index 60cb0511..84920131 100644
--- a/src/app/state.rs
+++ b/src/app/state.rs
@@ -595,6 +595,7 @@ pub struct AppState {
// Config
pub prefix_code: KeyCode,
pub prefix_mods: KeyModifiers,
+ pub default_sidebar_width: u16,
pub sidebar_width: u16,
pub sidebar_width_auto: bool,
pub sidebar_collapsed: bool,
@@ -703,8 +704,9 @@ impl AppState {
toast: None,
prefix_code: KeyCode::Char('b'),
prefix_mods: KeyModifiers::CONTROL,
+ default_sidebar_width: 26,
sidebar_width: 26,
- sidebar_width_auto: true,
+ sidebar_width_auto: false,
sidebar_collapsed: false,
agent_panel_scope: AgentPanelScope::CurrentWorkspace,
confirm_close: true,