diff --git a/changelog.d/fixed-14765-stage-dependency-blockers.md b/changelog.d/fixed-14765-stage-dependency-blockers.md new file mode 100644 index 0000000000..3ae7d59ffc --- /dev/null +++ b/changelog.d/fixed-14765-stage-dependency-blockers.md @@ -0,0 +1 @@ +- The stage tracker now marks issues waiting on open GitHub dependencies as blocked, names their predecessors, and shows “Actionable · blocked” instead of implying they are waiting for a worker ([#14765](https://github.com/hivecommons/hive/issues/14765)). diff --git a/src/pkg/dashboard/stage_tracker.go b/src/pkg/dashboard/stage_tracker.go index 00cb6088dc..e9aaf16671 100644 --- a/src/pkg/dashboard/stage_tracker.go +++ b/src/pkg/dashboard/stage_tracker.go @@ -267,6 +267,9 @@ type StageTrackerItem struct { // stage/085 on a PR carried as a park signal), needs-rebase, blocked, // draft. Modifiers []string `json:"modifiers"` + // BlockedBy lists the canonical work keys of unresolved dependencies. + // Resolved predecessors are omitted; labels alone do not populate it. + BlockedBy []string `json:"blocked_by,omitempty"` // RegressedFrom / RegressedTo / RegressedAt / RegressedReason narrate // the unresolved regression behind the `regressed` modifier: the // high-water stage the item fell from, the stage that fall landed on @@ -749,14 +752,20 @@ func stageTrackerBlockedBy(it *StageTrackerItem, blockers []string) { if it == nil || len(blockers) == 0 || it.Stage > trackerNumberPossiblyExists { return } - it.BlockedOn = append([]string(nil), blockers...) + it.BlockedOn = slices.Compact(append([]string(nil), blockers...)) + it.BlockedBy = append([]string(nil), it.BlockedOn...) if !slices.Contains(it.Modifiers, modBlocked) { it.Modifiers = append(it.Modifiers, modBlocked) slices.SortFunc(it.Modifiers, func(a, b string) int { return slices.Index(stageTrackerModifierOrder, a) - slices.Index(stageTrackerModifierOrder, b) }) } - it.Caption = joinClause(it.Caption, "waiting on "+stageTrackerBlockerList(it.Repo, blockers)) + waiting := "waiting on " + stageTrackerBlockerList(it.Repo, it.BlockedOn) + if it.Stage == trackerNumberActionable { + it.Caption = "Triaged, but blocked; " + waiting + } else { + it.Caption = joinClause(it.Caption, waiting) + } it.Actor = "its blockers" } diff --git a/src/pkg/dashboard/stage_tracker_blocked_by_test.go b/src/pkg/dashboard/stage_tracker_blocked_by_test.go index 51618fb677..cf7bc41477 100644 --- a/src/pkg/dashboard/stage_tracker_blocked_by_test.go +++ b/src/pkg/dashboard/stage_tracker_blocked_by_test.go @@ -58,7 +58,7 @@ func TestStageTrackerBlockedByDependencyIsSurfaced(t *testing.T) { } claimed := trackerItem(t, resp, "issue", 14637) - if claimed.Stage != 20 || hasMod(claimed, modBlocked) || claimed.BlockedOn != nil { + if claimed.Stage != 20 || hasMod(claimed, modBlocked) || claimed.BlockedOn != nil || claimed.BlockedBy != nil { t.Errorf("#14637 past the gate = stage %d mods %v blocked_on %v, want 020 untouched", claimed.Stage, claimed.Modifiers, claimed.BlockedOn) } diff --git a/src/pkg/dashboard/stage_tracker_blocked_test.go b/src/pkg/dashboard/stage_tracker_blocked_test.go new file mode 100644 index 0000000000..32aff2ddd3 --- /dev/null +++ b/src/pkg/dashboard/stage_tracker_blocked_test.go @@ -0,0 +1,91 @@ +package dashboard + +import ( + "encoding/json" + "slices" + "strings" + "testing" + "time" + + "github.com/hivecommons/hive/pkg/github" + "github.com/hivecommons/hive/pkg/stagelabels" +) + +func TestStageTrackerOpenDependencies(t *testing.T) { + now := time.Date(2026, 10, 28, 1, 0, 0, 0, time.UTC) + for _, tc := range []struct { + name string + labels []string + deps []github.IssueDependency + want []string + }{ + { + name: "open blockers without label", + deps: []github.IssueDependency{ + {Key: "acme/console#7"}, {Key: "acme/console#3", Resolved: true}, + {Key: "acme/console#6"}, {Key: "acme/console#7"}, {}, + {Key: "acme/console-api#8"}, + }, + want: []string{"acme/console#6", "acme/console#7", "acme/console-api#8"}, + }, + { + name: "open blocker and label", labels: []string{"blocked"}, + deps: []github.IssueDependency{{Key: "acme/console#7"}}, want: []string{"acme/console#7"}, + }, + {name: "resolved blockers", deps: []github.IssueDependency{{Key: "acme/console#7", Resolved: true}, {}}}, + {name: "no dependencies"}, + {name: "label only", labels: []string{"blocked"}}, + } { + t.Run(tc.name, func(t *testing.T) { + s := newTestServer() + store := stagelabels.NewStore("", func() time.Time { return now }) + store.Observe(stagelabels.Key("acme/console", 21), stagelabels.Actionable, "actionable") + status := minimalPayload() + status.Repos = []FrontendRepo{{Name: "console", Full: "acme/console", ActionableIssues: []any{ + github.Issue{Number: 21, Title: "Waiting work", Labels: tc.labels, DependsOn: tc.deps}, + }}} + s.UpdateStatus(status) + resp := s.buildStageTracker(s.status, store, now) + it := trackerItem(t, resp, "issue", 21) + if it.Stage != trackerNumberActionable || it.Reason != "actionable" { + t.Fatalf("dependency display must preserve the stage and reason: %+v", it) + } + if !slices.Equal(it.BlockedBy, tc.want) { + t.Fatalf("blocked_by = %v, want %v", it.BlockedBy, tc.want) + } + wantBlocked := len(tc.want) > 0 || slices.Contains(tc.labels, "blocked") + count := 0 + for _, mod := range it.Modifiers { + if mod == modBlocked { + count++ + } + } + if (count == 1) != wantBlocked || count > 1 { + t.Fatalf("blocked modifier count = %d, want blocked=%v", count, wantBlocked) + } + if len(tc.want) > 0 { + if !strings.Contains(it.Caption, "waiting on #") || strings.Contains(it.Caption, "waiting for the scanner") || it.Actor != "its blockers" { + t.Fatalf("blocked work must explain the wait: %+v", it) + } + for _, key := range tc.want { + ref := key + if number, ok := strings.CutPrefix(key, "acme/console#"); ok { + ref = "#" + number + } + if !strings.Contains(it.Caption, ref) { + t.Errorf("caption %q omits %s", it.Caption, ref) + } + } + } else if it.Actor != "scanner" || !strings.Contains(it.Caption, "waiting for the scanner") { + t.Fatalf("no unresolved dependencies should preserve the normal caption: %+v", it) + } + body, err := json.Marshal(it) + if err != nil { + t.Fatal(err) + } + if strings.Contains(string(body), `"blocked_by"`) != (len(tc.want) > 0) { + t.Fatalf("blocked_by must be present only for unresolved dependencies: %s", body) + } + }) + } +} diff --git a/src/pkg/dashboard/stage_tracker_ui_test.go b/src/pkg/dashboard/stage_tracker_ui_test.go index 559d9a12f7..c086913f9c 100644 --- a/src/pkg/dashboard/stage_tracker_ui_test.go +++ b/src/pkg/dashboard/stage_tracker_ui_test.go @@ -318,6 +318,18 @@ assert.deepStrictEqual(segStates(row), ['active ham-open-blocked ham-open-stale' assert.ok(strip(row).includes(' — blocked on acme/api#7 — '), 'a known blocker is named: ' + strip(row)); assert.strictEqual(stageTrackerBlockedTip({ blocked_on: ['acme/api#7', 'acme/api#8'] }), 'blocked on acme/api#7, acme/api#8'); assert.strictEqual(stageTrackerBlockedTip({}), 'carries the blocked label'); +// GitHub dependency blockers keep stage 010 but must not look starved for a worker. +const dependencyBlocked = { repo: 'acme/console', number: 14635, kind: 'issue', title: 'Sequenced work', stage: 10, modifiers: ['blocked'], blocked_by: ['acme/console#7', 'acme/api#8'], caption: 'Triaged, but blocked; waiting on #7, acme/api#8' }; +row = stageTrackerRowHtml(dependencyBlocked, stages, ctx); +assert.strictEqual(stageTrackerHeadline(dependencyBlocked), 'Actionable · blocked'); +assert.ok(strip(row).includes('Actionable · blocked'), row); +assert.deepStrictEqual(segStates(row), [D, 'active ham-open-blocked', T, T, T, T, 'todo cap'], 'only the active Actionable step shows the block'); +assert.ok(strip(row).includes('blocked on acme/console#7, acme/api#8'), row); +assert.ok(tooltip(row).includes('waiting on #7, acme/api#8'), row); +assert.ok(row.includes('>blocked'), 'the existing modifier pill must render'); +assert.strictEqual(stageTrackerCurrentStageHtml(dependencyBlocked, stages, null, now), '
Actionable · blocked
'); +assert.strictEqual(stageTrackerHeadline({ stage: 10, modifiers: [] }), 'Waiting for a worker'); +assert.strictEqual(stageTrackerSegments({ stage: 10, modifiers: [] }, stages, now).find(s => s.state === 'active').short, 'Actionable'); row = stageTrackerRowHtml({ repo: 'acme/console', number: 29, kind: 'issue', title: 'Blocked no since', stage: 0, created_at: new Date(now - 3 * 86400000).toISOString(), modifiers: ['blocked'] }, stages, ctx); assert.strictEqual(openWord(row), 'Open · blocked · since 3d', 'created_at fallback in the chevron'); assert.ok(row.includes('3d'), 'created_at fallback in the since column: ' + row); diff --git a/src/pkg/dashboard/static/index.html b/src/pkg/dashboard/static/index.html index df56424e2d..55497d01e0 100644 --- a/src/pkg/dashboard/static/index.html +++ b/src/pkg/dashboard/static/index.html @@ -13930,7 +13930,7 @@