From a024e968dc36d230fb76c5c64049391f129711ea Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 22 Oct 2026 15:29:44 +0000 Subject: [PATCH] Make both sidebars resizable Drag the left sidebar's right edge or the right sidebar's left edge (menu and GitHub view each keep their own width); widths are remembered in the layout. Closes #56. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01Crnkeo39F4o6tHJoPEuSQW --- CLAUDE.md | 4 ++-- README.md | 2 +- src/app.rs | 44 +++++++++++++++++++++++++++++++++++--------- src/app/headless.rs | 28 +++++++++++++++++++++++++--- src/inspector.rs | 12 ++++++------ src/sidebar.rs | 25 +++++++++++++++++++++++-- src/store.rs | 8 +++++++- src/views.rs | 6 ++++-- 8 files changed, 103 insertions(+), 26 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 991e1c0..1be5bc1 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -74,7 +74,7 @@ Do not intercept Claude Code shortcuts merely to implement application-level sho ## The session list -The left sidebar is **one list** of Claude Code sessions and chats (product owner decision: no Chat/Code tabs, no project tree). **Running** comes first: terminals in the order the user arranged them (drag to reorder), then open chats. **Recent** follows, newest first, chats and sessions mixed; past the first 12 the rest sit behind a collapsed **Older**. Each row carries a project chip (the project's name, or the folder for an unregistered one; a project-less chat shows its age instead). +The left sidebar (284 px by default, 220–520 px by dragging its right edge; `layout.left_w` remembers it) is **one list** of Claude Code sessions and chats (product owner decision: no Chat/Code tabs, no project tree). **Running** comes first: terminals in the order the user arranged them (drag to reorder), then open chats. **Recent** follows, newest first, chats and sessions mixed; past the first 12 the rest sit behind a collapsed **Older**. Each row carries a project chip (the project's name, or the folder for an unregistered one; a project-less chat shows its age instead). ```text RUNNING @@ -399,7 +399,7 @@ Each Claude session can show a **shell under its terminal**, toggled with Ctrl+S A column on the right, under the top bar (so the window buttons stay in the corner), on by default. Toggle it with the top bar's panel button or Ctrl+Shift+R (Cmd+Shift+R); `layout.right_hidden` remembers it. It has two views, switched inside the same column: -- **Menu** (272 px): the actions that used to crowd the top bar (Open in editor ▾, Open folder, Commit & Push, Pull, show or hide the shell, GitHub), the **issues and pull requests Claude attached** to the session, the sessions and chats **linked** with it, and the session's **status**: context, prompt-cache timer, auto-compact and advisor. Auto-compact (On/Off) and Advisor (Off, Opus, Sonnet, Other… with a name box) are dropdowns while the session runs. The 5 HOUR / 7 DAY account meters stay in the left sidebar. +- **Menu** (272 px by default, `layout.right_menu_w`, 240–480 px by dragging its left edge): the actions that used to crowd the top bar (Open in editor ▾, Open folder, Commit & Push, Pull, show or hide the shell, GitHub), the **issues and pull requests Claude attached** to the session, the sessions and chats **linked** with it, and the session's **status**: context, prompt-cache timer, auto-compact and advisor. Auto-compact (On/Off) and Advisor (Off, Opus, Sonnet, Other… with a name box) are dropdowns while the session runs. The 5 HOUR / 7 DAY account meters stay in the left sidebar. - **GitHub**: the project's issues and pull requests (`github/view.rs`), in a wider column (`layout.right_gh_w`, 560 px by default, resizable by dragging its left edge). The arrow returns to the menu. The view follows the shown session to that session's project; it is never a session, a tab or a main-area page. Status comes from the per-process mod (`usage.rs` snapshots, no tokens): it reports context, limits, the `/config` auto-compact switch, the auto-compact threshold and `advisorModel` (`ClaudeMeta`). Nothing is typed into the PTY. diff --git a/README.md b/README.md index 6dcfead..26131dd 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ There's no API key and no login in Claudiu. Authentication stays with Claude Cod - **History.** Ended Claude sessions stay in the sidebar, and a click resumes one through `claude --resume`. - **Import on startup.** Your existing Claude Code sessions are found and merged in (read-only, no duplicates). - **Shell panel.** Each Claude session can show its own shell under its terminal (Ctrl+Shift+T). It starts in the session's folder and ends with the session. -- **Right sidebar.** The actions for the shown session (open in your editor, open folder, Commit & Push, Pull, shell), its status (context, prompt cache, auto-compact, advisor), the issues and pull requests Claude attached to it, the sessions and chats linked with it, and a GitHub view. Auto-compact and the advisor model can be changed from its status rows. Ctrl+Shift+R shows or hides it. +- **Right sidebar.** The actions for the shown session (open in your editor, open folder, Commit & Push, Pull, shell), its status (context, prompt cache, auto-compact, advisor), the issues and pull requests Claude attached to it, the sessions and chats linked with it, and a GitHub view. Auto-compact and the advisor model can be changed from its status rows. Ctrl+Shift+R shows or hides it. Drag the edge of either sidebar to resize it; the widths are remembered. - **Usage meters.** Context per session, plus 5-hour and 7-day account limits. See [Usage meters](#usage-meters) for the catch. - **Git buttons.** Commit & Push (Haiku writes the message through your own `claude` CLI) and Pull. Branch management too. - **Tab titles.** Claude names its own tabs. diff --git a/src/app.rs b/src/app.rs index 7b4e105..64ac4d4 100644 --- a/src/app.rs +++ b/src/app.rs @@ -14,6 +14,7 @@ use crate::accounts; use crate::chat::store::{ChatRecord, ChatStore, DEFAULT_TITLE, is_tied, scratch_dir, title_from}; use crate::chat::view::{ChatEvent, ChatView, Launch}; use crate::claude; +use crate::sidebar::{SIDEBAR_MAX, SIDEBAR_MIN, SIDEBAR_W}; use crate::github::view::{GhEvent, GithubView}; use crate::mcp; use crate::platform::{self, Editor}; @@ -233,13 +234,15 @@ pub struct ShellPanel { pub const SHELL_HEIGHT: f32 = 260.0; pub const SHELL_MIN: f32 = 120.0; -/// The right sidebar: a fixed-width menu, or the wider, resizable GitHub view. +/// The right sidebar: the menu or the wider GitHub view, each with its own remembered width. pub const RIGHT_MENU_W: f32 = 272.0; +pub const RIGHT_MENU_MIN: f32 = 240.0; +pub const RIGHT_MENU_MAX: f32 = 480.0; pub const RIGHT_GH_W: f32 = 560.0; pub const RIGHT_GH_MIN: f32 = 380.0; -/// A drag of the right sidebar's left edge: where it started and how wide the sidebar was then. -pub struct RightDrag { +/// A drag of a sidebar's inner edge: where it started and how wide the sidebar was then. +pub struct SideDrag { pub x: f32, pub width: f32, } @@ -267,7 +270,8 @@ pub struct Workspace { pub gh: Vec, /// The GitHub view the right sidebar shows; `None` is its menu. pub right_gh: Option, - pub right_drag: Option, + pub right_drag: Option, + pub left_drag: Option, pub chats: Vec, pub chat_store: ChatStore, /// The session shown in the main area. @@ -347,6 +351,7 @@ impl Workspace { gh: vec![], right_gh: None, right_drag: None, + left_drag: None, chats: vec![], chat_store: { let mut chats = ChatStore::load(ChatStore::path_for(&Store::default_path())); @@ -1736,20 +1741,41 @@ impl Workspace { cx.notify(); } - /// The right sidebar's current width: fixed for the menu, remembered (and draggable) for GitHub. + /// The right sidebar's current width: the remembered one for the menu or for GitHub, kept within bounds. pub fn right_width(&self, window_w: f32) -> f32 { + let layout = &self.store.data.layout; + let room = (window_w - 560.0).max(RIGHT_GH_MIN); if self.right_gh.is_none() { - return RIGHT_MENU_W; + return layout.right_menu_w.unwrap_or(RIGHT_MENU_W).clamp(RIGHT_MENU_MIN, RIGHT_MENU_MAX.min(room)); } - let wanted = self.store.data.layout.right_gh_w.unwrap_or(RIGHT_GH_W); - wanted.clamp(RIGHT_GH_MIN, (window_w - 560.0).max(RIGHT_GH_MIN)) + layout.right_gh_w.unwrap_or(RIGHT_GH_W).clamp(RIGHT_GH_MIN, room) } /// The right sidebar's left edge is being dragged: follow the pointer, wider to the left. pub fn drag_right(&mut self, x: f32, window_w: f32) { let Some(d) = self.right_drag.as_ref() else { return }; let wanted = d.width + d.x - x; - self.store.data.layout.right_gh_w = Some(wanted.clamp(RIGHT_GH_MIN, (window_w - 560.0).max(RIGHT_GH_MIN))); + let room = (window_w - 560.0).max(RIGHT_GH_MIN); + let layout = &mut self.store.data.layout; + if self.right_gh.is_none() { + layout.right_menu_w = Some(wanted.clamp(RIGHT_MENU_MIN, RIGHT_MENU_MAX.min(room))); + } else { + layout.right_gh_w = Some(wanted.clamp(RIGHT_GH_MIN, room)); + } + self.store.mark_dirty(); + } + + /// The left sidebar's current width, kept within bounds and leaving room for the session. + pub fn left_width(&self, window_w: f32) -> f32 { + let wanted = self.store.data.layout.left_w.unwrap_or(SIDEBAR_W); + wanted.clamp(SIDEBAR_MIN, SIDEBAR_MAX.min((window_w - 560.0).max(SIDEBAR_MIN))) + } + + /// The left sidebar's right edge is being dragged: follow the pointer, wider to the right. + pub fn drag_left(&mut self, x: f32, window_w: f32) { + let Some(d) = self.left_drag.as_ref() else { return }; + let wanted = d.width + x - d.x; + self.store.data.layout.left_w = Some(wanted.clamp(SIDEBAR_MIN, SIDEBAR_MAX.min((window_w - 560.0).max(SIDEBAR_MIN)))); self.store.mark_dirty(); } diff --git a/src/app/headless.rs b/src/app/headless.rs index 7babe7e..db7e5a8 100644 --- a/src/app/headless.rs +++ b/src/app/headless.rs @@ -213,12 +213,34 @@ fn sessions_and_shell() { step(&mut cx, &|ws, w, cx| ws.close_live(&first, w, cx)); assert!(ws.read_with(&cx, |ws, _| !ws.shells.contains_key(&first)), "closing the session drops its shell"); // The GitHub view lives in the right sidebar: one per folder, it widens the sidebar, "Ask Claude" starts a session. - assert_eq!(ws.read_with(&cx, |ws, _| ws.right_width(1600.0)), RIGHT_MENU_W, "the menu has a fixed width"); + assert_eq!(ws.read_with(&cx, |ws, _| ws.right_width(1600.0)), RIGHT_MENU_W, "the menu starts at its default width"); + // Both sidebars can be dragged; the menu and the GitHub view each remember their own width. + step(&mut cx, &|ws, _w, _cx| { + ws.right_drag = Some(SideDrag { x: 1000.0, width: RIGHT_MENU_W }); + ws.drag_right(960.0, 1600.0); + assert_eq!(ws.right_width(1600.0), RIGHT_MENU_W + 40.0); + ws.drag_right(5000.0, 1600.0); + assert_eq!(ws.right_width(1600.0), RIGHT_MENU_MIN); + ws.drag_right(-5000.0, 1600.0); + assert_eq!(ws.right_width(1600.0), RIGHT_MENU_MAX); + ws.drag_right(960.0, 1600.0); + ws.right_drag = None; + assert_eq!(ws.left_width(1600.0), SIDEBAR_W); + ws.left_drag = Some(SideDrag { x: 300.0, width: SIDEBAR_W }); + ws.drag_left(350.0, 1600.0); + assert_eq!(ws.left_width(1600.0), SIDEBAR_W + 50.0); + ws.drag_left(0.0, 1600.0); + assert_eq!(ws.left_width(1600.0), SIDEBAR_MIN); + ws.drag_left(5000.0, 1600.0); + assert_eq!(ws.left_width(1600.0), SIDEBAR_MAX); + assert_eq!(ws.left_width(700.0), SIDEBAR_MIN, "keeps room for the session in a small window"); + ws.left_drag = None; + }); step(&mut cx, &|ws, w, cx| ws.open_github(cwd.clone(), w, cx)); assert!(ws.read_with(&cx, |ws, _| ws.gh.len() == 1 && ws.right_gh.is_some()), "github shown in the right sidebar"); - assert_eq!(ws.read_with(&cx, |ws, _| ws.right_width(1600.0)), RIGHT_GH_W); + assert_eq!(ws.read_with(&cx, |ws, _| ws.right_width(1600.0)), RIGHT_GH_W, "GitHub keeps its own width"); step(&mut cx, &|ws, _w, _cx| { - ws.right_drag = Some(RightDrag { x: 1000.0, width: RIGHT_GH_W }); + ws.right_drag = Some(SideDrag { x: 1000.0, width: RIGHT_GH_W }); ws.drag_right(900.0, 1600.0); assert_eq!(ws.right_width(1600.0), RIGHT_GH_W + 100.0); ws.drag_right(5000.0, 1600.0); diff --git a/src/inspector.rs b/src/inspector.rs index 8c43d4a..a3c08ea 100644 --- a/src/inspector.rs +++ b/src/inspector.rs @@ -8,7 +8,7 @@ use gpui::{ StatefulInteractiveElement, Styled, Window, div, px, }; -use crate::app::{Act, GitOp, MenuItem, RightDrag, Workspace}; +use crate::app::{Act, GitOp, MenuItem, SideDrag, Workspace}; use crate::platform::Editor; use crate::store::{Attached, Id, Project, SessionKind, SessionRecord}; use crate::theme::{self, hsla}; @@ -77,8 +77,8 @@ impl Workspace { } None => self.render_right_menu(window, cx).into_any_element(), }; - // The wide GitHub view can be resized by its left edge; the menu has one width. - let handle = self.right_gh.is_some().then(|| { + // Both views can be resized by their left edge. + let handle = Some( div() .id("right-resize") .absolute() @@ -90,11 +90,11 @@ impl Workspace { .on_mouse_down( MouseButton::Left, cx.listener(move |ws, ev: &MouseDownEvent, _w, cx| { - ws.right_drag = Some(RightDrag { x: f32::from(ev.position.x), width }); + ws.right_drag = Some(SideDrag { x: f32::from(ev.position.x), width }); cx.notify(); }), - ) - }); + ), + ); Some( div() .id("right-sidebar") diff --git a/src/sidebar.rs b/src/sidebar.rs index 30b456e..c7b2218 100644 --- a/src/sidebar.rs +++ b/src/sidebar.rs @@ -10,13 +10,15 @@ use gpui::{ use gpui_kit::component::input::Input; use crate::chat::store::ChatRecord; -use crate::app::{Act, Activity, MenuItem, Workspace}; +use crate::app::{Act, Activity, MenuItem, SideDrag, Workspace}; use crate::store::{ExternalState, Id, Project, SessionKind, SessionRecord, now}; use crate::theme::{self, hsla}; use gpui_kit::assets::IconName; use crate::widgets::{ago, avatar, button, clawd, countdown, icon, icon_button, meter, section_label, spinner, tick}; pub const SIDEBAR_W: f32 = 284.0; +pub const SIDEBAR_MIN: f32 = 220.0; +pub const SIDEBAR_MAX: f32 = 520.0; /// Entries shown under RECENT before the rest go behind OLDER. const RECENT_LIMIT: usize = 12; @@ -554,12 +556,30 @@ impl Workspace { /// The sidebar chrome around either list: header, scrolling body, usage footer. fn sidebar_frame(&mut self, body: Div, window: &mut Window, cx: &mut Context) -> Stateful
{ + let width = self.left_width(f32::from(window.viewport_size().width)); + // The right edge is the drag handle (inside the sidebar, so the terminal beside it cannot cover it). + let handle = div() + .id("left-resize") + .absolute() + .top_0() + .right_0() + .w(px(5.0)) + .h_full() + .cursor_col_resize() + .on_mouse_down( + MouseButton::Left, + cx.listener(move |ws, ev: &MouseDownEvent, _w, cx| { + ws.left_drag = Some(SideDrag { x: f32::from(ev.position.x), width }); + cx.notify(); + }), + ); div() .id("sidebar") + .relative() .flex() .flex_col() .flex_none() - .w(px(SIDEBAR_W)) + .w(px(width)) .h_full() .bg(hsla(theme::SIDEBAR_BG)) .border_r_1() @@ -583,6 +603,7 @@ impl Workspace { .child(self.render_sidebar_header(cx)) .child(self.sidebar_scroll.wire(div().id("sidebar-scroll").flex_1().min_h_0(), window).pb(px(10.0)).child(body)) .child(self.render_footer(cx)) + .child(handle) } fn render_sidebar_header(&mut self, cx: &mut Context) -> impl IntoElement + use<> { diff --git a/src/store.rs b/src/store.rs index 9f7abc4..50f5ab9 100644 --- a/src/store.rs +++ b/src/store.rs @@ -215,9 +215,15 @@ pub struct Layout { /// The right sidebar is hidden (stored negated so older state files keep it on). #[serde(default)] pub right_hidden: bool, - /// Width of the right sidebar while it shows GitHub; the menu has a fixed width. + /// Width of the right sidebar while it shows GitHub; the menu keeps its own, `right_menu_w`. #[serde(default)] pub right_gh_w: Option, + /// Width of the left sidebar when the user has dragged it; the default otherwise. + #[serde(default)] + pub left_w: Option, + /// Width of the right sidebar's menu when the user has dragged it; the default otherwise. + #[serde(default)] + pub right_menu_w: Option, } #[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)] diff --git a/src/views.rs b/src/views.rs index 2e42a4e..f7f482b 100644 --- a/src/views.rs +++ b/src/views.rs @@ -608,22 +608,24 @@ impl Render for Workspace { .on_action(cx.listener(|ws, _: &OpenSettings, window, cx| ws.act(Act::OpenSettings, window, cx))) .on_action(cx.listener(|ws, _: &SwapFocus, window, cx| ws.swap_focus(window, cx))) .on_mouse_move(cx.listener(|ws, ev: &gpui::MouseMoveEvent, window, cx| { - if ws.shell_drag.is_none() && ws.right_drag.is_none() { + if ws.shell_drag.is_none() && ws.right_drag.is_none() && ws.left_drag.is_none() { return; } // The button was let go outside the window: stop following the pointer. if ev.pressed_button != Some(MouseButton::Left) { ws.shell_drag = None; ws.right_drag = None; + ws.left_drag = None; } else { let size = window.viewport_size(); ws.drag_shell(f32::from(ev.position.y), f32::from(size.height)); ws.drag_right(f32::from(ev.position.x), f32::from(size.width)); + ws.drag_left(f32::from(ev.position.x), f32::from(size.width)); } cx.notify(); })) .on_mouse_up(MouseButton::Left, cx.listener(|ws, _: &gpui::MouseUpEvent, _w, cx| { - if ws.shell_drag.take().is_some() | ws.right_drag.take().is_some() { + if ws.shell_drag.take().is_some() | ws.right_drag.take().is_some() | ws.left_drag.take().is_some() { cx.notify(); } }))