Skip to content

Commit 770d0bc

Browse files
Thomas StrombergThomas Stromberg
authored andcommitted
Add real-time notification support via sprinkler
1 parent 36f42bb commit 770d0bc

File tree

5 files changed

+507
-2
lines changed

5 files changed

+507
-2
lines changed

cmd/goose/github.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ func (app *App) initClients(ctx context.Context) error {
5353
turnClient.SetAuthToken(token)
5454
app.turnClient = turnClient
5555

56+
// Initialize sprinkler monitor for real-time events
57+
app.sprinklerMonitor = newSprinklerMonitor(app, token)
58+
5659
return nil
5760
}
5861

@@ -405,6 +408,22 @@ func (app *App) fetchPRsInternal(ctx context.Context) (incoming []PR, outgoing [
405408
// Only log summary, not individual PRs
406409
slog.Info("[GITHUB] GitHub PR summary", "incoming", len(incoming), "outgoing", len(outgoing))
407410

411+
// Update sprinkler monitor with discovered orgs
412+
app.mu.RLock()
413+
orgs := make([]string, 0, len(app.seenOrgs))
414+
for org := range app.seenOrgs {
415+
orgs = append(orgs, org)
416+
}
417+
app.mu.RUnlock()
418+
419+
if app.sprinklerMonitor != nil && len(orgs) > 0 {
420+
app.sprinklerMonitor.updateOrgs(orgs)
421+
// Start monitor if not already running
422+
if err := app.sprinklerMonitor.start(); err != nil {
423+
slog.Warn("[SPRINKLER] Failed to start monitor", "error", err)
424+
}
425+
}
426+
408427
// Fetch Turn API data
409428
// Always synchronous now for simplicity - Turn API calls are fast with caching
410429
app.fetchTurnDataSync(ctx, allIssues, user, &incoming, &outgoing)

cmd/goose/main.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ type App struct {
8282
hiddenOrgs map[string]bool
8383
seenOrgs map[string]bool
8484
turnClient *turn.Client
85+
sprinklerMonitor *sprinklerMonitor
8586
previousBlockedPRs map[string]bool
8687
authError string
8788
lastFetchError string
@@ -283,6 +284,9 @@ func main() {
283284
systray.Run(func() { app.onReady(appCtx) }, func() {
284285
slog.Info("Shutting down application")
285286
cancel() // Cancel the context to stop goroutines
287+
if app.sprinklerMonitor != nil {
288+
app.sprinklerMonitor.stop()
289+
}
286290
app.cleanupOldCache()
287291
})
288292
}

0 commit comments

Comments
 (0)