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
5,095 changes: 5,095 additions & 0 deletions .ci-log.txt

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions changelog.d/changed-pr-in-progress-actor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Activity Monitor: a lit "PR in progress" chevron names who works the PR with their kind icon — `PR in progress · @login` plus the hive / clanker / person glyph, the way "Waiting for @login" does (hivecommons/hive#16770); the name truncates with the copy, the tooltip holds the full text, and nobody known keeps the bare word.
77 changes: 77 additions & 0 deletions src/pkg/dashboard/stage_tracker_pr_progress_actor_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package dashboard

import "testing"

// A lit "PR in progress" chevron names who works the PR with their kind
// icon, the way "Waiting for @x" names its person: "PR in progress ·
// @thatguywob" + the robot for a clanker, the honeycomb for a hive agent,
// the person glyph for a human. The name rides inside the clamped copy
// (truncates like every holder) with the full text in the tooltip; the
// icon sits outside the copy. Nobody known keeps the bare word; an
// inactive column stays icon-only.
func TestStageTrackerPRProgressActorChevronJS(t *testing.T) {
html := indexHTML(t)
runStageTrackerRowActionsScript(t, stageTrackerRowsPreludeJS(t, html)+"\n"+stageTrackerActorIconJS(t, html)+stageTrackerRowsFixtureJS+`
const lit = (html) => (/<li class="ham-seg active[^"]*"[^>]*>([\s\S]*?)<\/li>/.exec(strip(html)) || ['', ''])[1];
const litWord = (html) => text(lit(html));
const copyText = (html) => text((/<span class="ham-chevron-copy">([\s\S]*?)<\/span>(?:<svg|<span id=)/.exec(lit(html)) || ['', ''])[1]);
const actorIco = (html) => (/<svg class="ham-ico ham-actor-ico"[^>]*aria-label="([^"]*)"[^>]*>([\s\S]*?)<\/svg>/.exec(lit(html)) || []);
const chevronTip = (html) => text((/<span id="ham-chevron-tip-[^"]*" class="config-tooltip ham-chevron-tip" role="tooltip">([\s\S]*?)<\/span>/.exec(lit(html)) || ['', ''])[1]);
const since = new Date(now - 3 * 3600000).toISOString();
// An issue drawn through its one unclassified covering PR: the PR row
// lights "PR in progress" under the issue (hivecommons/hive#15541); the
// payload carries the PR's author but no holder and no next mover.
const subRow = (prExtra) => stageTrackerRowHtml({ repo: 'hivecommons/hive', number: 10, kind: 'issue', title: 'fix it', url: 'https://x/10', stage: 40, stage_since: since, caption: 'Covered by PR', author: 'reporter', author_kind: 'human', stage_actor: { kind: 'none', why: 'its PR' }, linked_prs: [
Object.assign({ number: 101, url: 'https://x/101', title: 'fix', stage: 0, stage_since: since, caption: 'PR in progress', stage_actor: { kind: 'none', why: '' } }, prExtra),
] }, stages, ctx);

// Hive-agent author → @login + honeycomb.
let row = subRow({ author: 'thatguywob', author_kind: 'hive' });
assert.strictEqual(litWord(row), 'PR in progress · @thatguywob', litWord(row));
assert.ok(actorIco(row)[2] && actorIco(row)[2].includes(STAGE_TRACKER_ICONS.hive), 'hive author draws the honeycomb: ' + lit(row));
assert.strictEqual(actorIco(row)[1], 'Working the PR: hive @thatguywob');
assert.ok(/<span class="ham-seg-t ham-has-holder">PR in progress<span class="ham-holder"> · @thatguywob<\/span><\/span>/.test(lit(row)), 'the name rides the holder slot inside the copy: ' + lit(row));
assert.strictEqual(copyText(row), 'PR in progress · @thatguywob', 'the icon is outside the clamped copy: ' + lit(row));
assert.ok(chevronTip(row).includes('PR in progress · @thatguywob'), 'the tooltip holds the full text: ' + chevronTip(row));

// Clanker author → robot; human author → the person glyph.
row = subRow({ author: 'thatguywob', author_kind: 'clanker' });
assert.strictEqual(litWord(row), 'PR in progress · @thatguywob', litWord(row));
assert.ok(actorIco(row)[2].includes(STAGE_TRACKER_ICONS.clanker), 'clanker author draws the robot: ' + lit(row));
row = subRow({ author: 'alice', author_kind: 'human' });
assert.strictEqual(litWord(row), 'PR in progress · @alice', litWord(row));
assert.ok(actorIco(row)[2].includes(STAGE_TRACKER_ICONS.human), 'human author draws the person glyph: ' + lit(row));

// A recorded holder still leads and is named once.
row = subRow({ author: 'bob', author_kind: 'clanker', claimant: { kind: 'clanker', login: 'bob', since, source: 'author' } });
assert.strictEqual(litWord(row), "PR in progress · @bob's clanker", litWord(row));
assert.strictEqual((lit(row).match(/ham-actor-ico/g) || []).length, 1, 'one actor icon: ' + lit(row));

// Nobody known (bot author, unlabelled author): the bare word, no icon.
for (const extra of [{ author: 'dependabot[bot]', author_kind: 'bot' }, { author: 'someone', author_kind: '' }, { author: '', author_kind: '' }]) {
row = subRow(extra);
assert.strictEqual(litWord(row), 'PR in progress', JSON.stringify(extra) + ': ' + litWord(row));
assert.ok(!lit(row).includes('ham-actor-ico') && !lit(row).includes('ham-has-holder'), JSON.stringify(extra) + ': ' + lit(row));
}

// The server's stage_actor login names the actor when no holder is recorded.
row = stageTrackerRowHtml({ repo: 'hivecommons/hive', number: 11, kind: 'issue', title: 'fix it', url: 'https://x/11', stage: 30, stage_since: since, caption: 'PR in progress', author: 'reporter', author_kind: 'human', stage_actor: { kind: 'hive', login: 'fixer', why: 'fixer is on it' } }, stages, ctx);
assert.strictEqual(litWord(row), 'PR in progress · @fixer', litWord(row));
assert.strictEqual((lit(row).match(/ham-actor-ico/g) || []).length, 1, 'the next-move icon stands, not a second one: ' + lit(row));
// An issue's own author filed the issue, never works a PR: no name without a PR.
row = stageTrackerRowHtml({ repo: 'hivecommons/hive', number: 12, kind: 'issue', title: 'fix it', url: 'https://x/12', stage: 30, stage_since: since, caption: 'PR in progress', author: 'reporter', author_kind: 'human', stage_actor: { kind: 'hive', why: 'an agent has a PR under way' } }, stages, ctx);
assert.strictEqual(litWord(row), 'PR in progress', litWord(row));

// Inactive (the PR moved on to CI / Review): the column is its icon alone.
row = subRow({ author: 'thatguywob', author_kind: 'clanker', stage: 50, head: 'h1' });
assert.ok(!text(strip(row)).includes('@thatguywob'), 'a passed PR in progress column carries no name: ' + strip(row));
assert.ok(!/<li class="ham-seg done[^"]*"[^>]*>(?:(?!<\/li>)[\s\S])*ham-holder/.test(strip(row)), 'no holder text on a done column: ' + strip(row));

// Pure helper: the word gate and the fallback order.
assert.strictEqual(stageTrackerPRProgressActor({ kind: 'pr', author: 'alice', author_kind: 'human' }, 'Fixing'), null, 'only the bare word names an actor');
assert.deepStrictEqual(stageTrackerPRProgressActor({ kind: 'pr', author: 'alice', author_kind: 'human' }, 'PR in progress'), { who: '@alice', kind: 'human' });
assert.deepStrictEqual(stageTrackerPRProgressActor({ kind: 'pr', author: 'alice', author_kind: 'human', stage_actor: { kind: 'clanker', login: 'bob' } }, 'PR in progress'), { who: '@bob', kind: 'clanker' }, 'stage_actor login outranks the author');
assert.deepStrictEqual(stageTrackerPRProgressActor({ kind: 'pr', author: 'alice', author_kind: 'human', claimant: { kind: 'hive-agent', agent: 'quality' } }, 'PR in progress'), { who: 'quality', kind: 'hive' }, 'the recorded holder outranks both');
console.log('pr progress actor chevron ok');
`)
}
3 changes: 3 additions & 0 deletions src/pkg/dashboard/stage_tracker_ui_prelude_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ func stageTrackerRowsPreludeJS(t *testing.T, html string) string {
jsFunc(t, html, "stageTrackerClaimantIconKind"),
jsFunc(t, html, "stageTrackerClaimantShort"),
jsFunc(t, html, "stageTrackerClaimantLine"),
jsConstLine(t, html, "STAGE_TRACKER_PR_PROGRESS_WORD"),
jsConstLine(t, html, "STAGE_TRACKER_PR_PROGRESS_KINDS"),
jsFunc(t, html, "stageTrackerPRProgressActor"),
jsConstLine(t, html, "STAGE_TRACKER_MOTION_STATIC"),
jsConstLine(t, html, "STAGE_TRACKER_MOTION_ACTIVE"),
jsConstLine(t, html, "STAGE_TRACKER_MOTION_HUMAN"),
Expand Down
14 changes: 11 additions & 3 deletions src/pkg/dashboard/static-src/js/tracker-row-strip.js
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,15 @@
// already carries a why ("Ready for human merge · workflow files").
const wordText = String(sg.detour ? sg.detour.text : (sg.short || ''));
const reasonHtml = active && !sg.cap && humanReason && !gateWord && wordText.indexOf(' · ') < 0 && wordText.toLowerCase().indexOf(humanReason.toLowerCase()) < 0 ? `<span class="ham-human-reason"> · ${esc(humanReason)}</span>` : '';
const word = sg.detour ? `<span class="ham-detour${detourHolder ? ' ham-has-holder' : ''}">${esc(sg.detour.text)}${detourHolder}${reasonHtml}</span>` : (gateWord || `<span class="ham-seg-t${holderHtml ? ' ham-has-holder' : ''}">${esc(sg.short)}${holderHtml}${reasonHtml}</span>`);
// A lit "PR in progress" names who works the PR with their kind
// icon, the way "Waiting for @x" names its person (hive#16770): "PR in progress
// · @thatguywob" + robot. The name rides inside the clamped copy
// (truncates like every holder); the icon sits outside it. Nobody
// known keeps the bare word. Guarded: harnesses lift by name.
const progressActor = typeof stageTrackerPRProgressActor === 'function' && active && !sg.cap && sg.number === STAGE_TRACKER_PR_COLUMN && !sg.detour && !gateWord ? stageTrackerPRProgressActor(item, wordText) : null;
const progressHolderHtml = holderHtml || (progressActor ? `<span class="ham-holder"> · ${esc(progressActor.who)}</span>` : '');
const progressIco = progressActor && !actorIco && !holderIco ? stageTrackerIcon(progressActor.kind, 'ham-ico ham-actor-ico', 'Working the PR: ' + progressActor.kind + ' ' + progressActor.who) : '';
const word = sg.detour ? `<span class="ham-detour${detourHolder ? ' ham-has-holder' : ''}">${esc(sg.detour.text)}${detourHolder}${reasonHtml}</span>` : (gateWord || `<span class="ham-seg-t${progressHolderHtml ? ' ham-has-holder' : ''}">${esc(sg.short)}${progressHolderHtml}${reasonHtml}</span>`);
const gateCue = gateWord && typeof stageTrackerGateCueHtml === 'function' ? stageTrackerGateCueHtml(item, nowMs, trains) : '';
// The agent-working spinner (tracker-cues) names the agent and what
// it did, so a spinning glyph is never unexplained.
Expand All @@ -543,15 +551,15 @@
// the column is the row's history and wears the history mark.
if (sg.cap) inner = sg.terminal ? stageTrackerIcon(sg.number, 'ham-ico') : stageTrackerIcon('history', 'ham-ico ham-history-ico', 'History — no decisions or actions recorded yet');
else if (active) {
const fullTip = [tip, gateCaption || (sg.detour ? sg.detour.text : sg.short), item.caption, item.reason,
const fullTip = [tip, gateCaption || (sg.detour ? sg.detour.text : sg.short + (progressActor ? ' · ' + progressActor.who : '')), item.caption, item.reason,
item.head ? 'head ' + item.head : '',
item.hold ? (item.hold.pill || 'Held by @' + item.hold.by) + (item.hold.reason ? ' · ' + item.hold.reason : '') : ''].filter(Boolean).join(' · ');
const tipID = 'ham-chevron-tip-' + [item.repo || '', item.kind || '', item.number || 0, sg.number].map(x => encodeURIComponent(String(x))).join('-');
const caption = gateWord || word;
const text = decision ? stageTrackerDecisionTriggerHtml(decision, caption, fullTip) : caption;
// Deferred to a running track: the icon alone (a decision trigger
// keeps its button, since the popover lives in the word).
const content = waitingOnTracks && !sg.cap && !decision ? stageTrackerIcon(sg.number, 'ham-ico') : `${gateCue}${workIco}<span class="ham-chevron-copy">${text}</span>${actorIco || holderIco}`;
const content = waitingOnTracks && !sg.cap && !decision ? stageTrackerIcon(sg.number, 'ham-ico') : `${gateCue}${workIco}<span class="ham-chevron-copy">${text}</span>${actorIco || holderIco || progressIco}`;
// A decision's dialog is its sole hover/focus detail surface.
inner = decision ? `<span class="ham-chevron-info ham-chevron-decision">${content}</span>` : `<span class="ham-chevron-info config-info" tabindex="0" title="" aria-label="${esc(fullTip)}" aria-describedby="${esc(tipID)}">${content}<span id="${esc(tipID)}" class="config-tooltip ham-chevron-tip" role="tooltip">${esc(fullTip)}</span></span>`;
} else if (fixPushed) {
Expand Down
34 changes: 34 additions & 0 deletions src/pkg/dashboard/static-src/js/tracker-row.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,40 @@
const src = STAGE_TRACKER_CLAIMANT_SOURCE[c.source] || c.source || '';
return 'Held by: ' + who + since + (src ? ' (' + src + ')' : '');
}
// Who works a lit "PR in progress" chevron (word is the chevron's bare
// word; any other word → null), named the way "Waiting for @x" names
// its person: `{ who: '@login', kind }` with kind one of the
// actor icons (hive / clanker / human). The recorded holder (claimant)
// leads, then the server's stage_actor login, then the PR's author (for
// an issue drawn through its one covering PR, that PR's author). Null
// when nobody is known — a bot author or an unlabelled one — so the
// chevron keeps the bare word; it never guesses a kind from a login.
const STAGE_TRACKER_PR_PROGRESS_WORD = 'PR in progress';
const STAGE_TRACKER_PR_PROGRESS_KINDS = ['hive', 'clanker', 'human'];
function stageTrackerPRProgressActor(item, word) {
if (String(word) !== STAGE_TRACKER_PR_PROGRESS_WORD) return null;
const c = typeof stageTrackerClaimant === 'function' ? stageTrackerClaimant(item) : null;
if (c) {
const who = stageTrackerClaimantShort(c);
return who ? { who, kind: stageTrackerClaimantIconKind(c) } : null;
}
const sa = stageTrackerStageActor(item);
const kindOf = k => k === 'maintainer' ? 'human' : String(k || '');
if (sa && sa.login && STAGE_TRACKER_PR_PROGRESS_KINDS.indexOf(kindOf(sa.kind)) >= 0) return { who: '@' + String(sa.login).replace(/^@/, ''), kind: kindOf(sa.kind) };
// An issue's own author filed the issue; only a PR row, or the one
// covering PR an issue is drawn through, has a PR author to name.
if (!item) return null;
let src = null;
if (item.kind === 'pr' && !item.via_pr) src = item;
else if (item.via_pr && Array.isArray(item.linked_prs)) {
const here = item.linked_prs.filter(lp => lp && (!Number(lp.drawn_under) || Number(lp.drawn_under) === (Number(item.number) || 0)));
if (here.length === 1) src = here[0];
}
const author = String((src && src.author) || '').trim().replace(/^@/, '');
const kind = kindOf(src && src.author_kind);
return author && STAGE_TRACKER_PR_PROGRESS_KINDS.indexOf(kind) >= 0 ? { who: '@' + author, kind } : null;
}

// The Fixing column word when nobody is fixing: a bot-authored PR the
// hive does not touch, or an unowned red PR, reads as its state in
// plain words instead of an active "Fixing" (hivecommons/docs#500).
Expand Down
Loading
Loading