on main help sign in
fix(ui): dialog: show shortcut/info in list items
commit179e17f64604c2facf843199b069d23c08a5155c authorAyman Bagabas <ayman.bagabas@gmail.com> dateThu 18 Dec 2025, 15:57 (1 year ago) parentb449545
3 files changed+14−13
internal/ui/dialog/commands_item.go+1−1 internal/ui/dialog/models_item.go+1−1 internal/ui/dialog/sessions_item.go+12−11
internal/ui/dialog/commands_item.go+1−1
@@ -51,5 +51,5 @@ func (c *CommandItem) SetMatch(m fuzzy.Match) {
5151
5252// Render implements ListItem.
5353func (c *CommandItem) Render(width int) string {
54− return renderItem(c.t, c.Cmd.Title, 0, c.focused, width, c.cache, &c.m)
54+ return renderItem(c.t, c.Cmd.Title, c.Cmd.Shortcut, c.focused, width, c.cache, &c.m)
5555}
internal/ui/dialog/models_item.go+1−1
@@ -81,7 +81,7 @@ func (m *ModelItem) ID() string {
8181
8282// Render implements ListItem.
8383func (m *ModelItem) Render(width int) string {
84− return renderItem(m.t, m.model.Name, 0, m.focused, width, m.cache, &m.m)
84+ return renderItem(m.t, m.model.Name, "", m.focused, width, m.cache, &m.m)
8585}
8686
8787// SetFocused implements ListItem.
internal/ui/dialog/sessions_item.go+12−11
@@ -54,10 +54,11 @@ func (s *SessionItem) SetMatch(m fuzzy.Match) {
5454
5555// Render returns the string representation of the session item.
5656func (s *SessionItem) Render(width int) string {
57− return renderItem(s.t, s.Title, s.UpdatedAt, s.focused, width, s.cache, &s.m)
57+ info := humanize.Time(time.Unix(s.UpdatedAt, 0))
58+ return renderItem(s.t, s.Title, info, s.focused, width, s.cache, &s.m)
5859}
5960
60−func renderItem(t *styles.Styles, title string, updatedAt int64, focused bool, width int, cache map[int]string, m *fuzzy.Match) string {
61+func renderItem(t *styles.Styles, title string, info string, focused bool, width int, cache map[int]string, m *fuzzy.Match) string {
6162 if cache == nil {
6263 cache = make(map[int]string)
6364 }
@@ -72,23 +73,23 @@ func renderItem(t *styles.Styles, title string, updatedAt int64, focused bool, w
7273 style = t.Dialog.SelectedItem
7374 }
7475
75− var age string
76− var ageLen int
76+ var infoText string
77+ var infoLen int
7778 lineWidth := width
78− if updatedAt > 0 {
79− age = fmt.Sprintf(" %s ", humanize.Time(time.Unix(updatedAt, 0)))
79+ if len(info) > 0 {
80+ infoText = fmt.Sprintf(" %s ", info)
8081 if focused {
81− age = t.Base.Render(age)
82+ infoText = t.Base.Render(infoText)
8283 } else {
83− age = t.Subtle.Render(age)
84+ infoText = t.Subtle.Render(infoText)
8485 }
8586
86− ageLen = lipgloss.Width(age)
87+ infoLen = lipgloss.Width(infoText)
8788 }
8889
8990 title = ansi.Truncate(title, max(0, lineWidth), "")
9091 titleLen := lipgloss.Width(title)
91− gap := strings.Repeat(" ", max(0, lineWidth-titleLen-ageLen))
92+ gap := strings.Repeat(" ", max(0, lineWidth-titleLen-infoLen))
9293 content := title
9394 if matches := len(m.MatchedIndexes); matches > 0 {
9495 var lastPos int
@@ -118,7 +119,7 @@ func renderItem(t *styles.Styles, title string, updatedAt int64, focused bool, w
118119 content = strings.Join(parts, "")
119120 }
120121
121− content = style.Render(content + gap + age)
122+ content = style.Render(content + gap + infoText)
122123 cache[width] = content
123124 return content
124125}