Skip to content

Commit 1870c1f

Browse files
committed
ensure diamond icon only shows for first minute of a PR
1 parent 479e1a3 commit 1870c1f

File tree

2 files changed

+41
-16
lines changed

2 files changed

+41
-16
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)

0 commit comments

Comments
 (0)