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
1 change: 1 addition & 0 deletions changelog.d/fixed-overview-band-charts-outside.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- The Overview's "Issues by band" and "PRs by band" charts now add up to the Total open issues and Total open PRs tiles. A grey Outside slice holds the open items that are in no band (filtered out by the hive's settings, or draft PRs), with the same breakdown as the Outside tile on hover, for all repositories or a picked subset. Before, the charts showed fewer items than the tiles with nothing saying why.
2 changes: 2 additions & 0 deletions src/docs/dashboard-sections/overview-and-metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@ How many issues and pull requests Hive is tracking right now, and how many of th
- **PRs by band** groups open and held pull requests. The bands are Needs human, Merge-eligible, Blocked, In review, Open and Draft.
- Merge-eligible means the pull request passed every check Hive uses before merging. Blocked means a failed check, a merge conflict, or a blocking review verdict.
- Hover any band in a chart to see its exact rule.
- Each chart also has a grey **Outside** slice for the open items in no band: what your filters kept off the work list, and draft pull requests. Its hover shows the same reasons as the Outside tile. With it, each chart adds up to its Total open tile, for all repositories or for the ones you picked. The slice is left out when it would be 0. Click it to filter Projects the way the Outside tile does.
- The trend lines come from samples the hive takes on each status refresh, roughly every few minutes. Samples are kept for about 30 days and thinned to 96 points.
- Your browser also keeps its own samples. When you filter by repository, only the browser's samples are used.

**Numbers that look like they should match but do not.**

- The chart's Outside slice can be larger than the Outside tile. Open issues that are labeled `needs-human` or wait on their reporter but sit in no band are in the slice. The tiles count those as Blocked / needs-human.
- The band charts count more than Actionable now. The charts include items in "Needs human" and "Confirm & close". Actionable now leaves those out. So an issue chart can total 3 while Actionable now shows 2 issues.
- The "PRs by band" chart puts held pull requests in "Needs human". The tiles count the same pull requests as Held. So the chart can show 4 needing a human while the Blocked / needs-human tile shows 0 pull requests.

Expand Down
110 changes: 110 additions & 0 deletions src/pkg/dashboard/overview_band_charts_9003_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package dashboard

import (
"os/exec"
"regexp"
"strings"
"testing"
Expand Down Expand Up @@ -122,3 +123,112 @@ func cssCustomPropertyValue(t *testing.T, css, name string) string {
}
return strings.TrimSpace(match[1])
}

// The band donuts draw tracked items only (actionable + held); the "Total
// open" cards count every open item. Without the Outside slice the charts
// showed 100 issues / 93 PRs beside cards saying 134 / 95 (knuckle,
// 2026-11-19). Each chart must add up to its card for all repos and for a
// single selected repo, and the Outside slice must not double count.
func TestOverviewBandChartsAddUpToKPITotals(t *testing.T) {
node, err := exec.LookPath("node")
if err != nil {
t.Skip("node unavailable: Overview chart totals were not executed")
}
html := indexHTML(t)
script := overviewKPIRenderPrelude(t, html) + `
const OVERVIEW_HISTORY_MAX_SAMPLES = 288;
const OVERVIEW_HISTORY_MIN_SAMPLE_MS = 60000;
` + jsFunc(t, html, "overviewOutsideSlice") + `
` + jsFunc(t, html, "overviewChartSlices") + `
` + jsFunc(t, html, "overviewHistoryCounts") + `
` + jsFunc(t, html, "overviewSampleHistory") + `
` + jsFunc(t, html, "overviewAnimationSignature") + `
const state = { showKPIs: true };
const fill = n => Array.from({ length: n }, (_, i) => ({ number: i + 1 }));
const repos = [
{ full: 'acme/app', actionableIssues: fill(95), heldIssues: fill(5), openPrs: fill(90), heldPrs: fill(3),
workBreakdown: { issues: { actionable: 95, hold: 5, dependency_dashboard: 22, filtered: 11, hive_advisory: 1 }, prs: { actionable: 90, hold: 3, draft: 2 } } },
{ full: 'acme/lib', actionableIssues: fill(4), heldIssues: [], openPrs: fill(1), heldPrs: [],
workBreakdown: { issues: { actionable: 4, filtered: 3 }, prs: { actionable: 1 } } },
];
_overviewLastRepos = repos;
const issueSlices = (n, held) => [
{ key: 'ready', count: n - held - 10, items: [] }, { key: 'in-progress', count: held, items: [] },
{ key: 'agent-filed', count: 0, items: [] }, { key: 'waiting', count: 6, items: [] }, { key: 'done', count: 4, items: [] },
];
const prSlices = (n) => [
{ key: 'waiting', count: 0, items: [] }, { key: 'eligible', count: n - 3, items: [] }, { key: 'blocked', count: 1, items: [] },
{ key: 'in-review', count: 2, items: [] }, { key: 'open', count: 0, items: [] }, { key: 'draft', count: 0, items: [] },
];
const cards = out => Object.fromEntries([...out.matchAll(/data-overview-kpi-key="([^"]+)" data-overview-kpi-value="([^"]+)"[^>]*>([^<]*)<\/span><span class="overview-kpi-label">([^<]*)/g)].map(m => [m[4], Number(m[3])]));
const sum = slices => slices.reduce((n, s) => n + s.count, 0);
const check = (selected, iSlices, pSlices) => {
const issueChart = overviewChartSlices('issue', iSlices, selected);
const prChart = overviewChartSlices('pr', pSlices, selected);
const kpi = cards(renderOverviewKPIs(selected, iSlices, pSlices, state));
assert.equal(sum(issueChart), kpi['Total open issues'], 'issue donut total');
assert.equal(sum(prChart), kpi['Total open PRs'], 'PR donut total');
assert.equal(kpi['Total open issues'] + kpi['Total open PRs'],
kpi['Actionable now'] + kpi.Held + kpi['Blocked / needs-human'] + kpi.Outside, 'card arithmetic');
// The band slices are untouched: the Outside slice only adds the gap.
assert.deepEqual(issueChart.slice(0, iSlices.length), iSlices);
assert.deepEqual(prChart.slice(0, pSlices.length), pSlices);
return { issueChart, prChart };
};

// All repos: 104 tracked issues of 141, 94 tracked PRs of 96.
const all = check(repos, issueSlices(104, 5), prSlices(94));
const issueOutside = all.issueChart.find(s => s.key === 'outside');
const prOutside = all.prChart.find(s => s.key === 'outside');
assert.equal(issueOutside.count, 37);
assert.equal(prOutside.count, 2);
assert.equal(issueOutside.className, 'overview-issue-outside');
assert.equal(prOutside.className, 'overview-pr-outside');
assert.match(issueOutside.rule, /14 filtered · 1 hive advisory · 22 dependency dashboard/);
assert.match(prOutside.rule, /: 2 draft$/);
assert.doesNotMatch(prOutside.rule, /held/);

// One repo selected (the knuckle shape: 134/95 on the cards, 100/93 in the
// bands): the chart follows that repo's card.
const one = check([repos[0]], issueSlices(100, 5), prSlices(93));
assert.equal(one.issueChart.find(s => s.key === 'outside').count, 34);
assert.match(one.issueChart.find(s => s.key === 'outside').rule, /11 filtered · 1 hive advisory · 22 dependency dashboard/);

// Nothing outside: no Outside slice at all.
const tidy = { full: 'acme/tidy', actionableIssues: fill(2), heldIssues: [], openPrs: fill(1), heldPrs: [],
workBreakdown: { issues: { actionable: 2 }, prs: { actionable: 1 } } };
const tidyIssues = [{ key: 'ready', count: 2, items: [] }];
const tidyPRs = [{ key: 'eligible', count: 1, items: [] }];
assert.deepEqual(overviewChartSlices('issue', tidyIssues, [tidy]), tidyIssues);
assert.deepEqual(overviewChartSlices('pr', tidyPRs, [tidy]), tidyPRs);

// History and the animation signature carry the Outside count.
const hist = { history: {} };
assert.equal(overviewSampleHistory('issue', all.issueChart, hist), true);
assert.equal(hist.history.issue[0].counts.outside, 37);
assert.match(overviewAnimationSignature(all.issueChart, all.prChart, []), /\["outside",37\]/);
`
out, err := exec.Command(node, "-e", script).CombinedOutput()
if err != nil {
t.Fatalf("node overview chart totals failed: %v\n%s", err, strings.TrimSpace(string(out)))
}
}

func TestOverviewBandChartsDrawOutsideSliceStatic(t *testing.T) {
html := indexHTML(t)
for _, want := range []string{
"const issueChartSlices = overviewChartSlices('issue', issueSlices, selectedRepos);",
"const prChartSlices = overviewChartSlices('pr', prSlices, selectedRepos);",
"overviewSampleHistory('issue', issueChartSlices, state)",
"overviewAnimationSignature(issueChartSlices, prChartSlices, selectedNames)",
// The KPI cards keep the band slices: their arithmetic reads band keys.
"renderOverviewKPIs(selectedRepos, issueSlices, prSlices, state)",
".overview-issue-outside, .overview-pr-outside { --slice-c: var(--muted); }",
"if (band === 'outside') return overviewApplyKPIProjectFilter('outside');",
"kind && !s.outside ?",
} {
if !strings.Contains(html, want) {
t.Errorf("index.html missing %q", want)
}
}
}
2 changes: 2 additions & 0 deletions src/pkg/dashboard/static-src/css/overview.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 37 additions & 6 deletions src/pkg/dashboard/static-src/js/overview.js
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@
const percent = (s.count / total) * OVERVIEW_CHART_PERCENT_SCALE;
const percentLabel = percent.toFixed(OVERVIEW_CHART_DECIMAL_PLACES) + '%';
const format = ((state && state.exportFormat) || 'csv').toUpperCase();
const download = kind ? `<button type="button" class="overview-band-download" data-action="overviewOpenExport" data-prevent="1" data-stop="1" data-arg0="${esc(overviewExportURL(kind, s.key))}" title="Export ${esc(s.label)} as ${format}" aria-label="Export ${esc(s.label)} as ${format}">⬇</button>` : '';
const download = kind && !s.outside ? `<button type="button" class="overview-band-download" data-action="overviewOpenExport" data-prevent="1" data-stop="1" data-arg0="${esc(overviewExportURL(kind, s.key))}" title="Export ${esc(s.label)} as ${format}" aria-label="Export ${esc(s.label)} as ${format}">⬇</button>` : '';
return `<div class="overview-chart-legend-row" data-action="overviewNavigateBand" data-arg0="${esc(kind || '')}" data-arg1="${esc(s.key)}" data-stop="1" title="${esc(s.label + (s.rule ? ': ' + s.rule : ''))}"><span class="overview-chart-swatch ${esc(s.className)}"></span><span class="overview-chart-legend-label">${esc(s.label)}</span><span class="overview-chart-legend-count">${esc(overviewSliceLabel(s.count, percentLabel, state))}</span>${download}</div>`;
}).join('');
}
Expand Down Expand Up @@ -971,6 +971,34 @@
return overviewRepoForgeTotals(repos);
}

// The bands draw only tracked items (actionable + held) while the "Total
// open" cards count every open item from the same forge totals, so the
// charts showed fewer items than the cards with nothing saying why. The
// Outside slice is the difference, so each chart adds up to its card for
// any repo selection; its rule carries the same breakdown the card does.
function overviewOutsideSlice(kind, slices, forgeTotals) {
const total = forgeTotals && forgeTotals[kind === 'pr' ? 'prs' : 'issues'];
const drawn = (slices || []).reduce((n, s) => n + Number(s.count || 0), 0);
const count = total ? Math.max(0, Number(total.forge || 0) - drawn) : 0;
const labels = kind === 'pr' ? OVERVIEW_PR_BREAKDOWN_LABELS : OVERVIEW_ISSUE_BREAKDOWN_LABELS;
const parts = Object.entries(labels).filter(([key]) => key !== 'hold').map(([key, label]) => {
const n = Number(total?.breakdown?.[key] || 0);
return n > 0 ? `${n} ${label}` : '';
}).filter(Boolean);
const what = kind === 'pr' ? 'Open PRs' : 'Open issues';
const rule = `${what} not in any band, left out by this hive's scanner settings${parts.length ? ': ' + parts.join(' · ') : ''}`;
return { key: 'outside', label: 'Outside', rule, count, className: 'overview-' + kind + '-outside', items: [], outside: true };
}

// overviewChartSlices is what the charts draw: the band slices plus the
// Outside slice when it is non-empty. The KPI cards keep the band slices.
function overviewChartSlices(kind, slices, repos) {
// renderOverviewKPIs sets the same scope; the forge totals read it.
_overviewKPILocalScope = overviewKPIRepoScope(repos);
const outside = overviewOutsideSlice(kind, slices, overviewKPIForgeTotals(repos));
return outside.count > 0 ? (slices || []).concat([outside]) : (slices || []);
}

function overviewKPIBreakdownSubline(total, labels) {
const parts = Object.entries(labels || {}).map(([key, label]) => {
const n = Number(total?.breakdown?.[key] || 0);
Expand Down Expand Up @@ -1524,6 +1552,7 @@
}

function overviewNavigateBand(kind, band) {
if (band === 'outside') return overviewApplyKPIProjectFilter('outside');
const key = kind === 'issue' ? (band === 'waiting' || band === 'done' ? 'blocked-needs-human' : 'actionable-now') : (band === 'waiting' || band === 'blocked' ? 'blocked-needs-human' : (band === 'draft' ? 'outside' : 'actionable-now'));
overviewApplyKPIProjectFilter(key);
}
Expand Down Expand Up @@ -1631,15 +1660,17 @@
const repoSuffix = overviewRepoSubtitleSuffix(_overviewLastRepos, selectedNames);
const issueSlices = overviewIssueBandSlices(selectedRepos);
const prSlices = overviewPRBandSlices(selectedRepos);
const animationSignature = overviewAnimationSignature(issueSlices, prSlices, selectedNames);
const issueChartSlices = overviewChartSlices('issue', issueSlices, selectedRepos);
const prChartSlices = overviewChartSlices('pr', prSlices, selectedRepos);
const animationSignature = overviewAnimationSignature(issueChartSlices, prChartSlices, selectedNames);
const dataChanged = overviewShouldAnimateData(animationSignature);
const issueSampled = overviewSampleHistory('issue', issueSlices, state);
const prSampled = overviewSampleHistory('pr', prSlices, state);
const issueSampled = overviewSampleHistory('issue', issueChartSlices, state);
const prSampled = overviewSampleHistory('pr', prChartSlices, state);
const sampled = issueSampled || prSampled;
const total = issueSlices.concat(prSlices).reduce((n, s) => n + s.count, 0);
const total = issueChartSlices.concat(prChartSlices).reduce((n, s) => n + s.count, 0);
const kpis = renderOverviewKPIs(selectedRepos, issueSlices, prSlices, state);
const html = total
? `${kpis}<div class="overview-grid">${renderOverviewPanel('issue', 'Issues by band', 'Actionable and held issues ' + repoSuffix + ' · hover a band for its rule', issueSlices, state)}${renderOverviewPanel('pr', 'PRs by band', 'Open and held pull requests ' + repoSuffix + ' · hover a band for its rule', prSlices, state)}</div>`
? `${kpis}<div class="overview-grid">${renderOverviewPanel('issue', 'Issues by band', 'Open issues ' + repoSuffix + ' · hover a band for its rule', issueChartSlices, state)}${renderOverviewPanel('pr', 'PRs by band', 'Open pull requests ' + repoSuffix + ' · hover a band for its rule', prChartSlices, state)}</div>`
: `${kpis}<div class="overview-empty">Nothing actionable — the hive is caught up</div>`;
if (sampled) saveOverviewChartsState(state);
setIfChanged(el, html);
Expand Down
Loading
Loading