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 += '
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 += '