Skip to content

Commit a9bca8a

Browse files
committed
merge
1 parent 81053e4 commit a9bca8a

File tree

4 files changed

+76
-21
lines changed

4 files changed

+76
-21
lines changed

cmd/goose/main.go

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,31 @@ func (app *App) onReady(ctx context.Context) {
331331
app.mu.Unlock()
332332

333333
// Load current user
334-
loadCurrentUser(ctx, app)
334+
if app.client != nil {
335+
var user *github.User
336+
err := retry.Do(func() error {
337+
var retryErr error
338+
user, _, retryErr = app.client.Users.Get(ctx, "")
339+
if retryErr != nil {
340+
slog.Warn("GitHub Users.Get failed (will retry)", "error", retryErr)
341+
return retryErr
342+
}
343+
return nil
344+
},
345+
retry.Attempts(maxRetries),
346+
retry.DelayType(retry.CombineDelay(retry.BackOffDelay, retry.RandomDelay)),
347+
retry.MaxDelay(maxRetryDelay),
348+
retry.OnRetry(func(n uint, err error) {
349+
slog.Debug("[RETRY] Retrying GitHub API call", "attempt", n, "error", err)
350+
}),
351+
)
352+
if err == nil && user != nil {
353+
if app.targetUser == "" {
354+
app.targetUser = user.GetLogin()
355+
slog.Info("Set target user to current user", "user", app.targetUser)
356+
}
357+
}
358+
}
335359

336360
// Update tooltip
337361
tooltip := "Goose - Loading PRs..."

cmd/goose/notifications.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,7 @@ func (app *App) processNotifications(ctx context.Context) {
9595
slog.Debug("[NOTIFY] Updating menu after notifications")
9696
app.updateMenu(ctx)
9797
}
98-
99-
// Auto-open if enabled
100-
if app.enableAutoBrowser && time.Since(app.startTime) > startupGracePeriod {
101-
app.tryAutoOpenPR(ctx, pr, app.enableAutoBrowser, app.startTime)
102-
}
103-
}
98+
}()
10499

105100
// Update menu if we sent notifications
106101
if len(toNotify) > 0 {

cmd/goose/systray_interface.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package main
22

33
import (
4+
"log/slog"
5+
46
"github.com/energye/systray"
57
)
68

@@ -19,10 +21,12 @@ type SystrayInterface interface {
1921
type RealSystray struct{}
2022

2123
func (*RealSystray) ResetMenu() {
24+
slog.Debug("[SYSTRAY] ResetMenu called")
2225
systray.ResetMenu()
2326
}
2427

2528
func (*RealSystray) AddMenuItem(title, tooltip string) MenuItem {
29+
slog.Debug("[SYSTRAY] AddMenuItem called", "title", title)
2630
item := systray.AddMenuItem(title, tooltip)
2731
return &RealMenuItem{MenuItem: item}
2832
}
@@ -32,6 +36,7 @@ func (*RealSystray) AddSeparator() {
3236
}
3337

3438
func (*RealSystray) SetTitle(title string) {
39+
slog.Info("[SYSTRAY] SetTitle called", "title", title, "len", len(title))
3540
systray.SetTitle(title)
3641
}
3742

cmd/goose/ui.go

Lines changed: 45 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -193,23 +193,46 @@ func (app *App) setTrayTitle() {
193193
// Set title and icon based on PR state
194194
var title string
195195
var iconType IconType
196-
switch {
197-
case counts.IncomingBlocked == 0 && counts.OutgoingBlocked == 0:
198-
title = ""
199-
iconType = IconSmiling
200-
case counts.IncomingBlocked > 0 && counts.OutgoingBlocked > 0:
201-
title = fmt.Sprintf("%d / %d", counts.IncomingBlocked, counts.OutgoingBlocked)
202-
iconType = IconBoth
203-
case counts.IncomingBlocked > 0:
204-
title = fmt.Sprintf("%d", counts.IncomingBlocked)
205-
iconType = IconGoose
206-
default:
207-
title = fmt.Sprintf("%d", counts.OutgoingBlocked)
208-
iconType = IconPopper
196+
197+
// On Linux, always show counts if there are any PRs
198+
// This helps since not all desktop environments show the text
199+
if runtime.GOOS == "linux" && (counts.IncomingTotal > 0 || counts.OutgoingTotal > 0) {
200+
// Show blocked/total format for better visibility
201+
if counts.IncomingBlocked > 0 && counts.OutgoingBlocked > 0 {
202+
title = fmt.Sprintf("%d/%d • %d/%d", counts.IncomingBlocked, counts.IncomingTotal, counts.OutgoingBlocked, counts.OutgoingTotal)
203+
iconType = IconBoth
204+
} else if counts.IncomingBlocked > 0 {
205+
title = fmt.Sprintf("%d/%d", counts.IncomingBlocked, counts.IncomingTotal)
206+
iconType = IconGoose
207+
} else if counts.OutgoingBlocked > 0 {
208+
title = fmt.Sprintf("%d/%d", counts.OutgoingBlocked, counts.OutgoingTotal)
209+
iconType = IconPopper
210+
} else {
211+
// No blocked PRs but there are PRs
212+
title = fmt.Sprintf("0/%d", counts.IncomingTotal+counts.OutgoingTotal)
213+
iconType = IconSmiling
214+
}
215+
} else {
216+
// Original behavior for other platforms
217+
switch {
218+
case counts.IncomingBlocked == 0 && counts.OutgoingBlocked == 0:
219+
title = ""
220+
iconType = IconSmiling
221+
case counts.IncomingBlocked > 0 && counts.OutgoingBlocked > 0:
222+
title = fmt.Sprintf("%d / %d", counts.IncomingBlocked, counts.OutgoingBlocked)
223+
iconType = IconBoth
224+
case counts.IncomingBlocked > 0:
225+
title = fmt.Sprintf("%d", counts.IncomingBlocked)
226+
iconType = IconGoose
227+
default:
228+
title = fmt.Sprintf("%d", counts.OutgoingBlocked)
229+
iconType = IconPopper
230+
}
209231
}
210232

211233
// Log title change with detailed counts
212-
slog.Debug("[TRAY] Setting title and icon",
234+
slog.Info("[TRAY] Setting title and icon",
235+
"os", runtime.GOOS,
213236
"title", title,
214237
"icon", iconType,
215238
"incoming_total", counts.IncomingTotal,
@@ -533,9 +556,17 @@ func (app *App) generatePRSectionTitles(prs []PR, sectionTitle string, hiddenOrg
533556
// rebuildMenu completely rebuilds the menu from scratch.
534557
func (app *App) rebuildMenu(ctx context.Context) {
535558
// Rebuild entire menu
559+
slog.Info("[MENU] Starting rebuildMenu", "os", runtime.GOOS)
536560

537561
// Clear all existing menu items
538562
app.systrayInterface.ResetMenu()
563+
slog.Info("[MENU] Called ResetMenu")
564+
565+
// On Linux, add a small delay to ensure DBus properly processes the reset
566+
// This helps prevent menu item duplication
567+
if runtime.GOOS == "linux" {
568+
time.Sleep(50 * time.Millisecond)
569+
}
539570

540571
// Check for errors (auth or connection failures)
541572
app.mu.RLock()

0 commit comments

Comments
 (0)