From ab731f06fdb7e42d9879328f069201d4d4a1f1a6 Mon Sep 17 00:00:00 2001 From: Evan Genske <87594408+DavyJonesStockings@users.noreply.github.com> Date: Mon, 15 Jun 2026 21:46:25 -0400 Subject: [PATCH] feat(chat): add sidebar.width_percent field for guilds tree width (#805) Co-authored-by: ayn2op --- internal/config/config.go | 15 +++++++++++++-- internal/config/config.toml | 5 +++++ internal/ui/chat/model.go | 4 ++-- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/internal/config/config.go b/internal/config/config.go index d4ded89..d25830e 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -96,8 +96,11 @@ type ( } SidebarConfig struct { - Markers SidebarMarkersConfig `toml:"markers"` - Indents SidebarIndentsConfig `toml:"indents"` + // WidthPercent is the percentage (%) of the total + // window width that the guilds tree sidebar occupies + WidthPercent int `toml:"width_percent"` + Markers SidebarMarkersConfig `toml:"markers"` + Indents SidebarIndentsConfig `toml:"indents"` } Config struct { @@ -182,6 +185,14 @@ func applyDefaults(cfg *Config) { cfg.Composer.MaxHeight = 10 } + if cfg.Sidebar.WidthPercent <= 0 || cfg.Sidebar.WidthPercent >= 100 { + // these guidelines are simply to guarantee functionality; + // there's no guarantee that there's functional utility in + // setting an extremely low width, but that's for the + // user to decide. + cfg.Sidebar.WidthPercent = 20 + } + if cfg.DateSeparator.Format == "" { cfg.DateSeparator.Format = "January 2, 2006" } diff --git a/internal/config/config.toml b/internal/config/config.toml index 159e28d..0b837c6 100644 --- a/internal/config/config.toml +++ b/internal/config/config.toml @@ -68,6 +68,11 @@ send = true # Whether to receive typing status or not. receive = true +[sidebar] +# Percentage (%) of the available width used by the guilds tree sidebar. +# Valid values are 1-99. Invalid values fall back to 20. +width_percent = 20 + [sidebar.markers] expanded = "▾ " collapsed = "▸ " diff --git a/internal/ui/chat/model.go b/internal/ui/chat/model.go index d193da3..41fe91b 100644 --- a/internal/ui/chat/model.go +++ b/internal/ui/chat/model.go @@ -138,8 +138,8 @@ func (m *Model) buildLayout() { AddItem(m.composer, 3, 1, false) // The guilds tree is always focused first at start-up. m.mainFlex. - AddItem(m.guildsTree, 0, 1, true). - AddItem(m.rightFlex, 0, 4, false) + AddItem(m.guildsTree, 0, m.cfg.Sidebar.WidthPercent, true). + AddItem(m.rightFlex, 0, 100-m.cfg.Sidebar.WidthPercent, false) m.AddLayer(m.mainFlex, layers.WithName(flexLayerName), layers.WithResize(true), layers.WithVisible(true)) m.AddLayer(