@@ -47,6 +47,19 @@ const (
4747 // Retry settings for external API calls - exponential backoff with jitter up to 2 minutes.
4848 maxRetryDelay = 2 * time .Minute
4949 maxRetries = 10 // Should reach 2 minutes with exponential backoff
50+
51+ // Failure thresholds.
52+ minorFailureThreshold = 3
53+ majorFailureThreshold = 10
54+ panicFailureIncrement = 10
55+
56+ // Notification settings.
57+ reminderInterval = 24 * time .Hour
58+ historyRetentionDays = 30
59+
60+ // Turn API settings.
61+ turnAPITimeout = 10 * time .Second
62+ maxConcurrentTurnAPICalls = 10
5063)
5164
5265// PR represents a pull request with metadata.
@@ -270,7 +283,7 @@ func (app *App) updateLoop(ctx context.Context) {
270283
271284 // Update failure count
272285 app .mu .Lock ()
273- app .consecutiveFailures += 10 // Treat panic as critical failure
286+ app .consecutiveFailures += panicFailureIncrement // Treat panic as critical failure
274287 app .mu .Unlock ()
275288
276289 // Signal app to quit after panic
@@ -308,10 +321,6 @@ func (app *App) updatePRs(ctx context.Context) {
308321 app .mu .Unlock ()
309322
310323 // Progressive degradation based on failure count
311- const (
312- minorFailureThreshold = 3
313- majorFailureThreshold = 10
314- )
315324 var title , tooltip string
316325 switch {
317326 case failureCount == 1 :
@@ -475,10 +484,6 @@ func (app *App) updatePRsWithWait(ctx context.Context) {
475484 app .mu .Unlock ()
476485
477486 // Progressive degradation based on failure count
478- const (
479- minorFailureThreshold = 3
480- majorFailureThreshold = 10
481- )
482487 var title , tooltip string
483488 switch {
484489 case failureCount == 1 :
@@ -541,35 +546,6 @@ func (app *App) updatePRsWithWait(ctx context.Context) {
541546 app .checkForNewlyBlockedPRs (ctx )
542547}
543548
544- // shouldNotifyForPR determines if we should send a notification for a PR.
545- func shouldNotifyForPR (
546- _ string ,
547- isBlocked bool ,
548- prevState NotificationState ,
549- hasHistory bool ,
550- reminderInterval time.Duration ,
551- enableReminders bool ,
552- ) (shouldNotify bool , reason string ) {
553- if ! hasHistory && isBlocked {
554- return true , "newly blocked"
555- }
556-
557- if ! hasHistory {
558- return false , ""
559- }
560-
561- switch {
562- case isBlocked && ! prevState .WasBlocked :
563- return true , "became blocked"
564- case ! isBlocked && prevState .WasBlocked :
565- return false , "unblocked"
566- case isBlocked && prevState .WasBlocked && enableReminders && time .Since (prevState .LastNotified ) > reminderInterval :
567- return true , "reminder"
568- default :
569- return false , ""
570- }
571- }
572-
573549// processPRNotifications handles notification logic for a single PR.
574550func (app * App ) processPRNotifications (
575551 ctx context.Context ,
@@ -582,7 +558,24 @@ func (app *App) processPRNotifications(
582558 reminderInterval time.Duration ,
583559) {
584560 prevState , hasHistory := notificationHistory [pr .URL ]
585- shouldNotify , notifyReason := shouldNotifyForPR (pr .URL , isBlocked , prevState , hasHistory , reminderInterval , app .enableReminders )
561+
562+ // Determine if we should notify (inlined from shouldNotifyForPR)
563+ var shouldNotify bool
564+ var notifyReason string
565+ switch {
566+ case ! hasHistory && isBlocked :
567+ shouldNotify , notifyReason = true , "newly blocked"
568+ case ! hasHistory :
569+ shouldNotify , notifyReason = false , ""
570+ case isBlocked && ! prevState .WasBlocked :
571+ shouldNotify , notifyReason = true , "became blocked"
572+ case ! isBlocked && prevState .WasBlocked :
573+ shouldNotify , notifyReason = false , "unblocked"
574+ case isBlocked && prevState .WasBlocked && app .enableReminders && time .Since (prevState .LastNotified ) > reminderInterval :
575+ shouldNotify , notifyReason = true , "reminder"
576+ default :
577+ shouldNotify , notifyReason = false , ""
578+ }
586579
587580 // Update state for unblocked PRs
588581 if notifyReason == "unblocked" {
@@ -669,8 +662,7 @@ func (app *App) checkForNewlyBlockedPRs(ctx context.Context) {
669662 now := time .Now ()
670663 staleThreshold := now .Add (- stalePRThreshold )
671664
672- // Reminder interval for re-notifications (24 hours)
673- const reminderInterval = 24 * time .Hour
665+ // Use reminder interval constant from package level
674666
675667 currentBlockedPRs := make (map [string ]bool )
676668 playedIncomingSound := false
0 commit comments