Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions github.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,11 @@ func (*App) githubToken(ctx context.Context) (string, error) {

// fetchPRs retrieves all PRs involving the current user.
func (app *App) fetchPRs(ctx context.Context) (incoming []PR, outgoing []PR, err error) {
// Use targetUser if specified, otherwise use authenticated user
user := app.currentUser.GetLogin()
if app.targetUser != "" {
user = app.targetUser
}

// Single query to get all PRs involving the user
query := fmt.Sprintf("is:open is:pr involves:%s archived:false", user)
Expand Down Expand Up @@ -183,6 +187,7 @@ func (app *App) fetchPRs(ctx context.Context) (incoming []PR, outgoing []PR, err
}

// Categorize as incoming or outgoing
// When viewing another user's PRs, we're looking at it from their perspective
if issue.GetUser().GetLogin() == user {
pr.IsBlocked = pr.NeedsReview
outgoing = append(outgoing, pr)
Expand Down
29 changes: 27 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package main

import (
"context"
"flag"
"fmt"
"log"
"os"
Expand Down Expand Up @@ -55,6 +56,7 @@ type App struct {
lastSuccessfulFetch time.Time
turnClient *turn.Client
currentUser *github.User
targetUser string // User to query PRs for (overrides currentUser if set)
previousBlockedPRs map[string]bool
client *github.Client
cacheDir string
Expand All @@ -69,6 +71,11 @@ type App struct {
}

func main() {
// Parse command line flags
var targetUser string
flag.StringVar(&targetUser, "user", "", "GitHub user to query PRs for (defaults to authenticated user)")
flag.Parse()

log.SetFlags(log.LstdFlags | log.Lshortfile)
log.Printf("Starting GitHub PR Monitor (version=%s, commit=%s, date=%s)", version, commit, date)

Expand All @@ -88,6 +95,7 @@ func main() {
cacheDir: cacheDir,
hideStaleIncoming: true,
previousBlockedPRs: make(map[string]bool),
targetUser: targetUser,
}

log.Println("Initializing GitHub clients...")
Expand All @@ -103,6 +111,11 @@ func main() {
}
app.currentUser = user

// Log if we're using a different target user
if app.targetUser != "" && app.targetUser != user.GetLogin() {
log.Printf("Querying PRs for user '%s' instead of authenticated user '%s'", app.targetUser, user.GetLogin())
}

log.Println("Starting systray...")
// Create a cancellable context for the application
appCtx, cancel := context.WithCancel(ctx)
Expand All @@ -118,7 +131,13 @@ func main() {
func (app *App) onReady(ctx context.Context) {
log.Println("System tray ready")
systray.SetTitle("Loading PRs...")
systray.SetTooltip("GitHub PR Monitor")

// Set tooltip based on whether we're using a custom user
tooltip := "GitHub PR Monitor"
if app.targetUser != "" {
tooltip = fmt.Sprintf("GitHub PR Monitor - @%s", app.targetUser)
}
systray.SetTooltip(tooltip)

// Set up click handlers
systray.SetOnClick(func(menu systray.IMenu) {
Expand Down Expand Up @@ -199,7 +218,13 @@ func (app *App) updatePRs(ctx context.Context) {
if !app.lastSuccessfulFetch.IsZero() {
timeSinceSuccess = time.Since(app.lastSuccessfulFetch).Round(time.Minute).String()
}
systray.SetTooltip(fmt.Sprintf("GitHub PR Monitor - Error: %v\nLast success: %s ago", err, timeSinceSuccess))

// Include user in error tooltip
userInfo := ""
if app.targetUser != "" {
userInfo = fmt.Sprintf(" - @%s", app.targetUser)
}
systray.SetTooltip(fmt.Sprintf("GitHub PR Monitor%s - Error: %v\nLast success: %s ago", userInfo, err, timeSinceSuccess))
return
}

Expand Down
6 changes: 5 additions & 1 deletion ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,11 @@ func (app *App) addStaticMenuItems(ctx context.Context) {
})

// About
aboutItem := systray.AddMenuItem("About", "")
aboutText := "About"
if app.targetUser != "" {
aboutText = fmt.Sprintf("About (viewing @%s)", app.targetUser)
}
aboutItem := systray.AddMenuItem(aboutText, "")
app.menuItems = append(app.menuItems, aboutItem)
aboutItem.Click(func() {
log.Println("GitHub PR Monitor - A system tray app for tracking PR reviews")
Expand Down