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
1 change: 1 addition & 0 deletions changed-gate-fold-tap-target.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Activity Monitor: the human-gate pill folds its verbs at render time (three on the strip tier, one plus `…` at ≀1100px), keeps the folded verbs in a template until `…` opens, and gives the `…` button its 44px tap target β€” the row holds no hidden buttons for the header-geometry probe to reject.
1 change: 1 addition & 0 deletions changelog.d/fixed-17515.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- dashboard: fold the human-gate verbs at render time; keeps its 44px tap target (#17515)
10 changes: 6 additions & 4 deletions src/pkg/dashboard/stage_tracker_human_gate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ func stageTrackerHumanGateJS(t *testing.T, html string) string {
jsConstLine(t, html, "STAGE_TRACKER_GATE_WORD"),
jsConstLine(t, html, "STAGE_TRACKER_GATE_SETTLING"),
jsConstLine(t, html, "STAGE_TRACKER_GATE_VISIBLE"),
jsConstLine(t, html, "STAGE_TRACKER_GATE_FOLD_QUERY"),
jsConstBlock(t, html, "STAGE_TRACKER_GATE_VERBS"),
jsConstLine(t, html, "STAGE_TRACKER_GATE_ORDER"),
jsConstLine(t, html, "STAGE_TRACKER_GATE_PR_ONLY"),
Expand All @@ -28,6 +29,7 @@ func stageTrackerHumanGateJS(t *testing.T, html string) string {
jsFunc(t, html, "stageTrackerHumanGateTip"),
jsFunc(t, html, "stageTrackerHumanGateVerbState"),
jsFunc(t, html, "stageTrackerHumanGateVerbHtml"),
jsFunc(t, html, "stageTrackerHumanGateVisible"),
jsFunc(t, html, "stageTrackerHumanGateHtml"),
}, "\n")
}
Expand Down Expand Up @@ -130,8 +132,8 @@ assert.strictEqual(reasons(row), 'review sentinel', 'review verdict + sentinel a
assert.strictEqual(gateWord(row), 'Needs human Β· review, sentinel');
assert.ok(gateTip(row).includes(question.replace(/\?/g, '?')) && gateTip(row).includes('touches .github/workflows'), 'the status hover is the question and the rule: ' + gateTip(row));
assert.deepStrictEqual(verbs(row), ['Approve', 'Request changes…', 'Let hive decide', 'Confirm safe'], 'union of the review and sentinel verb sets, de-duplicated');
assert.ok(row.includes('data-ham-gate-overflow="1"') && /<div class="ham-menu ham-gate-menu"[^>]*>[\s\S]*?Confirm safe/.test(row), 'the fourth verb folds into the … menu: ' + row);
assert.ok(!/data-ham-gate-inline[^>]*>Confirm safe/.test(row) && /data-ham-gate-inline[^>]*>Let hive decide/.test(row), 'menu copies of inline verbs are marked for the phone tier');
assert.ok(row.includes('data-ham-gate-more') && /<template class="ham-gate-menu-tpl"><div class="ham-menu ham-gate-menu"[^>]*>[\s\S]*?Confirm safe/.test(row), 'the fourth verb waits in the … menu template: ' + row);
assert.ok(!/ham-gate-menu-tpl[\s\S]*Let hive decide/.test(row), 'the menu holds only the folded verbs, not copies of the inline ones');
assert.ok(!row.includes('ham-badge-sentinel') && !row.includes('ham-mod-needs-decision') && !row.includes('ham-lead-pill'), 'no sentinel chip, needs-decision pill or loose lead buttons beside the gate: ' + row);
assert.ok(row.includes('<p class="ham-current-stage">') && row.includes('Needs human decision'), 'the expander line still names the decision');

Expand Down Expand Up @@ -170,8 +172,8 @@ assert.strictEqual(gates(row), 1, row);
assert.strictEqual(reasons(row), 'decision');
assert.deepStrictEqual(verbs(row), ['Decide…', 'Approve as-is', 'Let hive decide']);
assert.ok(gateTip(row).includes('Two fixes are possible'), gateTip(row));
assert.ok(row.includes('data-ham-gate-overflow="0"'), 'three verbs need no overflow on the strip tier (the … is the phone tier\'s fold)');
assert.strictEqual((row.match(/ham-gate-act-rest/g) || []).length, 2, 'the verbs after the first fold on the phone tier');
assert.ok(!row.includes('data-ham-gate-more'), 'three verbs need no … on the strip tier');
assert.strictEqual((row.match(/class="ham-lead-act ham-gate-act[^"]*"/g) || []).length, 3, 'all three verbs are inline');
assert.deepStrictEqual(segStates(row), [D, D, D, D, D, 'active detoured ham-human-gated', 'todo cap'], strip(row));
assert.ok(row.includes('<span class="ham-detour">Merge queue</span>'), 'the chevron reads its column: ' + strip(row));

Expand Down
25 changes: 8 additions & 17 deletions src/pkg/dashboard/static-src/css/tracker.css
Original file line number Diff line number Diff line change
Expand Up @@ -987,18 +987,15 @@
.ham-human-gate > .ham-gate-status > .ham-mod-word { overflow: hidden; text-overflow: ellipsis; }
.ham-human-gate > button.ham-gate-status { cursor: pointer; }
.ham-human-gate > button.ham-gate-status:hover, .ham-human-gate > button.ham-gate-status:focus-visible { text-decoration: underline; outline: none; }
.ham-human-gate > .ham-gate-act { --ham-gate-seg-radius: 0; border-radius: var(--ham-gate-seg-radius); border-top: 0; border-bottom: 0; border-right: 0; border-left-color: color-mix(in srgb, var(--amber) 35%, transparent); margin: 0; }
.ham-human-gate > .ham-gate-act.ham-act-secondary, .ham-human-gate > .ham-gate-more { --ham-act-fill: transparent; --ham-act-ink: var(--text); }
.ham-human-gate > .ham-gate-act:hover, .ham-human-gate > .ham-gate-act:focus-visible { box-shadow: none; background: color-mix(in srgb, var(--amber) 22%, transparent); filter: none; }
.ham-human-gate > .ham-gate-act, .ham-human-gate .ham-gate-more { --ham-gate-seg-radius: 0; border-radius: var(--ham-gate-seg-radius); border-top: 0; border-bottom: 0; border-right: 0; border-left-color: color-mix(in srgb, var(--amber) 35%, transparent); margin: 0; }
.ham-human-gate > .ham-gate-act.ham-act-secondary, .ham-human-gate .ham-gate-more { --ham-act-fill: transparent; --ham-act-ink: var(--text); }
.ham-human-gate > .ham-gate-act:hover, .ham-human-gate > .ham-gate-act:focus-visible, .ham-human-gate .ham-gate-more:hover, .ham-human-gate .ham-gate-more:focus-visible { box-shadow: none; background: color-mix(in srgb, var(--amber) 22%, transparent); filter: none; }
.ham-human-gate > .ham-gate-act.ham-act-primary:hover, .ham-human-gate > .ham-gate-act.ham-act-primary:focus-visible { filter: brightness(1.12); }
.ham-human-gate > .ham-gate-more { padding-inline: var(--sp-2); }
.ham-human-gate > .ham-gate-more::after { content: none; }
.ham-human-gate > .ham-gate-more[aria-expanded="true"] { background: color-mix(in srgb, var(--amber) 22%, transparent); }
.ham-human-gate .ham-gate-more { padding-inline: var(--sp-2); }
.ham-human-gate .ham-gate-more::after { content: none; }
.ham-human-gate .ham-gate-more[aria-expanded="true"] { background: color-mix(in srgb, var(--amber) 22%, transparent); }
.ham-human-gate.ham-gate-settling { opacity: 0.75; border-style: dashed; }
.ham-human-gate.ham-gate-settling > .ham-gate-status { color: var(--cue-work); }
/* Strip tier: the … button only when a verb overflows; menu copies of
the inline verbs stay hidden. The phone tier flips both. */
.ham-gate-more-wrap[data-ham-gate-overflow="0"], .ham-gate-menu > [data-ham-gate-inline] { display: none; }
.ham-gate-menu[hidden] { display: none; }
/* The passive "decision pending on #N" chip is a link to the primary row. */
.ham-decision-pending[data-ham-scroll-to] { text-decoration: underline dotted; text-underline-offset: var(--sp-1); }
Expand Down Expand Up @@ -1031,11 +1028,6 @@
.ham-head-cols .ham-badges > .ham-badge-mod.ham-mod-ask > .ham-mod-ico { margin-right: 0; }
.ham-head-cols .ham-human-gate > .ham-gate-status > .ham-mod-word { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.ham-head-cols .ham-human-gate > .ham-gate-status { position: relative; padding-right: var(--sp-2); }
/* Stacked head: the first verb inline, the rest behind …, so the pill
leaves the title its line and no verb is squeezed into a fragment. */
.ham-head-cols .ham-human-gate > .ham-gate-act-rest { display: none; }
.ham-head-cols .ham-human-gate .ham-gate-more-wrap[data-ham-gate-overflow="0"] { display: inline; }
.ham-head-cols .ham-human-gate .ham-gate-menu > [data-ham-gate-inline] { display: flex; }
.ham-row .ham-seg { padding: 0 var(--sp-2) 0 var(--sp-3); }
.ham-row .ham-seg.cap { flex-basis: 2em; }
.ham-since { width: 3em; }
Expand Down Expand Up @@ -1271,10 +1263,9 @@
/* Gate segments keep the one-line pill; each segment pads its hit area
out to the tap target so the phone harness sees β‰₯44Γ—44. */
#activity-monitor-section .ham-human-gate { display: inline-flex; line-height: inherit; vertical-align: baseline; }
#activity-monitor-section .ham-human-gate > .ham-gate-act, #activity-monitor-section .ham-human-gate > .ham-gate-more, #activity-monitor-section .ham-human-gate > button.ham-gate-status { position: relative; display: inline-flex; min-width: var(--tap-target); min-height: 0; height: auto; padding-block: 0; line-height: inherit; }
#activity-monitor-section .ham-human-gate > .ham-gate-act-rest { display: none; }
#activity-monitor-section .ham-human-gate > .ham-gate-act, #activity-monitor-section .ham-human-gate .ham-gate-more, #activity-monitor-section .ham-human-gate > button.ham-gate-status { position: relative; display: inline-flex; min-width: var(--tap-target); min-height: 0; height: auto; padding-block: 0; line-height: inherit; }

#activity-monitor-section .ham-human-gate > .ham-gate-act::before, #activity-monitor-section .ham-human-gate > .ham-gate-more::before, #activity-monitor-section .ham-human-gate > button.ham-gate-status::before { content: ""; position: absolute; inset: calc((1lh - var(--tap-target)) / 2) 0; }
#activity-monitor-section .ham-human-gate > .ham-gate-act::before, #activity-monitor-section .ham-human-gate .ham-gate-more::before, #activity-monitor-section .ham-human-gate > button.ham-gate-status::before { content: ""; position: absolute; inset: calc((1lh - var(--tap-target)) / 2) 0; }
#activity-monitor-section .ham-badge-mod.ham-decision-trigger::before { content: ""; position: absolute; inset: calc((1lh - var(--tap-target)) / 2) calc((100% - var(--tap-target)) / 2); }
/* A card keeps its two-line head and its density (#17161): the πŸ—’
shows on a phone only once the item has notes; the row's β‹― menu
Expand Down
42 changes: 25 additions & 17 deletions src/pkg/dashboard/static-src/js/tracker-human-gate.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
const STAGE_TRACKER_GATE_WORD = 'Needs human';
const STAGE_TRACKER_GATE_SETTLING = 'settling…';
const STAGE_TRACKER_GATE_VISIBLE = 3;
const STAGE_TRACKER_GATE_FOLD_QUERY = '(max-width: 1100px)';
// Reason β†’ verbs, in the order they stand on the pill. The same reason
// always offers the same verbs (the maintainer's "consistent way").
const STAGE_TRACKER_GATE_VERBS = {
Expand Down Expand Up @@ -134,16 +135,23 @@
if (lead) return { enabled: lead.enabled !== false, why: lead.enabled === false ? String(lead.why || '') : '' };
return typeof stageTrackerActionAllowed === 'function' ? stageTrackerActionAllowed(id, ctx) : { enabled: true, why: '' };
}
// more: a menu item. inline: this menu item doubles a verb that is also
// drawn inline on the strip tier (the phone tier hides the inline copy
// and shows this one). rest: an inline verb after the first (the phone
// tier folds it into the … menu).
function stageTrackerHumanGateVerbHtml(item, v, state, more, inline, rest) {
function stageTrackerHumanGateVerbHtml(item, v, state, more) {
const ref = typeof stageTrackerRefOf === 'function' ? stageTrackerRefOf(item) : '';
const tip = state.enabled ? v.posts : state.why;
const attrs = `data-ham-act="${esc(v.id)}"${state.enabled ? '' : ' aria-disabled="true"'}${tip ? ` title="${esc(tip)}"` : ''} aria-label="${esc(v.label + (ref ? ' β€” ' + ref : ''))}"`;
if (more) return `<button type="button" role="menuitem" class="ham-menu-item ham-lead-act ham-gate-act" ${attrs} tabindex="-1"${inline ? ' data-ham-gate-inline' : ''}>${esc(v.label)}</button>`;
return `<button type="button" class="ham-lead-act ham-gate-act${rest ? ' ham-gate-act-rest' : ''}" ${attrs}>${esc(v.label)}</button>`;
if (more) return `<button type="button" role="menuitem" class="ham-menu-item ham-lead-act ham-gate-act" ${attrs} tabindex="-1">${esc(v.label)}</button>`;
return `<button type="button" class="ham-lead-act ham-gate-act" ${attrs}>${esc(v.label)}</button>`;
}
// How many verbs ride inline: three on the strip tier; one on the
// stacked head (≀ 1100px, which includes the phone card) so the pill
// stays one line and leaves the title its room β€” the rest fold behind
// the … menu. Rows re-render when the viewport crosses the breakpoint.
function stageTrackerHumanGateVisible() {
return typeof window !== 'undefined' && typeof window.matchMedia === 'function' && window.matchMedia(STAGE_TRACKER_GATE_FOLD_QUERY).matches ? 1 : STAGE_TRACKER_GATE_VISIBLE;
}
if (typeof window !== 'undefined' && typeof window.matchMedia === 'function') {
const mq = window.matchMedia(STAGE_TRACKER_GATE_FOLD_QUERY);
if (mq && typeof mq.addEventListener === 'function') mq.addEventListener('change', () => { if (typeof renderStageTracker === 'function') renderStageTracker(); });
}
// Pure: the pill. '' when the row has no gate. The status segment is
// the decision popover's trigger when the row carries a decision, else
Expand Down Expand Up @@ -183,15 +191,14 @@
const status = decision && typeof stageTrackerDecisionTriggerHtml === 'function'
? stageTrackerDecisionTriggerHtml(decision, inner, tip, 'ham-gate-status ham-mod-ask')
: `<span class="ham-gate-status ham-mod-ask" title="${esc(tip)}" aria-label="${esc(text + ' β€” ' + tip)}">${inner}</span>`;
const shownVerbs = verbs.slice(0, STAGE_TRACKER_GATE_VISIBLE);
const moreVerbs = verbs.slice(STAGE_TRACKER_GATE_VISIBLE);
const acts = shownVerbs.map((v, i) => stageTrackerHumanGateVerbHtml(item, v, stageTrackerHumanGateVerbState(v.id, shown, ctx, leads), false, false, i > 0)).join('');
// The … menu holds every verb after the first: on the strip tier CSS
// shows only the ones past STAGE_TRACKER_GATE_VISIBLE (and hides the
// button when there are none); the phone tier shows the first verb
// inline and the rest here, so the pill stays one line (#17161).
const menuVerbs = verbs.slice(1);
const more = menuVerbs.length ? `<span class="ham-gate-more-wrap" data-ham-gate-overflow="${moreVerbs.length}"><button type="button" class="ham-lead-act ham-gate-act ham-gate-more" data-ham-gate-more aria-haspopup="menu" aria-expanded="false" aria-label="More ways to settle this gate" title="${esc(menuVerbs.map(v => v.label).join(' Β· '))}">…</button><div class="ham-menu ham-gate-menu" role="menu" aria-label="More ways to settle this gate" hidden>${menuVerbs.map((v, i) => stageTrackerHumanGateVerbHtml(item, v, stageTrackerHumanGateVerbState(v.id, shown, ctx, leads), true, i + 1 < STAGE_TRACKER_GATE_VISIBLE)).join('')}</div></span>` : '';
const visibleCount = stageTrackerHumanGateVisible();
const shownVerbs = verbs.slice(0, visibleCount);
const moreVerbs = verbs.slice(visibleCount);
const acts = shownVerbs.map(v => stageTrackerHumanGateVerbHtml(item, v, stageTrackerHumanGateVerbState(v.id, shown, ctx, leads), false)).join('');
// The menu's items wait in a <template> (no hidden buttons in the row;
// the header-geometry harness hit-tests every button it finds) and are
// stamped into the wrap the first time the … opens.
const more = moreVerbs.length ? `<span class="ham-gate-more-wrap"><button type="button" class="ham-lead-act ham-gate-act ham-gate-more" data-ham-gate-more aria-haspopup="menu" aria-expanded="false" aria-label="More ways to settle this gate" title="${esc(moreVerbs.map(v => v.label).join(' Β· '))}">…</button><template class="ham-gate-menu-tpl"><div class="ham-menu ham-gate-menu" role="menu" aria-label="More ways to settle this gate" hidden>${moreVerbs.map(v => stageTrackerHumanGateVerbHtml(item, v, stageTrackerHumanGateVerbState(v.id, shown, ctx, leads), true)).join('')}</div></template></span>` : '';
const key = typeof stageTrackerItemKey === 'function' ? stageTrackerItemKey(item) : '';
return `<span class="ham-human-gate" data-ham-gate="${esc(key)}" data-ham-gate-reasons="${esc(reasons.map(r => r.key).join(' '))}" role="group" aria-label="${esc(text)}">${status}${acts}${more}</span>`;
}
Expand All @@ -215,7 +222,8 @@
const b = e.target.closest ? e.target.closest('[data-ham-gate-more]') : null;
if (!b) { if (!(e.target.closest && e.target.closest('.ham-gate-menu'))) closeAll(); return; }
e.preventDefault(); e.stopPropagation();
const menu = b.nextElementSibling;
let menu = b.nextElementSibling;
if (menu && menu.tagName === 'TEMPLATE') { const stamped = menu.content.firstElementChild.cloneNode(true); menu.replaceWith(stamped); menu = stamped; }
const open = menu && menu.hidden;
closeAll();
if (menu && open) { menu.hidden = false; b.setAttribute('aria-expanded', 'true'); const first = menu.querySelector('[role="menuitem"]'); if (first) first.focus(); }
Expand Down
Loading
Loading