fix: recover orphaned mail migration to bd v0.32.0

The merge at 96c773f lost changes from 5791752 (beads-sync branch).
Re-implementing:
- router.go: Use bd create --type=message with labels
- mailbox.go: Use bd list/show/close instead of bd mail commands
- types.go: Add Pinned field to Message struct

Original work was in commits 5791752 and 4c060f4 on beads-sync.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Steve Yegge
2025-12-20 22:01:16 -08:00
parent 1cc20efc40
commit 7e16ac4800
3 changed files with 37 additions and 27 deletions
+18 -19
View File
@@ -105,31 +105,31 @@ func isTownLevelAddress(address string) bool {
func (r *Router) Send(msg *Message) error {
// Convert addresses to beads identities
toIdentity := addressToIdentity(msg.To)
fromIdentity := addressToIdentity(msg.From)
// Build command: bd mail send <recipient> -s <subject> -m <body>
args := []string{"mail", "send", toIdentity,
"-s", msg.Subject,
"-m", msg.Body,
// Build labels for from/thread/reply-to
var labels []string
labels = append(labels, "from:"+msg.From)
if msg.ThreadID != "" {
labels = append(labels, "thread:"+msg.ThreadID)
}
if msg.ReplyTo != "" {
labels = append(labels, "reply-to:"+msg.ReplyTo)
}
// Build command: bd create <subject> --type=message --assignee=<recipient> -d <body>
args := []string{"create", msg.Subject,
"--type", "message",
"--assignee", toIdentity,
"-d", msg.Body,
}
// Add priority flag
beadsPriority := PriorityToBeads(msg.Priority)
args = append(args, "--priority", fmt.Sprintf("%d", beadsPriority))
// Add message type if set
if msg.Type != "" && msg.Type != TypeNotification {
args = append(args, "--type", string(msg.Type))
}
// Add thread ID if set
if msg.ThreadID != "" {
args = append(args, "--thread-id", msg.ThreadID)
}
// Add reply-to if set
if msg.ReplyTo != "" {
args = append(args, "--reply-to", msg.ReplyTo)
// Add labels
if len(labels) > 0 {
args = append(args, "--labels", strings.Join(labels, ","))
}
// Resolve the correct beads directory for the recipient
@@ -137,7 +137,6 @@ func (r *Router) Send(msg *Message) error {
cmd := exec.Command("bd", args...)
cmd.Env = append(cmd.Environ(),
"BEADS_AGENT_NAME="+fromIdentity,
"BEADS_DIR="+beadsDir,
)
cmd.Dir = filepath.Dir(beadsDir) // Run in parent of .beads