From 93152481349921b795f36667a29897f6401332f1 Mon Sep 17 00:00:00 2001 From: gastown/refinery Date: Tue, 13 Jan 2026 12:54:54 -0800 Subject: [PATCH] fix(mq): persist MR rejection to beads storage The RejectMR function was modifying the in-memory MR object but never persisting the change to beads storage. This caused rejected MRs to continue showing in the queue with status "open". Fix: Call beads.CloseWithReason() to properly close the MR bead before updating the in-memory state. Co-Authored-By: Claude Opus 4.5 --- internal/refinery/manager.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/internal/refinery/manager.go b/internal/refinery/manager.go index 980926e6..66e48c80 100644 --- a/internal/refinery/manager.go +++ b/internal/refinery/manager.go @@ -744,9 +744,16 @@ func (m *Manager) RejectMR(idOrBranch string, reason string, notify bool) (*Merg return nil, fmt.Errorf("%w: MR is already closed with reason: %s", ErrClosedImmutable, mr.CloseReason) } - // Close with rejected reason + // Close the bead in storage with the rejection reason + b := beads.New(m.rig.BeadsPath()) + if err := b.CloseWithReason("rejected: "+reason, mr.ID); err != nil { + return nil, fmt.Errorf("failed to close MR bead: %w", err) + } + + // Update in-memory state for return value if err := mr.Close(CloseReasonRejected); err != nil { - return nil, fmt.Errorf("failed to close MR: %w", err) + // Non-fatal: bead is already closed, just log + _, _ = fmt.Fprintf(m.output, "Warning: failed to update MR state: %v\n", err) } mr.Error = reason