diff --git a/internal/ui/dialog/commands_item.go b/internal/ui/dialog/commands_item.go index 79f0aa047ee22a691d117014c33bc7e551b1a29b..408fe70865bfb02ce446c57c32c2b3d79bfd8fe5 100644 --- a/internal/ui/dialog/commands_item.go +++ b/internal/ui/dialog/commands_item.go @@ -51,5 +51,5 @@ func (c *CommandItem) SetMatch(m fuzzy.Match) { // Render implements ListItem. func (c *CommandItem) Render(width int) string { - return renderItem(c.t, c.Cmd.Title, 0, c.focused, width, c.cache, &c.m) + return renderItem(c.t, c.Cmd.Title, c.Cmd.Shortcut, c.focused, width, c.cache, &c.m) } diff --git a/internal/ui/dialog/models_item.go b/internal/ui/dialog/models_item.go index 7dfe98d986a38cfefeee12151deb40722227287b..1493bce8458f117068a8a68e7d2439b2b4b56432 100644 --- a/internal/ui/dialog/models_item.go +++ b/internal/ui/dialog/models_item.go @@ -81,7 +81,7 @@ func (m *ModelItem) ID() string { // Render implements ListItem. func (m *ModelItem) Render(width int) string { - return renderItem(m.t, m.model.Name, 0, m.focused, width, m.cache, &m.m) + return renderItem(m.t, m.model.Name, "", m.focused, width, m.cache, &m.m) } // SetFocused implements ListItem. diff --git a/internal/ui/dialog/sessions_item.go b/internal/ui/dialog/sessions_item.go index 23434bf53e0cd53bb6dc863ac7903c1acf6766f4..ddff75806e8345ca1140622739933c31055658e6 100644 --- a/internal/ui/dialog/sessions_item.go +++ b/internal/ui/dialog/sessions_item.go @@ -54,10 +54,11 @@ func (s *SessionItem) SetMatch(m fuzzy.Match) { // Render returns the string representation of the session item. func (s *SessionItem) Render(width int) string { - return renderItem(s.t, s.Title, s.UpdatedAt, s.focused, width, s.cache, &s.m) + info := humanize.Time(time.Unix(s.UpdatedAt, 0)) + return renderItem(s.t, s.Title, info, s.focused, width, s.cache, &s.m) } -func renderItem(t *styles.Styles, title string, updatedAt int64, focused bool, width int, cache map[int]string, m *fuzzy.Match) string { +func renderItem(t *styles.Styles, title string, info string, focused bool, width int, cache map[int]string, m *fuzzy.Match) string { if cache == nil { cache = make(map[int]string) } @@ -72,23 +73,23 @@ func renderItem(t *styles.Styles, title string, updatedAt int64, focused bool, w style = t.Dialog.SelectedItem } - var age string - var ageLen int + var infoText string + var infoLen int lineWidth := width - if updatedAt > 0 { - age = fmt.Sprintf(" %s ", humanize.Time(time.Unix(updatedAt, 0))) + if len(info) > 0 { + infoText = fmt.Sprintf(" %s ", info) if focused { - age = t.Base.Render(age) + infoText = t.Base.Render(infoText) } else { - age = t.Subtle.Render(age) + infoText = t.Subtle.Render(infoText) } - ageLen = lipgloss.Width(age) + infoLen = lipgloss.Width(infoText) } title = ansi.Truncate(title, max(0, lineWidth), "") titleLen := lipgloss.Width(title) - gap := strings.Repeat(" ", max(0, lineWidth-titleLen-ageLen)) + gap := strings.Repeat(" ", max(0, lineWidth-titleLen-infoLen)) content := title if matches := len(m.MatchedIndexes); matches > 0 { var lastPos int @@ -118,7 +119,7 @@ func renderItem(t *styles.Styles, title string, updatedAt int64, focused bool, w content = strings.Join(parts, "") } - content = style.Render(content + gap + age) + content = style.Render(content + gap + infoText) cache[width] = content return content }