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 <noreply@anthropic.com>
This commit is contained in:
nemunaire 2026-03-29 19:43:58 +07:00
commit 9c0ca254f5
2 changed files with 20 additions and 2 deletions

View file

@ -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
}