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:
parent
70b0eedb9c
commit
9c0ca254f5
2 changed files with 20 additions and 2 deletions
21
model.go
21
model.go
|
|
@ -10,6 +10,7 @@ import (
|
||||||
"github.com/charmbracelet/bubbles/textinput"
|
"github.com/charmbracelet/bubbles/textinput"
|
||||||
"github.com/charmbracelet/bubbles/viewport"
|
"github.com/charmbracelet/bubbles/viewport"
|
||||||
tea "github.com/charmbracelet/bubbletea"
|
tea "github.com/charmbracelet/bubbletea"
|
||||||
|
"github.com/charmbracelet/lipgloss"
|
||||||
"github.com/charmbracelet/x/ansi"
|
"github.com/charmbracelet/x/ansi"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -366,7 +367,17 @@ func (m Model) View() string {
|
||||||
return m.list.View() + "\n" + m.renderBottom()
|
return m.list.View() + "\n" + m.renderBottom()
|
||||||
|
|
||||||
case stateMessage:
|
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)
|
scrollPct := int(m.viewport.ScrollPercent() * 100)
|
||||||
headersHint := "H: full headers"
|
headersHint := "H: full headers"
|
||||||
if m.showFullHeaders {
|
if m.showFullHeaders {
|
||||||
|
|
@ -452,7 +463,13 @@ func (m Model) renderBottom() string {
|
||||||
label := fmt.Sprintf(" Fetching subjects: %d / %d ", m.loadingDone, m.loadingTotal)
|
label := fmt.Sprintf(" Fetching subjects: %d / %d ", m.loadingDone, m.loadingTotal)
|
||||||
return dimStyle.Render(label) + "\n " + m.progress.View()
|
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())),
|
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
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,4 +12,5 @@ var (
|
||||||
partSepStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("240"))
|
partSepStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("240"))
|
||||||
attachStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("214"))
|
attachStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("214"))
|
||||||
headerKeyStyle = lipgloss.NewStyle().Bold(true)
|
headerKeyStyle = lipgloss.NewStyle().Bold(true)
|
||||||
|
reasonStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("196"))
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue