on main help sign in
Merge pull request #2191 from charmbracelet/charm-1152-sessions-dialog-is-too-big

fix(ui): adjust sessions dialog size

commitd320f1293f4755b6f185f84f31d3612ea5333ae5 authorAyman Bagabas <ayman.bagabas@gmail.com> dateWed 11 Feb 2026, 17:51 (8 months ago) parent8a6f25f361a318
5 files changed+22−30
internal/ui/dialog/commands.go+7−11 internal/ui/dialog/dialog.go+2−2 internal/ui/dialog/models.go+4−6 internal/ui/dialog/sessions.go+7−9 internal/ui/dialog/sessions_item.go+2−2
internal/ui/dialog/commands.go+7−11
@@ -27,9 +27,7 @@ type CommandType uint
2727func (c CommandType) String() string { return []string{"System", "User", "MCP"}[c] }
2828
2929const (
30− sidebarCompactModeBreakpoint = 120
31− defaultCommandsDialogMaxHeight = 20
32− defaultCommandsDialogMaxWidth = 70
30+ sidebarCompactModeBreakpoint = 120
3331)
3432
3533const (
@@ -155,19 +153,17 @@ func (c *Commands) HandleMsg(msg tea.Msg) Action {
155153 c.list.Focus()
156154 if c.list.IsSelectedFirst() {
157155 c.list.SelectLast()
158− c.list.ScrollToBottom()
159− break
156+ } else {
157+ c.list.SelectPrev()
160158 }
161− c.list.SelectPrev()
162159 c.list.ScrollToSelected()
163160 case key.Matches(msg, c.keyMap.Next):
164161 c.list.Focus()
165162 if c.list.IsSelectedLast() {
166163 c.list.SelectFirst()
167− c.list.ScrollToTop()
168− break
164+ } else {
165+ c.list.SelectNext()
169166 }
170− c.list.SelectNext()
171167 c.list.ScrollToSelected()
172168 case key.Matches(msg, c.keyMap.Select):
173169 if selectedItem := c.list.SelectedItem(); selectedItem != nil {
@@ -240,8 +236,8 @@ func commandsRadioView(sty *styles.Styles, selected CommandType, hasUserCmds boo
240236// Draw implements [Dialog].
241237func (c *Commands) Draw(scr uv.Screen, area uv.Rectangle) *tea.Cursor {
242238 t := c.com.Styles
243− width := max(0, min(defaultCommandsDialogMaxWidth, area.Dx()-t.Dialog.View.GetHorizontalBorderSize()))
244− height := max(0, min(defaultCommandsDialogMaxHeight, area.Dy()-t.Dialog.View.GetVerticalBorderSize()))
239+ width := max(0, min(defaultDialogMaxWidth, area.Dx()-t.Dialog.View.GetHorizontalBorderSize()))
240+ height := max(0, min(defaultDialogHeight, area.Dy()-t.Dialog.View.GetVerticalBorderSize()))
245241 if area.Dx() != c.windowWidth && c.selected == SystemCommands {
246242 c.windowWidth = area.Dx()
247243 // since some items in the list depend on width (e.g. toggle sidebar command),
internal/ui/dialog/dialog.go+2−2
@@ -11,9 +11,9 @@ import (
1111// Dialog sizing constants.
1212const (
1313 // defaultDialogMaxWidth is the maximum width for standard dialogs.
14− defaultDialogMaxWidth = 120
14+ defaultDialogMaxWidth = 70
1515 // defaultDialogHeight is the default height for standard dialogs.
16− defaultDialogHeight = 30
16+ defaultDialogHeight = 20
1717 // titleContentHeight is the height of the title content line.
1818 titleContentHeight = 1
1919 // inputContentHeight is the height of the input content line.
internal/ui/dialog/models.go+4−6
@@ -174,19 +174,17 @@ func (m *Models) HandleMsg(msg tea.Msg) Action {
174174 m.list.Focus()
175175 if m.list.IsSelectedFirst() {
176176 m.list.SelectLast()
177− m.list.ScrollToBottom()
178− break
177+ } else {
178+ m.list.SelectPrev()
179179 }
180− m.list.SelectPrev()
181180 m.list.ScrollToSelected()
182181 case key.Matches(msg, m.keyMap.Next):
183182 m.list.Focus()
184183 if m.list.IsSelectedLast() {
185184 m.list.SelectFirst()
186− m.list.ScrollToTop()
187− break
185+ } else {
186+ m.list.SelectNext()
188187 }
189− m.list.SelectNext()
190188 m.list.ScrollToSelected()
191189 case key.Matches(msg, m.keyMap.Select, m.keyMap.Edit):
192190 selectedItem := m.list.SelectedItem()
internal/ui/dialog/sessions.go+7−9
@@ -190,19 +190,17 @@ func (s *Session) HandleMsg(msg tea.Msg) Action {
190190 s.list.Focus()
191191 if s.list.IsSelectedFirst() {
192192 s.list.SelectLast()
193− s.list.ScrollToBottom()
194− break
193+ } else {
194+ s.list.SelectPrev()
195195 }
196− s.list.SelectPrev()
197196 s.list.ScrollToSelected()
198197 case key.Matches(msg, s.keyMap.Next):
199198 s.list.Focus()
200199 if s.list.IsSelectedLast() {
201200 s.list.SelectFirst()
202− s.list.ScrollToTop()
203− break
201+ } else {
202+ s.list.SelectNext()
204203 }
205− s.list.SelectNext()
206204 s.list.ScrollToSelected()
207205 case key.Matches(msg, s.keyMap.Select):
208206 if item := s.list.SelectedItem(); item != nil {
@@ -231,9 +229,9 @@ func (s *Session) Cursor() *tea.Cursor {
231229// Draw implements [Dialog].
232230func (s *Session) Draw(scr uv.Screen, area uv.Rectangle) *tea.Cursor {
233231 t := s.com.Styles
234− width := max(0, min(defaultDialogMaxWidth, area.Dx()))
235− height := max(0, min(defaultDialogHeight, area.Dy()))
236− innerWidth := width - t.Dialog.View.GetHorizontalFrameSize() - 2
232+ width := max(0, min(defaultDialogMaxWidth, area.Dx()-t.Dialog.View.GetHorizontalBorderSize()))
233+ height := max(0, min(defaultDialogHeight, area.Dy()-t.Dialog.View.GetVerticalBorderSize()))
234+ innerWidth := width - t.Dialog.View.GetHorizontalFrameSize()
237235 heightOffset := t.Dialog.Title.GetVerticalFrameSize() + titleContentHeight +
238236 t.Dialog.InputPrompt.GetVerticalFrameSize() + inputContentHeight +
239237 t.Dialog.HelpView.GetVerticalFrameSize() +
internal/ui/dialog/sessions_item.go+2−2
@@ -137,7 +137,7 @@ func renderItem(t ListItemStyles, title string, info string, focused bool, width
137137 infoWidth = lipgloss.Width(infoText)
138138 }
139139
140− title = ansi.Truncate(title, max(0, lineWidth-infoWidth), "")
140+ title = ansi.Truncate(title, max(0, lineWidth-infoWidth), "…")
141141 titleWidth := lipgloss.Width(title)
142142 gap := strings.Repeat(" ", max(0, lineWidth-titleWidth-infoWidth))
143143 content := title
@@ -154,7 +154,7 @@ func renderItem(t ListItemStyles, title string, info string, focused bool, width
154154 // because we can control the underline start and stop more
155155 // precisely via [ansi.AttrUnderline] and [ansi.AttrNoUnderline]
156156 // which only affect the underline attribute without interfering
157− // with other style
157+ // with other style attributes.
158158 parts = append(parts,
159159 ansi.NewStyle().Underline(true).String(),
160160 ansi.Cut(title, start, stop+1),