From dea868309bdac6f08170d4834b1d993ccff362a0 Mon Sep 17 00:00:00 2001 From: drew Date: Wed, 21 Jan 2026 14:29:20 +0400 Subject: [PATCH 1/2] fix!: images not clearing --- tui/email_view.go | 42 +++++++++++++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/tui/email_view.go b/tui/email_view.go index 6ba73fc..3168f4a 100644 --- a/tui/email_view.go +++ b/tui/email_view.go @@ -3,6 +3,7 @@ package tui import ( "encoding/base64" "fmt" + "os" "strings" "github.com/charmbracelet/bubbles/viewport" @@ -12,6 +13,14 @@ import ( "github.com/floatpane/matcha/view" ) +// clearKittyGraphics sends the Kitty graphics protocol delete command directly to stdout +func clearKittyGraphics() tea.Msg { + // Delete all images: a=d (action=delete), d=A (delete all) + os.Stdout.WriteString("\x1b_Ga=d,d=A\x1b\\") + os.Stdout.Sync() + return nil +} + var ( emailHeaderStyle = lipgloss.NewStyle().BorderStyle(lipgloss.NormalBorder()).BorderBottom(true).Padding(0, 1) attachmentBoxStyle = lipgloss.NewStyle().Border(lipgloss.NormalBorder(), false, false, false, true).PaddingLeft(2).MarginTop(1) @@ -74,8 +83,11 @@ func (m *EmailView) Update(msg tea.Msg) (tea.Model, tea.Cmd) { m.focusOnAttachments = false return m, nil } - m.viewport.SetContent("\x1b_Ga=d\x1b\\") - return m, func() tea.Msg { return BackToMailboxMsg{Mailbox: m.mailbox} } + // Clear Kitty graphics before returning to mailbox + return m, tea.Sequence( + clearKittyGraphics, + func() tea.Msg { return BackToMailboxMsg{Mailbox: m.mailbox} }, + ) } if m.focusOnAttachments { @@ -110,19 +122,31 @@ func (m *EmailView) Update(msg tea.Msg) (tea.Model, tea.Cmd) { } else { switch msg.String() { case "r": - return m, func() tea.Msg { return ReplyToEmailMsg{Email: m.email} } + // Clear Kitty graphics before opening composer + return m, tea.Sequence( + clearKittyGraphics, + func() tea.Msg { return ReplyToEmailMsg{Email: m.email} }, + ) case "d": accountID := m.accountID uid := m.email.UID - return m, func() tea.Msg { - return DeleteEmailMsg{UID: uid, AccountID: accountID, Mailbox: m.mailbox} - } + // Clear Kitty graphics before transitioning + return m, tea.Sequence( + clearKittyGraphics, + func() tea.Msg { + return DeleteEmailMsg{UID: uid, AccountID: accountID, Mailbox: m.mailbox} + }, + ) case "a": accountID := m.accountID uid := m.email.UID - return m, func() tea.Msg { - return ArchiveEmailMsg{UID: uid, AccountID: accountID, Mailbox: m.mailbox} - } + // Clear Kitty graphics before transitioning + return m, tea.Sequence( + clearKittyGraphics, + func() tea.Msg { + return ArchiveEmailMsg{UID: uid, AccountID: accountID, Mailbox: m.mailbox} + }, + ) case "tab": if len(m.email.Attachments) > 0 { m.focusOnAttachments = true From 6003e8599adb87fade04dd38842dc92af2bad7d3 Mon Sep 17 00:00:00 2001 From: drew Date: Wed, 21 Jan 2026 15:09:09 +0400 Subject: [PATCH 2/2] fix: tests --- tui/email_view.go | 35 +++++++++++++---------------------- 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/tui/email_view.go b/tui/email_view.go index 3168f4a..3a519eb 100644 --- a/tui/email_view.go +++ b/tui/email_view.go @@ -14,11 +14,10 @@ import ( ) // clearKittyGraphics sends the Kitty graphics protocol delete command directly to stdout -func clearKittyGraphics() tea.Msg { +func clearKittyGraphics() { // Delete all images: a=d (action=delete), d=A (delete all) os.Stdout.WriteString("\x1b_Ga=d,d=A\x1b\\") os.Stdout.Sync() - return nil } var ( @@ -84,10 +83,8 @@ func (m *EmailView) Update(msg tea.Msg) (tea.Model, tea.Cmd) { return m, nil } // Clear Kitty graphics before returning to mailbox - return m, tea.Sequence( - clearKittyGraphics, - func() tea.Msg { return BackToMailboxMsg{Mailbox: m.mailbox} }, - ) + clearKittyGraphics() + return m, func() tea.Msg { return BackToMailboxMsg{Mailbox: m.mailbox} } } if m.focusOnAttachments { @@ -123,30 +120,24 @@ func (m *EmailView) Update(msg tea.Msg) (tea.Model, tea.Cmd) { switch msg.String() { case "r": // Clear Kitty graphics before opening composer - return m, tea.Sequence( - clearKittyGraphics, - func() tea.Msg { return ReplyToEmailMsg{Email: m.email} }, - ) + clearKittyGraphics() + return m, func() tea.Msg { return ReplyToEmailMsg{Email: m.email} } case "d": accountID := m.accountID uid := m.email.UID // Clear Kitty graphics before transitioning - return m, tea.Sequence( - clearKittyGraphics, - func() tea.Msg { - return DeleteEmailMsg{UID: uid, AccountID: accountID, Mailbox: m.mailbox} - }, - ) + clearKittyGraphics() + return m, func() tea.Msg { + return DeleteEmailMsg{UID: uid, AccountID: accountID, Mailbox: m.mailbox} + } case "a": accountID := m.accountID uid := m.email.UID // Clear Kitty graphics before transitioning - return m, tea.Sequence( - clearKittyGraphics, - func() tea.Msg { - return ArchiveEmailMsg{UID: uid, AccountID: accountID, Mailbox: m.mailbox} - }, - ) + clearKittyGraphics() + return m, func() tea.Msg { + return ArchiveEmailMsg{UID: uid, AccountID: accountID, Mailbox: m.mailbox} + } case "tab": if len(m.email.Attachments) > 0 { m.focusOnAttachments = true