Skip to content

Commit d4d9aad

Browse files
authored
Merge pull request #115 from tstromberg/main
Ensure diamond icon only shows for first minute
2 parents b1dc651 + 1870c1f commit d4d9aad

File tree

4 files changed

+56
-31
lines changed

4 files changed

+56
-31
lines changed

cmd/reviewGOOSE/main_test.go

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -205,15 +205,16 @@ func TestMenuItemTitleTransition(t *testing.T) {
205205
_ = ctx // Unused in this test but would be used for real menu operations
206206
}
207207

208-
// TestWorkflowStateNewlyPublished tests that PRs with NEWLY_PUBLISHED workflow state get a 💎 bullet.
208+
// TestWorkflowStateNewlyPublished tests that PRs with NEWLY_PUBLISHED workflow state get a 💎 bullet
209+
// only when updated within the last minute and not blocked/needing review.
209210
func TestWorkflowStateNewlyPublished(t *testing.T) {
210211
tests := []struct {
211212
name string
212213
pr PR
213214
expectedTitle string
214215
}{
215216
{
216-
name: "newly_published_with_action",
217+
name: "newly_published_needs_review_gets_block_not_diamond",
217218
pr: PR{
218219
Repository: "test/repo",
219220
Number: 123,
@@ -222,10 +223,10 @@ func TestWorkflowStateNewlyPublished(t *testing.T) {
222223
NeedsReview: true,
223224
UpdatedAt: time.Now(),
224225
},
225-
expectedTitle: "💎 test/repo #123 — review",
226+
expectedTitle: " test/repo #123 — review",
226227
},
227228
{
228-
name: "newly_published_without_action",
229+
name: "newly_published_recent_gets_diamond",
229230
pr: PR{
230231
Repository: "test/repo",
231232
Number: 456,
@@ -235,7 +236,17 @@ func TestWorkflowStateNewlyPublished(t *testing.T) {
235236
expectedTitle: "💎 test/repo #456",
236237
},
237238
{
238-
name: "newly_published_with_running_tests",
239+
name: "newly_published_stale_no_prefix",
240+
pr: PR{
241+
Repository: "test/repo",
242+
Number: 457,
243+
WorkflowState: string(turn.StateNewlyPublished),
244+
UpdatedAt: time.Now().Add(-2 * time.Minute),
245+
},
246+
expectedTitle: "test/repo #457",
247+
},
248+
{
249+
name: "newly_published_with_running_tests_gets_diamond",
239250
pr: PR{
240251
Repository: "test/repo",
241252
Number: 789,
@@ -245,6 +256,17 @@ func TestWorkflowStateNewlyPublished(t *testing.T) {
245256
},
246257
expectedTitle: "💎 test/repo #789 — tests running...",
247258
},
259+
{
260+
name: "newly_published_with_action_gets_bullet_not_diamond",
261+
pr: PR{
262+
Repository: "test/repo",
263+
Number: 790,
264+
ActionKind: "review",
265+
WorkflowState: string(turn.StateNewlyPublished),
266+
UpdatedAt: time.Now(),
267+
},
268+
expectedTitle: "• test/repo #790 — review",
269+
},
248270
{
249271
name: "not_newly_published_with_action",
250272
pr: PR{
@@ -273,12 +295,15 @@ func TestWorkflowStateNewlyPublished(t *testing.T) {
273295
title = fmt.Sprintf("%s — tests running...", title)
274296
}
275297

276-
// Add prefix based on workflow state or blocked status
298+
// Add prefix based on blocked status, action, or newly published
299+
// (mirrors priority order in ui.go - diamond is lowest priority)
277300
switch {
278-
case pr.WorkflowState == string(turn.StateNewlyPublished):
279-
title = fmt.Sprintf("💎 %s", title)
280301
case pr.NeedsReview || pr.IsBlocked:
281302
title = fmt.Sprintf("■ %s", title)
303+
case pr.ActionKind != "":
304+
title = fmt.Sprintf("• %s", title)
305+
case pr.WorkflowState == string(turn.StateNewlyPublished) && time.Since(pr.UpdatedAt) < time.Minute:
306+
title = fmt.Sprintf("💎 %s", title)
282307
}
283308

284309
return title

cmd/reviewGOOSE/ui.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -304,9 +304,6 @@ func (app *App) addPRSection(ctx context.Context, prs []PR, sectionTitle string,
304304

305305
// Add bullet point or emoji based on PR status
306306
switch {
307-
case pr.WorkflowState == string(turn.StateNewlyPublished):
308-
// Use gem emoji for newly published PRs
309-
title = fmt.Sprintf("💎 %s", title)
310307
case pr.NeedsReview || pr.IsBlocked:
311308
// Get the blocked time from state manager
312309
prState, hasState := app.stateManager.PRState(pr.URL)
@@ -371,8 +368,11 @@ func (app *App) addPRSection(ctx context.Context, prs []PR, sectionTitle string,
371368
case pr.ActionKind != "":
372369
// PR has an action but isn't blocked - add bullet to indicate it could use input
373370
title = fmt.Sprintf("• %s", title)
371+
case pr.WorkflowState == string(turn.StateNewlyPublished) && time.Since(pr.UpdatedAt) < time.Minute:
372+
// Use gem emoji for newly published PRs updated within the last minute
373+
title = fmt.Sprintf("💎 %s", title)
374374
default:
375-
// No special prefix needed
375+
// No prefix needed
376376
}
377377

378378
// Format age for tooltip
@@ -520,9 +520,6 @@ func (app *App) generatePRSectionTitles(prs []PR, sectionTitle string, hiddenOrg
520520

521521
// Add bullet point or emoji for blocked PRs (same logic as in addPRSection)
522522
switch {
523-
case pr.WorkflowState == string(turn.StateNewlyPublished):
524-
// Use gem emoji for newly published PRs
525-
title = fmt.Sprintf("💎 %s", title)
526523
case pr.NeedsReview || pr.IsBlocked:
527524
prState, hasState := app.stateManager.PRState(pr.URL)
528525

@@ -583,8 +580,11 @@ func (app *App) generatePRSectionTitles(prs []PR, sectionTitle string, hiddenOrg
583580
case pr.ActionKind != "":
584581
// PR has an action but isn't blocked - add bullet to indicate it could use input
585582
title = fmt.Sprintf("• %s", title)
583+
case pr.WorkflowState == string(turn.StateNewlyPublished) && time.Since(pr.UpdatedAt) < time.Minute:
584+
// Use gem emoji for newly published PRs updated within the last minute
585+
title = fmt.Sprintf("💎 %s", title)
586586
default:
587-
// No special prefix needed
587+
// No prefix needed
588588
}
589589

590590
titles = append(titles, title)

go.mod

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ require (
1010
github.com/gen2brain/beeep v0.11.2
1111
github.com/godbus/dbus/v5 v5.2.2
1212
github.com/google/go-github/v57 v57.0.0
13-
golang.org/x/image v0.34.0
13+
golang.org/x/image v0.35.0
1414
golang.org/x/oauth2 v0.34.0
1515
)
1616

@@ -26,12 +26,12 @@ require (
2626
github.com/jackmordaunt/icns/v3 v3.0.1 // indirect
2727
github.com/klauspost/compress v1.18.2 // indirect
2828
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 // indirect
29-
github.com/puzpuzpuz/xsync/v4 v4.2.0 // indirect
29+
github.com/puzpuzpuz/xsync/v4 v4.3.0 // indirect
3030
github.com/sergeymakinen/go-bmp v1.0.0 // indirect
3131
github.com/sergeymakinen/go-ico v1.0.0 // indirect
3232
github.com/tadvi/systray v0.0.0-20190226123456-11a2b8fa57af // indirect
3333
github.com/tevino/abool v0.0.0-20220530134649-2bfc934cb23c // indirect
34-
golang.org/x/net v0.48.0 // indirect
35-
golang.org/x/sys v0.39.0 // indirect
36-
golang.org/x/text v0.32.0 // indirect
34+
golang.org/x/net v0.49.0 // indirect
35+
golang.org/x/sys v0.40.0 // indirect
36+
golang.org/x/text v0.33.0 // indirect
3737
)

go.sum

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ github.com/pierrec/lz4/v4 v4.1.22 h1:cKFw6uJDK+/gfw5BcDL0JL5aBsAFdsIT18eRtLj7VIU
4545
github.com/pierrec/lz4/v4 v4.1.22/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4=
4646
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
4747
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
48-
github.com/puzpuzpuz/xsync/v4 v4.2.0 h1:dlxm77dZj2c3rxq0/XNvvUKISAmovoXF4a4qM6Wvkr0=
49-
github.com/puzpuzpuz/xsync/v4 v4.2.0/go.mod h1:VJDmTCJMBt8igNxnkQd86r+8KUeN1quSfNKu5bLYFQo=
48+
github.com/puzpuzpuz/xsync/v4 v4.3.0 h1:w/bWkEJdYuRNYhHn5eXnIT8LzDM1O629X1I9MJSkD7Q=
49+
github.com/puzpuzpuz/xsync/v4 v4.3.0/go.mod h1:VJDmTCJMBt8igNxnkQd86r+8KUeN1quSfNKu5bLYFQo=
5050
github.com/sergeymakinen/go-bmp v1.0.0 h1:SdGTzp9WvCV0A1V0mBeaS7kQAwNLdVJbmHlqNWq0R+M=
5151
github.com/sergeymakinen/go-bmp v1.0.0/go.mod h1:/mxlAQZRLxSvJFNIEGGLBE/m40f3ZnUifpgVDlcUIEY=
5252
github.com/sergeymakinen/go-ico v1.0.0 h1:uL3khgvKkY6WfAetA+RqsguClBuu7HpvBB/nq/Jvr80=
@@ -62,18 +62,18 @@ github.com/tadvi/systray v0.0.0-20190226123456-11a2b8fa57af h1:6yITBqGTE2lEeTPG0
6262
github.com/tadvi/systray v0.0.0-20190226123456-11a2b8fa57af/go.mod h1:4F09kP5F+am0jAwlQLddpoMDM+iewkxxt6nxUQ5nq5o=
6363
github.com/tevino/abool v0.0.0-20220530134649-2bfc934cb23c h1:coVla7zpsycc+kA9NXpcvv2E4I7+ii6L5hZO2S6C3kw=
6464
github.com/tevino/abool v0.0.0-20220530134649-2bfc934cb23c/go.mod h1:qc66Pna1RiIsPa7O4Egxxs9OqkuxDX55zznh9K07Tzg=
65-
golang.org/x/image v0.34.0 h1:33gCkyw9hmwbZJeZkct8XyR11yH889EQt/QH4VmXMn8=
66-
golang.org/x/image v0.34.0/go.mod h1:2RNFBZRB+vnwwFil8GkMdRvrJOFd1AzdZI6vOY+eJVU=
67-
golang.org/x/net v0.48.0 h1:zyQRTTrjc33Lhh0fBgT/H3oZq9WuvRR5gPC70xpDiQU=
68-
golang.org/x/net v0.48.0/go.mod h1:+ndRgGjkh8FGtu1w1FGbEC31if4VrNVMuKTgcAAnQRY=
65+
golang.org/x/image v0.35.0 h1:LKjiHdgMtO8z7Fh18nGY6KDcoEtVfsgLDPeLyguqb7I=
66+
golang.org/x/image v0.35.0/go.mod h1:MwPLTVgvxSASsxdLzKrl8BRFuyqMyGhLwmC+TO1Sybk=
67+
golang.org/x/net v0.49.0 h1:eeHFmOGUTtaaPSGNmjBKpbng9MulQsJURQUAfUwY++o=
68+
golang.org/x/net v0.49.0/go.mod h1:/ysNB2EvaqvesRkuLAyjI1ycPZlQHM3q01F02UY/MV8=
6969
golang.org/x/oauth2 v0.34.0 h1:hqK/t4AKgbqWkdkcAeI8XLmbK+4m4G5YeQRrmiotGlw=
7070
golang.org/x/oauth2 v0.34.0/go.mod h1:lzm5WQJQwKZ3nwavOZ3IS5Aulzxi68dUSgRHujetwEA=
7171
golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
7272
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
73-
golang.org/x/sys v0.39.0 h1:CvCKL8MeisomCi6qNZ+wbb0DN9E5AATixKsvNtMoMFk=
74-
golang.org/x/sys v0.39.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
75-
golang.org/x/text v0.32.0 h1:ZD01bjUt1FQ9WJ0ClOL5vxgxOI/sVCNgX1YtKwcY0mU=
76-
golang.org/x/text v0.32.0/go.mod h1:o/rUWzghvpD5TXrTIBuJU77MTaN0ljMWE47kxGJQ7jY=
73+
golang.org/x/sys v0.40.0 h1:DBZZqJ2Rkml6QMQsZywtnjnnGvHza6BTfYFWY9kjEWQ=
74+
golang.org/x/sys v0.40.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
75+
golang.org/x/text v0.33.0 h1:B3njUFyqtHDUI5jMn1YIr5B0IE2U0qck04r6d4KPAxE=
76+
golang.org/x/text v0.33.0/go.mod h1:LuMebE6+rBincTi9+xWTY8TztLzKHc/9C1uBCG27+q8=
7777
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
7878
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
7979
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=

0 commit comments

Comments
 (0)