From 9c0ca254f5f8a92d70a0ce6e73f21dd90d9ba058 Mon Sep 17 00:00:00 2001 From: Pierre-Olivier Mercier Date: Sun, 29 Mar 2026 19:43:58 +0700 Subject: [PATCH] Show delivery failure reason in message view header Display the postqueue failure reason right-aligned in red on the message header line so it's immediately visible when viewing a message. Co-Authored-By: Claude Sonnet 4.6 --- model.go | 21 +++++++++++++++++++-- styles.go | 1 + 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/model.go b/model.go index ddf4db9..197b432 100644 --- a/model.go +++ b/model.go @@ -10,6 +10,7 @@ import ( "github.com/charmbracelet/bubbles/textinput" "github.com/charmbracelet/bubbles/viewport" tea "github.com/charmbracelet/bubbletea" + "github.com/charmbracelet/lipgloss" "github.com/charmbracelet/x/ansi" ) @@ -366,7 +367,17 @@ func (m Model) View() string { return m.list.View() + "\n" + m.renderBottom() case stateMessage: - header := titleStyle.Render(fmt.Sprintf("Message: %s", m.currentID)) + title := titleStyle.Render(fmt.Sprintf("Message: %s", m.currentID)) + header := title + if idx, ok := m.entryIndex[m.currentID]; ok { + if reason := m.entries[idx].Reason; reason != "" { + gap := m.width - lipgloss.Width(title) - lipgloss.Width(reason) - 2 + if gap < 1 { + gap = 1 + } + header = title + strings.Repeat(" ", gap) + reasonStyle.Render(reason) + } + } scrollPct := int(m.viewport.ScrollPercent() * 100) headersHint := "H: full headers" if m.showFullHeaders { @@ -452,7 +463,13 @@ func (m Model) renderBottom() string { label := fmt.Sprintf(" Fetching subjects: %d / %d ", m.loadingDone, m.loadingTotal) return dimStyle.Render(label) + "\n " + m.progress.View() } - return statusBarStyle.Render( + status := statusBarStyle.Render( fmt.Sprintf(" %d message(s) │ Enter: open │ r: refresh │ q: quit ", len(m.list.Items())), ) + if item, ok := m.list.SelectedItem().(queueItem); ok { + if reason := item.entry.Reason; reason != "" { + return status + "\n " + reasonStyle.Render(reason) + } + } + return status } diff --git a/styles.go b/styles.go index c748b33..cffc818 100644 --- a/styles.go +++ b/styles.go @@ -12,4 +12,5 @@ var ( partSepStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("240")) attachStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("214")) headerKeyStyle = lipgloss.NewStyle().Bold(true) + reasonStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("196")) )