From 7a24214afe1dc8322e0ea03c453978009566c194 Mon Sep 17 00:00:00 2001 From: mendezr Date: Wed, 18 Nov 2026 17:33:49 +0000 Subject: [PATCH 1/2] =?UTF-8?q?=E2=9C=A8=20feature:=20show=20recent=20kick?= =?UTF-8?q?=20outcomes=20in=20agent=20details?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Show the last ten kick outcomes and role-filtered evidence using the existing read API. Add refresh/error handling, renderer regression coverage and synthetic desktop/phone render-evidence fixtures. Hive-Run: hivecommons/hive#19032 Hive-Plan: kick-outcomes-ui Hive-Spec: issue-19032#scope Signed-off-by: mendezr --- .github/scripts/integration-governance.cjs | 2 +- changelog.d/added-kick-outcomes-ui.md | 1 + src/pkg/dashboard/kick_outcomes.test.js | 74 ++++++++++++++++++ .../dashboard/static-src/css/agent-detail.css | 6 ++ .../dashboard/static-src/js/agent-detail.js | 6 ++ .../dashboard/static-src/js/kick-outcomes.js | 46 ++++++++++++ src/pkg/dashboard/static-src/manifest.txt | 1 + src/pkg/dashboard/static/index.html | 58 ++++++++++++++ src/scripts/dashboard-render-evidence.mjs | 12 ++- .../render-evidence/api/kick-outcomes.json | 75 +++++++++++++++++++ src/scripts/lib/render-evidence.mjs | 1 + src/scripts/lib/render-evidence.test.mjs | 5 ++ 12 files changed, 285 insertions(+), 2 deletions(-) create mode 100644 changelog.d/added-kick-outcomes-ui.md create mode 100644 src/pkg/dashboard/kick_outcomes.test.js create mode 100644 src/pkg/dashboard/static-src/js/kick-outcomes.js create mode 100644 src/scripts/fixtures/render-evidence/api/kick-outcomes.json 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..dd5d7da002 --- /dev/null +++ b/src/pkg/dashboard/kick_outcomes.test.js @@ -0,0 +1,74 @@ +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 = () => {}) { + return new Function('esc', 'document', 'fetch', '_inceptionAuthHeaders', source + '\nreturn {kickOutcomesHtml, refreshKickOutcomes};')(esc, document, fetch, () => ({Authorization: 'Bearer fixture'})); +} +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('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('