Skip to content

Commit c8c963e

Browse files
authored
Merge pull request #41 from codeGROOVE-dev/correct-highlighting
Fix resource use issues around PR highlighting
2 parents 9c602af + 2bb58e0 commit c8c963e

File tree

2 files changed

+34
-21
lines changed

2 files changed

+34
-21
lines changed

cmd/goose/main.go

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,36 @@ func (app *App) checkForNewlyBlockedPRs(ctx context.Context) {
611611
outgoing := make([]PR, len(app.outgoing))
612612
copy(outgoing, app.outgoing)
613613
previousBlocked := app.previousBlockedPRs
614-
blockedTimes := app.blockedPRTimes
614+
615+
// Clean up blockedPRTimes first to remove stale entries
616+
// Only keep blocked times for PRs that are actually in the current lists
617+
cleanedBlockedTimes := make(map[string]time.Time)
618+
for i := range app.incoming {
619+
if blockTime, exists := app.blockedPRTimes[app.incoming[i].URL]; exists {
620+
cleanedBlockedTimes[app.incoming[i].URL] = blockTime
621+
}
622+
}
623+
for i := range app.outgoing {
624+
if blockTime, exists := app.blockedPRTimes[app.outgoing[i].URL]; exists {
625+
cleanedBlockedTimes[app.outgoing[i].URL] = blockTime
626+
}
627+
}
628+
629+
// Log any removed entries
630+
removedCount := 0
631+
for url := range app.blockedPRTimes {
632+
if _, exists := cleanedBlockedTimes[url]; !exists {
633+
log.Printf("[BLOCKED] Removing stale blocked time for PR no longer in list: %s", url)
634+
removedCount++
635+
}
636+
}
637+
if removedCount > 0 {
638+
log.Printf("[BLOCKED] Cleaned up %d stale blocked PR times", removedCount)
639+
}
640+
641+
// Update the app's blockedPRTimes to the cleaned version to prevent memory growth
642+
app.blockedPRTimes = cleanedBlockedTimes
643+
blockedTimes := cleanedBlockedTimes
615644
autoBrowserEnabled := app.enableAutoBrowser
616645
startTime := app.startTime
617646
hideStaleIncoming := app.hideStaleIncoming
@@ -688,27 +717,10 @@ func (app *App) checkForNewlyBlockedPRs(ctx context.Context) {
688717
}
689718
}
690719

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-
708720
// Update state with a lock
709721
app.mu.Lock()
710722
app.previousBlockedPRs = currentBlocked
711-
app.blockedPRTimes = cleanedBlockedTimes
723+
app.blockedPRTimes = newBlockedTimes
712724
// Update the PR lists with FirstBlockedAt times
713725
app.incoming = incoming
714726
app.outgoing = outgoing

cmd/goose/ui.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,9 @@ func (app *App) setTrayTitle() {
154154
title = fmt.Sprintf("🎉 %d", counts.OutgoingBlocked)
155155
}
156156

157-
log.Printf("[TRAY] Setting title: %s (incoming_blocked=%d, outgoing_blocked=%d)",
158-
title, counts.IncomingBlocked, counts.OutgoingBlocked)
157+
// Log title change with detailed counts
158+
log.Printf("[TRAY] Setting title to '%s' (incoming_total=%d, incoming_blocked=%d, outgoing_total=%d, outgoing_blocked=%d)",
159+
title, counts.IncomingTotal, counts.IncomingBlocked, counts.OutgoingTotal, counts.OutgoingBlocked)
159160
systray.SetTitle(title)
160161
}
161162

0 commit comments

Comments
 (0)