@@ -402,6 +402,34 @@ func (app *App) updatePRs(ctx context.Context) {
402402
403403 // Update state atomically
404404 app .mu .Lock ()
405+ // Log PRs that were removed (likely merged/closed)
406+ for i := range app .incoming {
407+ found := false
408+ for j := range incoming {
409+ if app .incoming [i ].URL == incoming [j ].URL {
410+ found = true
411+ break
412+ }
413+ }
414+ if ! found {
415+ log .Printf ("[UPDATE] Incoming PR removed (likely merged/closed): %s #%d - %s" ,
416+ app .incoming [i ].Repository , app .incoming [i ].Number , app .incoming [i ].URL )
417+ }
418+ }
419+ for i := range app .outgoing {
420+ found := false
421+ for j := range outgoing {
422+ if app .outgoing [i ].URL == outgoing [j ].URL {
423+ found = true
424+ break
425+ }
426+ }
427+ if ! found {
428+ log .Printf ("[UPDATE] Outgoing PR removed (likely merged/closed): %s #%d - %s" ,
429+ app .outgoing [i ].Repository , app .outgoing [i ].Number , app .outgoing [i ].URL )
430+ }
431+ }
432+
405433 app .incoming = incoming
406434 app .outgoing = outgoing
407435 // Mark initial load as complete after first successful update
@@ -660,10 +688,27 @@ func (app *App) checkForNewlyBlockedPRs(ctx context.Context) {
660688 }
661689 }
662690
691+ // Clean up blockedPRTimes to only include PRs that are currently in the lists
692+ // This ensures merged/closed PRs don't persist
693+ cleanedBlockedTimes := make (map [string ]time.Time )
694+ var removedCount int
695+ for url , blockTime := range newBlockedTimes {
696+ // Only keep blocked times for PRs that are still in current lists
697+ if currentBlocked [url ] {
698+ cleanedBlockedTimes [url ] = blockTime
699+ } else {
700+ removedCount ++
701+ log .Printf ("[BLOCKED] Removing stale blocked time for PR no longer in list: %s" , url )
702+ }
703+ }
704+ if removedCount > 0 {
705+ log .Printf ("[BLOCKED] Cleaned up %d stale blocked PR times (likely merged/closed)" , removedCount )
706+ }
707+
663708 // Update state with a lock
664709 app .mu .Lock ()
665710 app .previousBlockedPRs = currentBlocked
666- app .blockedPRTimes = newBlockedTimes
711+ app .blockedPRTimes = cleanedBlockedTimes
667712 // Update the PR lists with FirstBlockedAt times
668713 app .incoming = incoming
669714 app .outgoing = outgoing
0 commit comments