diff --git a/.github/scripts/integration-governance.cjs b/.github/scripts/integration-governance.cjs index 61adc627d7..43c3f67287 100644 --- a/.github/scripts/integration-governance.cjs +++ b/.github/scripts/integration-governance.cjs @@ -9,7 +9,7 @@ const MAX_COMMITS = 1000; const MAX_AUTHOR_BATCH = 50; // This literal is inside the enrolled .github closure. A caller-supplied // preparedBy.sourceSHA must never choose a new executable verifier tree. -const TRUSTED_SCRIPTS_TREE = 'ff53044755a6b1a79a28925df7a4dd61d71462bb'; +const TRUSTED_SCRIPTS_TREE = '109f0f1af9f90cbdf4a7b433b22a0765bdb41d74'; const SOURCE = 'https://github.com/kubernetes-sigs/kubebuilder-release-tools/tree/012269a88fa4c034a0acf1ba84c26b195c0dbab4'; const sha = value => crypto.createHash('sha256').update(value).digest('hex'); const git = (args, cwd = process.cwd()) => diff --git a/changelog.d/added-kick-outcomes-ui.md b/changelog.d/added-kick-outcomes-ui.md new file mode 100644 index 0000000000..b349d3cdbd --- /dev/null +++ b/changelog.d/added-kick-outcomes-ui.md @@ -0,0 +1 @@ +- The dashboard agent detail panel now shows recent kick outcomes, with trigger, timing, PR, commit and refusal evidence for read-write users and owners, and only the latest one-line summary for read-only users ([#19032](https://github.com/hivecommons/hive/issues/19032)). diff --git a/src/pkg/dashboard/kick_outcomes.test.js b/src/pkg/dashboard/kick_outcomes.test.js new file mode 100644 index 0000000000..187f20e46c --- /dev/null +++ b/src/pkg/dashboard/kick_outcomes.test.js @@ -0,0 +1,90 @@ +const test = require('node:test'); +const assert = require('node:assert/strict'); +const fs = require('node:fs'); +const path = require('node:path'); +const source = fs.readFileSync(path.join(__dirname, 'static-src/js/kick-outcomes.js'), 'utf8'); +const esc = value => String(value).replace(/[&<>"']/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c])); +function build(document = {}, fetch = () => {}, formatDashboardDateTime = date => date.toISOString()) { + return new Function('esc', 'document', 'fetch', '_inceptionAuthHeaders', 'formatDashboardDateTime', source + '\nreturn {kickOutcomesHtml, refreshKickOutcomes};')(esc, document, fetch, () => ({Authorization: 'Bearer fixture'}), formatDashboardDateTime); +} +const fixture = JSON.parse(fs.readFileSync(path.join(__dirname, '../../scripts/fixtures/render-evidence/api/kick-outcomes.json'), 'utf8')); + +test('shipped dashboard wires outcomes into both full render and status refresh', () => { + const html = fs.readFileSync(path.join(__dirname, 'static/index.html'), 'utf8'); + assert.ok(html.includes('function kickOutcomesHtml(data)')); + assert.ok(html.includes('aria-label="Recent kick outcomes"')); + assert.equal((html.match(/refreshKickOutcomes\(a\.name\);/g) || []).length, 2); + assert.ok(html.includes('overflow-wrap: anywhere')); +}); + +test('all seven outcome kinds and real evidence render', () => { + const html = build().kickOutcomesHtml(fixture); + for (const label of ['Opened PR', 'Pushed commit', 'Commented', 'Stood down', 'Refused', 'Still running', 'Ended — no visible action']) assert.ok(html.includes(label), label); + for (const field of ['fixture-operator', 'PR #42', '0123456789abcdef', 'paused', 'No eligible work.']) assert.ok(html.includes(field), field); + assert.ok(html.includes('<This is untrusted agent text.>')); +}); + +test('timestamps use the shared dashboard formatter and preserve unknown-time fallbacks', () => { + const timestamps = []; + const {kickOutcomesHtml} = build({}, () => {}, date => { + timestamps.push(date.toISOString()); + return ''; + }); + const kick = {kind: 'stood_down', at: '2026-11-18T12:00:00Z', started_at: '2026-11-18T11:00:00Z', ended_at: '2026-11-18T12:01:00Z'}; + const html = kickOutcomesHtml({detail: true, kicks: [kick]}); + assert.deepEqual(timestamps.sort(), [kick.at, kick.started_at, kick.ended_at].map(value => new Date(value).toISOString()).sort()); + assert.equal((html.match(/<selected timezone & clock>/g) || []).length, 3); + timestamps.length = 0; + const unknown = kickOutcomesHtml({detail: true, kicks: [{kind: 'stood_down', at: 'invalid', ended_at: 'invalid'}]}); + assert.equal((unknown.match(/Unknown time/g) || []).length, 3); + assert.equal(timestamps.length, 0); +}); + +test('read-only response renders only its latest summary, even with stray detail fields', () => { + const html = build().kickOutcomesHtml({detail: false, latest: {...fixture.kicks[0], summary: 'Latest summary'}, kicks: fixture.kicks}); + assert.ok(html.includes('Latest summary')); + for (const hidden of ['fixture-operator', 'href=', 'Trigger:', 'Started:', 'blockquote', 'Branch:']) assert.ok(!html.includes(hidden), hidden); + assert.equal((html.match(/
  • /g) || []).length, 1); +}); + +test('empty history, malicious quotes, summaries and link protocols are safe', () => { + assert.match(build().kickOutcomesHtml({detail: true, kicks: null}), /No recorded kicks/); + assert.match(build().kickOutcomesHtml({detail: false}), /No recorded kicks/); + const html = build().kickOutcomesHtml({detail: true, kicks: [{kind: 'refused', summary: '', quote: '', pr_url: 'javascript:alert(1)', branch: 'branch', refusal_code: ''}]}); + assert.ok(!html.includes('