From 020559ea914f64f024c4ef286140e9f51ae71dfa Mon Sep 17 00:00:00 2001 From: Andy Anderson Date: Wed, 18 Nov 2026 00:36:48 -0500 Subject: [PATCH 1/2] =?UTF-8?q?=E2=9C=A8=20Build=20visibility=20UI:=20cont?= =?UTF-8?q?ains=20lookup=20on=20the=20hub=20hive=20list=20and=20the=20hive?= =?UTF-8?q?=20version=20menu?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds a PR number or commit SHA lookup (yes, no or unknown, with the reason) to the hub dashboard hive list and to the hive's own version menu, and shows the newest image commit and the newest merged commit separately. Regenerates static/index.html with make dashboard-gen. Part of #18915. Signed-off-by: Andy Anderson --- changelog.d/added-18915-build-contains-ui.md | 1 + .../dashboard/sidebar_version_panel_test.go | 1 + src/pkg/dashboard/static-src/css/topbar.css | 8 ++ src/pkg/dashboard/static-src/js/version.js | 70 ++++++++++++ src/pkg/dashboard/static/index.html | 78 +++++++++++++ src/pkg/dashboard/version_contains_ui_test.go | 63 +++++++++++ .../dashboard/version_provenance_ui_test.go | 2 +- src/pkg/hub/assets/dashboard.html | 107 ++++++++++++++++++ src/pkg/hub/build_contains_ui_test.go | 104 +++++++++++++++++ 9 files changed, 433 insertions(+), 1 deletion(-) create mode 100644 changelog.d/added-18915-build-contains-ui.md create mode 100644 src/pkg/dashboard/version_contains_ui_test.go create mode 100644 src/pkg/hub/build_contains_ui_test.go diff --git a/changelog.d/added-18915-build-contains-ui.md b/changelog.d/added-18915-build-contains-ui.md new file mode 100644 index 0000000000..7b3e2b6bc1 --- /dev/null +++ b/changelog.d/added-18915-build-contains-ui.md @@ -0,0 +1 @@ +- The hub hive list and each hive's version menu can now answer "does this build contain PR #N" ([#18915](https://github.com/hivecommons/hive/issues/18915)): type a PR number or commit SHA to see yes, no or unknown per hive, with the reason for every unknown and each hive's behind-by count. The version menu also shows the newest image commit and the newest merged commit as separate rows, so "merged, not yet built" is visible. diff --git a/src/pkg/dashboard/sidebar_version_panel_test.go b/src/pkg/dashboard/sidebar_version_panel_test.go index be369c8452..aaa5067363 100644 --- a/src/pkg/dashboard/sidebar_version_panel_test.go +++ b/src/pkg/dashboard/sidebar_version_panel_test.go @@ -135,6 +135,7 @@ const window = {}; jsFunc(t, html, "versionStatusSummary") + "\n" + jsFunc(t, html, "versionButtonHTML") + "\n" + jsFunc(t, html, "renderVersionUpgradeAction") + "\n" + + jsFunc(t, html, "versionBuildBlockHTML") + "\n" + jsFunc(t, html, "renderVersionDetails") + ` const out = renderVersionDetails({hash:'07d99d8426ec7b5ae364e25abcdef0123456789', short:'07d99d8', branch:'v5', channel:'candidate', tracking:'floating', latestHash:'07d99d8426ec7b5ae364e25abcdef0123456789', target:{sha:'07d99d8426ec7b5ae364e25abcdef0123456789', short:'07d99d8', managedBy:'hub'}, autoUpdate:{state:'up_to_date', managedBy:'hub', enabled:true, detail:'ok'}, releaseStatus:{attempt:{state:'succeeded', completedAt:'2026-10-02T10:00:00Z'}}}, {deliveryLabel:'candidate (v5)', offeredUpgradeHash:'07d99d8426ec7b5ae364e25abcdef0123456789', offeredUpgradeShort:'07d99d8'}); if (!out.includes('>07d99d8<')) throw new Error('short sha missing: '+out); diff --git a/src/pkg/dashboard/static-src/css/topbar.css b/src/pkg/dashboard/static-src/css/topbar.css index 103f6798c4..33c36790e9 100644 --- a/src/pkg/dashboard/static-src/css/topbar.css +++ b/src/pkg/dashboard/static-src/css/topbar.css @@ -59,6 +59,14 @@ .oc-version-row strong { min-width: 0; text-align: right; overflow-wrap: anywhere; } .oc-version-row strong, .oc-version-row a { color: var(--text); } .oc-version-row strong a { display: block; min-width: 0; overflow-wrap: anywhere; } + .oc-version-contains { display: grid; gap: var(--sp-2); padding: var(--sp-2) var(--sp-5); min-width: 0; } + .oc-version-contains-form { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; } + .oc-version-contains-form input { flex: 1; min-width: 0; padding: var(--sp-2) var(--sp-3); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm); color: var(--text); font-size: var(--fs-sm); font-family: inherit; } + .oc-version-contains-result { color: var(--muted); font-size: var(--fs-sm); overflow-wrap: anywhere; } + .oc-version-contains-chip { display: inline-block; padding: var(--sp-0) var(--sp-3); border-radius: var(--r-pill); border: 1px solid var(--border); font-size: var(--fs-xs); } + .oc-version-contains-chip.is-yes { color: var(--status-ok); border-color: var(--status-ok); } + .oc-version-contains-chip.is-no { color: var(--danger); border-color: var(--danger); } + .oc-version-contains-chip.is-unknown { color: var(--status-warn); border-color: var(--status-warn); } .oc-version-actions { display: flex; flex-direction: column; gap: var(--sp-2); padding: var(--sp-3) var(--sp-5); min-width: 0; } .oc-version-menu #spoke-upgrade-btn.oc-version-upgrade-available { border-color: var(--accent); box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 45%, transparent); } .oc-version-menu #spoke-upgrade-btn.oc-version-upgrade-available::before { content: '●'; color: var(--amber); font-size: 0.7em; line-height: 1; } diff --git a/src/pkg/dashboard/static-src/js/version.js b/src/pkg/dashboard/static-src/js/version.js index f12f6625d4..f2ca62a88e 100644 --- a/src/pkg/dashboard/static-src/js/version.js +++ b/src/pkg/dashboard/static-src/js/version.js @@ -819,6 +819,75 @@ return versionButtonHTML('Upgrade to ' + targetShort, 'Upgrade this Hive' + runtimeDeploymentSuffix + ' to ' + (ctx.offeredUpgradeLabel || 'target') + ' ' + targetShort + ' now', target.ref || targetHash, true); } + /* "Does this build contain PR #N?" (#18915). The lookup is answered by + GET /api/version/contains from git ancestry of the running commit: yes, + no, or unknown. Unknown is never a guess (commit not resolvable, PR not + found, lookup failed, or no GitHub access) and the reason says which. + The query and last answer live in window._versionContains so the menu, + which re-renders on every version poll, does not lose them. */ + function versionContainsResultHTML(r) { + if (!r) return ''; + if (r.error) return '' + escapeHtml(String(r.error)) + ''; + const verdict = r.contains === 'yes' || r.contains === 'no' ? r.contains : 'unknown'; + const q = r.query || {}; + const what = q.kind === 'pr' ? 'PR #' + q.pr : 'commit ' + String(q.commit || '').slice(0, 7); + const tested = r.commit ? ' (' + String(r.commit).slice(0, 7) + ')' : ''; + return '' + verdict + ' ' + + escapeHtml(what + tested) + (r.reason ? ': ' + escapeHtml(String(r.reason)) : ''); + } + + /* The newest image commit and the newest merged commit are shown + separately: a channel image can sit on an older commit than the newest + merge (merged, not yet built), and one number would hide that. */ + function versionBuildBlockHTML(v) { + const newestImage = String((v && v.target && v.target.short) || (v && v.stableV4Short) || ''); + const newestMerged = String((v && v.latestShort) || ''); + const cell = function(label, text, title) { + return '
' + escapeHtml(label) + '' + escapeHtml(text) + '
'; + }; + let html = ''; + if (newestImage) html += cell('Newest image', newestImage, 'The newest commit whose image is published for the channel this hive follows'); + if (newestMerged) { + const unbuilt = newestImage && !versionSameCommit(newestImage, newestMerged); + html += cell('Newest merged', newestMerged + (unbuilt ? ' (not in the newest image)' : ''), 'The newest commit merged on this hive\'s branch'); + } + const st = window._versionContains || {}; + html += '
' + + '
' + + '' + + '' + + '
' + + '
' + (st.html || '') + '
' + + '
'; + return html; + } + + function versionContainsDraft(value) { + window._versionContains = Object.assign({}, window._versionContains, { q: String(value || '') }); + } + + async function runVersionContains() { + const input = document.getElementById('oc-version-contains-q'); + const out = document.getElementById('oc-version-contains-result'); + const q = String((input && input.value) || (window._versionContains && window._versionContains.q) || '').trim(); + if (!out || !q) return; + const seq = (window._versionContainsSeq = (window._versionContainsSeq || 0) + 1); + window._versionContains = { q: q, html: 'Checking…' }; + out.textContent = 'Checking…'; + let html; + try { + const res = await fetch('/api/version/contains?q=' + encodeURIComponent(q)); + const body = await res.json(); + html = versionContainsResultHTML(res.ok ? body : { error: body && body.error || 'Lookup failed; try again.' }); + } catch (_) { + html = versionContainsResultHTML({ error: 'Lookup failed; try again.' }); + } + if (seq !== window._versionContainsSeq) return; + window._versionContains = { q: q, html: html }; + const live = document.getElementById('oc-version-contains-result'); + if (live) live.innerHTML = html; + } + function renderVersionDetails(v, ctx) { ctx = ctx || {}; const fullHash = String(v && v.hash || 'unknown'); @@ -871,6 +940,7 @@ if (lastUpgrade) html += row('History', value(lastUpgrade.text, lastUpgrade.title || lastUpgrade.text), lastUpgrade.title || lastUpgrade.text); const historyHTML = versionUpgradeHistoryHTML(v); if (historyHTML) html += '
Upgrade history
' + historyHTML; + html += versionBuildBlockHTML(v); if (compareURL && (v && (v.behind || (v.commitsBehind != null && v.commitsBehind > 0)))) { html += 'Compare with target ↗'; } diff --git a/src/pkg/dashboard/static/index.html b/src/pkg/dashboard/static/index.html index 14aea7df3f..00963b4056 100644 --- a/src/pkg/dashboard/static/index.html +++ b/src/pkg/dashboard/static/index.html @@ -428,6 +428,14 @@ .oc-version-row strong { min-width: 0; text-align: right; overflow-wrap: anywhere; } .oc-version-row strong, .oc-version-row a { color: var(--text); } .oc-version-row strong a { display: block; min-width: 0; overflow-wrap: anywhere; } + .oc-version-contains { display: grid; gap: var(--sp-2); padding: var(--sp-2) var(--sp-5); min-width: 0; } + .oc-version-contains-form { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; } + .oc-version-contains-form input { flex: 1; min-width: 0; padding: var(--sp-2) var(--sp-3); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm); color: var(--text); font-size: var(--fs-sm); font-family: inherit; } + .oc-version-contains-result { color: var(--muted); font-size: var(--fs-sm); overflow-wrap: anywhere; } + .oc-version-contains-chip { display: inline-block; padding: var(--sp-0) var(--sp-3); border-radius: var(--r-pill); border: 1px solid var(--border); font-size: var(--fs-xs); } + .oc-version-contains-chip.is-yes { color: var(--status-ok); border-color: var(--status-ok); } + .oc-version-contains-chip.is-no { color: var(--danger); border-color: var(--danger); } + .oc-version-contains-chip.is-unknown { color: var(--status-warn); border-color: var(--status-warn); } .oc-version-actions { display: flex; flex-direction: column; gap: var(--sp-2); padding: var(--sp-3) var(--sp-5); min-width: 0; } .oc-version-menu #spoke-upgrade-btn.oc-version-upgrade-available { border-color: var(--accent); box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 45%, transparent); } .oc-version-menu #spoke-upgrade-btn.oc-version-upgrade-available::before { content: '●'; color: var(--amber); font-size: 0.7em; line-height: 1; } @@ -62801,6 +62809,75 @@

Configure LiteLLM

return versionButtonHTML('Upgrade to ' + targetShort, 'Upgrade this Hive' + runtimeDeploymentSuffix + ' to ' + (ctx.offeredUpgradeLabel || 'target') + ' ' + targetShort + ' now', target.ref || targetHash, true); } + /* "Does this build contain PR #N?" (#18915). The lookup is answered by + GET /api/version/contains from git ancestry of the running commit: yes, + no, or unknown. Unknown is never a guess (commit not resolvable, PR not + found, lookup failed, or no GitHub access) and the reason says which. + The query and last answer live in window._versionContains so the menu, + which re-renders on every version poll, does not lose them. */ + function versionContainsResultHTML(r) { + if (!r) return ''; + if (r.error) return '' + escapeHtml(String(r.error)) + ''; + const verdict = r.contains === 'yes' || r.contains === 'no' ? r.contains : 'unknown'; + const q = r.query || {}; + const what = q.kind === 'pr' ? 'PR #' + q.pr : 'commit ' + String(q.commit || '').slice(0, 7); + const tested = r.commit ? ' (' + String(r.commit).slice(0, 7) + ')' : ''; + return '' + verdict + ' ' + + escapeHtml(what + tested) + (r.reason ? ': ' + escapeHtml(String(r.reason)) : ''); + } + + /* The newest image commit and the newest merged commit are shown + separately: a channel image can sit on an older commit than the newest + merge (merged, not yet built), and one number would hide that. */ + function versionBuildBlockHTML(v) { + const newestImage = String((v && v.target && v.target.short) || (v && v.stableV4Short) || ''); + const newestMerged = String((v && v.latestShort) || ''); + const cell = function(label, text, title) { + return '
' + escapeHtml(label) + '' + escapeHtml(text) + '
'; + }; + let html = ''; + if (newestImage) html += cell('Newest image', newestImage, 'The newest commit whose image is published for the channel this hive follows'); + if (newestMerged) { + const unbuilt = newestImage && !versionSameCommit(newestImage, newestMerged); + html += cell('Newest merged', newestMerged + (unbuilt ? ' (not in the newest image)' : ''), 'The newest commit merged on this hive\'s branch'); + } + const st = window._versionContains || {}; + html += '
' + + '
' + + '' + + '' + + '
' + + '
' + (st.html || '') + '
' + + '
'; + return html; + } + + function versionContainsDraft(value) { + window._versionContains = Object.assign({}, window._versionContains, { q: String(value || '') }); + } + + async function runVersionContains() { + const input = document.getElementById('oc-version-contains-q'); + const out = document.getElementById('oc-version-contains-result'); + const q = String((input && input.value) || (window._versionContains && window._versionContains.q) || '').trim(); + if (!out || !q) return; + const seq = (window._versionContainsSeq = (window._versionContainsSeq || 0) + 1); + window._versionContains = { q: q, html: 'Checking…' }; + out.textContent = 'Checking…'; + let html; + try { + const res = await fetch('/api/version/contains?q=' + encodeURIComponent(q)); + const body = await res.json(); + html = versionContainsResultHTML(res.ok ? body : { error: body && body.error || 'Lookup failed; try again.' }); + } catch (_) { + html = versionContainsResultHTML({ error: 'Lookup failed; try again.' }); + } + if (seq !== window._versionContainsSeq) return; + window._versionContains = { q: q, html: html }; + const live = document.getElementById('oc-version-contains-result'); + if (live) live.innerHTML = html; + } + function renderVersionDetails(v, ctx) { ctx = ctx || {}; const fullHash = String(v && v.hash || 'unknown'); @@ -62853,6 +62930,7 @@

Configure LiteLLM

if (lastUpgrade) html += row('History', value(lastUpgrade.text, lastUpgrade.title || lastUpgrade.text), lastUpgrade.title || lastUpgrade.text); const historyHTML = versionUpgradeHistoryHTML(v); if (historyHTML) html += '
Upgrade history
' + historyHTML; + html += versionBuildBlockHTML(v); if (compareURL && (v && (v.behind || (v.commitsBehind != null && v.commitsBehind > 0)))) { html += 'Compare with target ↗'; } diff --git a/src/pkg/dashboard/version_contains_ui_test.go b/src/pkg/dashboard/version_contains_ui_test.go new file mode 100644 index 0000000000..ba5f28b98b --- /dev/null +++ b/src/pkg/dashboard/version_contains_ui_test.go @@ -0,0 +1,63 @@ +package dashboard + +import ( + "os/exec" + "strings" + "testing" +) + +// The version menu's "Does this build contain PR #N?" block (#18915) is +// rendered by functions inside the generated index.html. This runs the shipped +// functions in node. The slice needs stubs: escapeHtml and versionSameCommit +// are real; window stands in for the browser global the block keeps its state in. +func TestVersionContainsUIRenders(t *testing.T) { + node, err := exec.LookPath("node") + if err != nil { + t.Skip("node unavailable: version contains rendering was not executed") + } + html := indexHTML(t) + var source strings.Builder + source.WriteString("const window = {};\n") + for _, name := range []string{"escapeHtml", "versionShortSHA", "versionSameCommit", "versionContainsResultHTML", "versionBuildBlockHTML", "versionContainsDraft"} { + source.WriteString(jsFunc(t, html, name)) + source.WriteByte('\n') + } + source.WriteString(` +const assert = (cond, msg) => { if (!cond) throw new Error(msg); }; + +const yes = versionContainsResultHTML({contains: 'yes', query: {kind: 'pr', pr: 7}, commit: '1a2b3c4d5e6f'}); +assert(yes.includes('is-yes') && yes.includes('PR #7') && yes.includes('1a2b3c4'), 'yes: ' + yes); + +const no = versionContainsResultHTML({contains: 'no', query: {kind: 'commit', commit: 'abcdef1234'}}); +assert(no.includes('is-no') && !no.includes('is-yes'), 'no: ' + no); + +// Anything that is not an explicit yes or no must read as unknown, never as a confident answer. +for (const odd of [undefined, '', 'maybe', 'YES', null]) { + const out = versionContainsResultHTML({contains: odd, query: {kind: 'pr', pr: 9}, reason: 'the commit is not in the repository history'}); + assert(out.includes('is-unknown') && !out.includes('is-yes') && !out.includes('is-no'), 'odd verdict ' + odd + ': ' + out); + assert(out.includes('not in the repository history'), 'reason must be shown: ' + out); +} + +const failed = versionContainsResultHTML({error: 'Lookup failed; try again.'}); +assert(!failed.includes('oc-version-contains-chip'), 'a failed lookup must show no verdict: ' + failed); + +const escaped = versionContainsResultHTML({contains: 'unknown', query: {kind: 'pr', pr: 1}, reason: ''}); +assert(!escaped.includes(' + +
Loading your hives...
@@ -6331,6 +6352,90 @@

' + esc(err || 'Lookup failed; try again.') + ''; + var q = resp.query || {}; + var head = q.kind === 'pr' ? 'PR #' + q.pr : 'commit ' + (q.commit || ''); + if (resp.commit) head += ' (tested as ' + resp.commit.slice(0, 7) + ')'; + if (resp.reason) head += ': ' + resp.reason; + var html = '
' + esc(head) + '
'; + var hives = resp.hives || []; + if (!hives.length) return html + '
No hives to check.
'; + hives.forEach(function(h) { + var verdict = h.contains === 'yes' || h.contains === 'no' ? h.contains : 'unknown'; + var note = buildContainsNote(rowsById && rowsById[h.id]); + var reason = h.reason || ''; + html += '
' + + '' + esc(h.name || h.id) + '' + + '' + esc((h.commit || '').slice(0, 7) || 'no commit') + '' + + (h.channel ? '' + esc(h.channel) + '' : '') + + '' + esc(verdict) + '' + + (reason ? '' + esc(reason) + '' : '') + + (note ? '' + esc(note) + '' : '') + + '
'; + }); + return html; + } + + function clearBuildContains() { + _buildContainsSeq++; + var input = document.getElementById('hive-contains-q'); + var out = document.getElementById('hive-contains-result'); + var clearBtn = document.getElementById('hive-contains-clear'); + if (input) input.value = ''; + if (out) { out.style.display = 'none'; out.innerHTML = ''; } + if (clearBtn) clearBtn.style.display = 'none'; + } + + function runBuildContains() { + var input = document.getElementById('hive-contains-q'); + var out = document.getElementById('hive-contains-result'); + var clearBtn = document.getElementById('hive-contains-clear'); + if (!input || !out) return; + var q = (input.value || '').trim(); + if (!q) { clearBuildContains(); return; } + var seq = ++_buildContainsSeq; + out.style.display = ''; + out.textContent = 'Checking…'; + if (clearBtn) clearBtn.style.display = ''; + var rowsById = {}; + (_allDashHives || []).forEach(function(h) { if (h && h.id) rowsById[h.id] = h; }); + fetch('/api/saas/build-contains?q=' + encodeURIComponent(q), { credentials: 'same-origin' }) + .then(function(resp) { + if (resp.status === 401) { window.location.href = '/login'; return null; } + return resp.json().then(function(body) { return { ok: resp.ok, body: body }; }); + }) + .then(function(r) { + if (!r || seq !== _buildContainsSeq) return; + out.innerHTML = r.ok + ? renderBuildContains(r.body, '', rowsById) + : renderBuildContains(null, (r.body && r.body.error) || 'Lookup failed; try again.'); + }) + .catch(function() { + if (seq === _buildContainsSeq) out.innerHTML = renderBuildContains(null, 'Lookup failed; try again.'); + }); + } + /* onHiveSearchInput debounces then re-renders from the unfiltered cache so search composes with the chips, the facets and the current sort. */ function onHiveSearchInput() { @@ -8919,6 +9024,8 @@

/g, '>'); } +function escAttr(s) { return esc(s).replace(/"/g, '"').replace(/'/g, '''); } +` + +func runContainsJS(t *testing.T, script string) map[string]string { + t.Helper() + src := strings.Join([]string{ + containsJSStubs, + jsFunc(t, "buildContainsNote"), + jsFunc(t, "renderBuildContains"), + script, + }, "\n") + stdout, err := exec.Command("node", "-e", src).Output() + if err != nil { + if ee, ok := err.(*exec.ExitError); ok { + t.Fatalf("node failed: %v\nstderr:\n%s", err, ee.Stderr) + } + t.Skipf("node unavailable: %v", err) + } + var got map[string]string + if err := json.Unmarshal(stdout, &got); err != nil { + t.Fatalf("decode %q: %v", stdout, err) + } + return got +} + +func TestBuildContainsUIVerdictsAndEscaping(t *testing.T) { + got := runContainsJS(t, ` +var resp = {query: {kind: 'pr', pr: 7}, commit: '1a2b3c4d5e6f', hives: [ + {id: 'a', name: 'alpha', commit: 'aaaaaaa1', channel: 'stable', contains: 'yes'}, + {id: 'b', name: 'beta', commit: 'bbbbbbb2', contains: 'no'}, + {id: 'c', name: 'gamma', commit: '', contains: 'unknown', reason: 'the hive reports no resolvable commit'}, + {id: 'd', name: 'delta', commit: 'ddddddd4', contains: 'definitely'} +]}; +var rows = {a: {commitsBehindTarget: 3, behindTargetRef: ':stable', behindTargetSHA: '1111111', branchTipSHA: '2222222'}}; +process.stdout.write(JSON.stringify({ + html: renderBuildContains(resp, '', rows), + failed: renderBuildContains(null, 'Lookup failed', rows), + empty: renderBuildContains({query: {kind: 'commit', commit: 'abc1234'}, hives: []}, '', {}), +}));`) + html := got["html"] + if strings.Contains(html, "alpha") { + t.Fatalf("hive names must be escaped: %s", html) + } + if strings.Count(html, `hive-contains-chip yes`) != 1 || strings.Count(html, `hive-contains-chip no`) != 1 { + t.Fatalf("expected exactly one yes and one no chip: %s", html) + } + // An unrecognised or missing verdict must render as unknown, never as a + // confident answer. + if strings.Count(html, `hive-contains-chip unknown`) != 2 { + t.Fatalf("empty and unrecognised verdicts must both render unknown: %s", html) + } + if !strings.Contains(html, "newest image 1111111") || !strings.Contains(html, "newest merged 2222222") { + t.Fatalf("the image commit and the merged commit must be shown separately: %s", html) + } + if !strings.Contains(html, "3 behind :stable") { + t.Fatalf("the behind count must be shown: %s", html) + } + if !strings.Contains(html, "no commit") { + t.Fatalf("a hive with no commit must say so: %s", html) + } + if !strings.Contains(got["failed"], "Lookup failed") || strings.Contains(got["failed"], "hive-contains-chip") { + t.Fatalf("a failed lookup must show the error and no verdicts: %s", got["failed"]) + } + if !strings.Contains(got["empty"], "No hives to check") { + t.Fatalf("empty fleet: %s", got["empty"]) + } +} + +func TestBuildContainsUIWiring(t *testing.T) { + html := dashScript(t) + for _, want := range []string{ + `id="hive-contains-q"`, + `onclick="runBuildContains()"`, + `onclick="clearBuildContains()"`, + "/api/saas/build-contains?q=", + "function runBuildContains(", + "function clearBuildContains(", + } { + if !strings.Contains(html, want) { + t.Fatalf("dashboard is missing %q", want) + } + } + // The lookup is on demand: no timer may drive it. + for _, name := range []string{"runBuildContains", "clearBuildContains", "renderBuildContains", "buildContainsNote"} { + if body := jsFunc(t, name); strings.Contains(body, "setInterval") { + t.Fatalf("%s must not use setInterval", name) + } + } +} From baf61df95707f4ee158eeb51a7fca3c0793f3e45 Mon Sep 17 00:00:00 2001 From: Andy Anderson Date: Wed, 18 Nov 2026 00:56:34 -0500 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=8C=B1=20Keep=20the=20hub=20styling?= =?UTF-8?q?=20ratchet=20green:=20tokens=20and=20hidden=20attribute=20for?= =?UTF-8?q?=20the=20contains=20lookup?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Part of #18915. Signed-off-by: Andy Anderson --- src/pkg/hub/assets/dashboard.html | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/pkg/hub/assets/dashboard.html b/src/pkg/hub/assets/dashboard.html index 9f9138e7b3..18b17a27c8 100644 --- a/src/pkg/hub/assets/dashboard.html +++ b/src/pkg/hub/assets/dashboard.html @@ -212,15 +212,16 @@ #hive-search-clear { flex: none; } /* "Does this build contain PR #N?" (#18915). Tokens only. */ #hive-contains-row { display: flex; align-items: center; gap: 10px; margin-bottom: var(--sp-3); } - #hive-contains-q { flex: 1; min-width: 0; padding: 8px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); color: var(--text); font-size: 0.85rem; font-family: inherit; } + #hive-contains-q { flex: 1; min-width: 0; padding: var(--sp-4) var(--sp-6); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); color: var(--text); font-size: var(--fs-sm); font-family: inherit; } #hive-contains-q:focus { outline: none; border-color: var(--hub-dashboard-accent); } - .hive-contains-label { flex: none; color: var(--muted); font-size: 0.85rem; } - .hive-contains-result { margin-bottom: var(--sp-5); padding: var(--sp-3) var(--sp-4); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); font-size: 0.85rem; } + .hive-contains-label { flex: none; color: var(--muted); font-size: var(--fs-sm); } + #hive-contains-row[hidden], #hive-contains-result[hidden], #hive-contains-clear[hidden] { display: none; } + .hive-contains-result { margin-bottom: var(--sp-5); padding: var(--sp-3) var(--sp-4); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); font-size: var(--fs-sm); } .hive-contains-head { color: var(--muted); margin-bottom: var(--sp-2); } .hive-contains-item { display: flex; align-items: baseline; flex-wrap: wrap; gap: var(--sp-2) var(--sp-3); padding: var(--sp-1) 0; } .hive-contains-sha { font-family: monospace; color: var(--muted); } .hive-contains-note { color: var(--muted); font-size: var(--fs-2xs); } - .hive-contains-chip { display: inline-block; padding: 1px 8px; border-radius: var(--r-pill); font-size: var(--fs-2xs); border: 1px solid var(--border); white-space: nowrap; } + .hive-contains-chip { display: inline-block; padding: var(--sp-1) var(--sp-4); border-radius: var(--r-pill); font-size: var(--fs-2xs); border: 1px solid var(--border); white-space: nowrap; } .hive-contains-chip.yes { color: var(--green); border-color: var(--green); } .hive-contains-chip.no { color: var(--red); border-color: var(--red); } .hive-contains-chip.unknown { color: var(--yellow); border-color: var(--yellow); } @@ -928,13 +929,13 @@