fix(mail): filter unread messages in beads mode

ListUnread() was returning all messages in beads mode instead of
filtering by the Read field. Apply the same filtering logic used
in legacy mode to both code paths.

Fixes #595

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
gastown/crew/dennis
2026-01-16 14:38:53 -08:00
committed by Steve Yegge
parent 29039ed69d
commit a88d2e1a9e

View File

@@ -250,21 +250,17 @@ func (m *Mailbox) listLegacy() ([]*Message, error) {
// ListUnread returns unread (open) messages.
func (m *Mailbox) ListUnread() ([]*Message, error) {
if m.legacy {
all, err := m.List()
if err != nil {
return nil, err
}
var unread []*Message
for _, msg := range all {
if !msg.Read {
unread = append(unread, msg)
}
}
return unread, nil
all, err := m.List()
if err != nil {
return nil, err
}
// For beads, inbox only returns open (unread) messages
return m.List()
var unread []*Message
for _, msg := range all {
if !msg.Read {
unread = append(unread, msg)
}
}
return unread, nil
}
// Get returns a message by ID.