diff --git a/README.md b/README.md index 15d4312..18ea887 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ and filed by a GitHub App. Reporters never need a GitHub account. - **Repo status (optional):** every repository at a glance, like a team status board: open PRs and issues and the oldest open PR, the last commit, issue and PR, what happened in a window you pick (10 minutes to a week, since the last build, or all time: commits, PRs opened and merged, issues, people), and each latest build with its unreleased commits and downloads. Sort by any column; a totals row sums them up. Fix first ranks the open issues across the repositories by what they say (crash, hang, data loss beats "doesn't work"), who filed them, how many people pile on and how fresh they are, with the reasons beside each score. Most reported ranks the issues by how many Discord tickets are about them (a duplicate counts for its original; ones Claude suggested and nobody has reviewed yet are shown as waiting for review), over the last 7, 30 or 90 days or all time, with the tickets one click away, and says when an issue closed as fixed keeps being reported. Pull requests lists the open ones (the ones fixing the most reported issues first, with how many Discord tickets are about them), the merged ones waiting for a release, and the ones merged in the last 90 days; Fix first and Most reported show when someone's working on an issue or it's already fixed. Read in the background every 5 to 60 minutes with GitHub's GraphQL API, which has its own budget, so filing isn't affected. Off until you turn it on; you pick the repositories (your apps' ones to start with). - **Analytics (optional):** downloads recorded every 30 minutes from when you turn it on (GitHub only keeps running totals), per app, platform, processor, format and version, from 30 minutes to 12 months at a time (today in 30-minute steps by default; steps of 30m, 1h, 3h, 6h, 12h or a day), in your own time zone, or All: lifetime totals (GitHub's own download and star counts) with the same breakdowns. The main chart switches between downloads and stars: stars gained over time (the change in GitHub's star count, read every 30 minutes with the downloads from when you turn it on; a star taken back counts -1) and each app's star total. Next to them: tickets, issues opened and closed, pull requests merged and stars over the same time, each compared with the period before, and release health: Discord tickets while each release was the latest, per 1,000 of its downloads. Every chart has a table view. - **AI triage (optional):** Claude flags priority, duplicates, regressions, spam and more, and sorts tickets into your own custom labels. Each action can be off, a suggestion, or automatic above a confidence threshold, with separate settings for issues opened directly on GitHub. - - AI triage › Overview: every label on your open issues at a glance (priority, triage's own labels, each custom label category with how many still have none of its labels, and your team's other labels), each linked to its issues on GitHub, next to what triage did over 7 days to all time: tickets and issues read per day, labels added, duplicates found, details asked for, what it closed, applied and still suggested by action, the priority it gave and how sure it was, what it skipped, what it cost, by app. + - AI triage › Overview: every label on your open issues in one table, grouped by category and searchable (priority, triage's own labels, each custom label category with how many still have none of its labels and a backfill for them, and your team's other labels), each bar out of all open issues and linked to its issues on GitHub, next to what triage did over 7 days to all time: tickets and issues read per day, labels added, duplicates found, details asked for, what it closed, applied and still suggested by action, the priority it gave and how sure it was, what it skipped, what it cost, by app. - AI triage › Custom labels: your own labels in categories (Kind: bug, parity, plugins, backlog; Topic; Platform…), each with a sentence on when to use it. Claude picks from each category for every ticket and never invents a label. Each label shows how many open issues have it. - AI triage › Review lists everything with suggestions waiting, from Discord tickets and GitHub issues. Every ticket shows its triage state (To review, Partly applied, Applied…), and suggestions say exactly what applying them does. - Apply or dismiss in bulk, e.g. all duplicates at 80%+ confidence. diff --git a/src/web/public/app.css b/src/web/public/app.css index c409023..7556dea 100644 --- a/src/web/public/app.css +++ b/src/web/public/app.css @@ -465,6 +465,12 @@ input:disabled, select:disabled, textarea:disabled { opacity: 0.6; cursor: not-a .dot.c4 { background: var(--dot-4); } .dot.c5 { background: var(--dot-5); } .dot.c6 { background: var(--dot-6); } .dot.c7 { background: var(--dot-7); } .dot.r0 { background: var(--role-0); } .dot.r1 { background: var(--role-1); } .dot.r2 { background: var(--role-2); } .dot.r3 { background: var(--role-3); } .dot.r4 { background: var(--role-4); } .dot.r5 { background: var(--role-5); } +/* Bars drawn by meter() in ui.ts, in SVG since the CSP blocks inline widths. */ +.meter { display: block; overflow: hidden; border-radius: var(--r-full); } +.meter-track { fill: var(--surface-2); } +.meter-defs { position: absolute; width: 0; height: 0; overflow: hidden; } +.mh-bg.warn { fill: var(--warn-soft); } .mh-fg.warn { fill: var(--warn); } +.mh-bg.muted { fill: var(--surface-3); } .mh-fg.muted { fill: var(--faint); } .tags { display: flex; flex-wrap: wrap; gap: 4px; } .badge { display: inline-block; min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--r-full); font: 600 11px/18px var(--font); text-align: center; font-variant-numeric: tabular-nums; background: var(--surface-2); color: var(--muted); flex: none; } @@ -2062,8 +2068,9 @@ details[open] > summary .cl-chev { transform: rotate(90deg); } .cl-side { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; } .cl-modes { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; } .cl-cov { display: flex; align-items: center; gap: 8px; font-size: 12px; white-space: nowrap; } -.cl-cover-bar { flex: 0 0 90px; height: 6px; border-radius: var(--r-full); background: var(--surface-3); overflow: hidden; } -.cl-cover-bar i { display: block; height: 100%; border-radius: inherit; background: var(--ok); } +.cl-cover-bar { flex: 0 0 90px; display: block; } +.cl-cover-bar .meter-track { fill: var(--surface-3); } +.cl-cover-fill { fill: var(--ok); } .cl-open .c, details[open] > summary .cl-open .o { display: none; } details[open] > summary .cl-open .c { display: inline; } .cl-body { border-top: 1px solid var(--border); } @@ -2128,13 +2135,14 @@ details[open] > summary .cl-open .c { display: inline; } .bf-totals-h { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; } .bf-totals-h h3 { margin: 0; font-size: 14px; } .bf-key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin: 0 4px 0 10px; vertical-align: -1px; } -.bf-key.sure, .bf-bar .sure { background: var(--ok); } -.bf-key.unsure, .bf-bar .unsure { background: var(--warn-border); } +.bf-key.sure { background: var(--ok); } +.bf-key.unsure { background: var(--warn-border); } +.bf-bar .sure { fill: var(--ok); } +.bf-bar .unsure { fill: var(--warn-border); } .bf-bars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; } .bf-bars li { display: grid; grid-template-columns: minmax(150px, 0.28fr) minmax(0, 1fr) 11em; gap: 12px; align-items: center; } .bf-bar-l { display: flex; align-items: center; gap: 8px; min-width: 0; } -.bf-bar { display: flex; height: 10px; border-radius: var(--r-full); background: var(--surface-2); overflow: hidden; } -.bf-bar i { display: block; height: 100%; } +.bf-bar { display: block; min-width: 0; } .bf-bar-n { font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } th.bf-ticket { width: 34%; } th.bf-had { width: 16%; } @@ -2151,50 +2159,92 @@ th.bf-had { width: 16%; } .ov-kpi:hover { border-color: var(--border-hover); text-decoration: none; } .ov-ch-a { margin-left: auto; } .ov-labels .an-ch { align-items: center; } -.ov-prio { padding: 6px 0 18px; border-bottom: 1px solid var(--border); margin-bottom: 16px; } -.ov-prio-h, .ov-sec-h { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; } -.ov-prio-h h3, .ov-sec-h h3 { margin: 0; font-size: 13px; font-weight: 600; } -.ov-sec-h .btn { margin-left: auto; } -.ov-stack { display: flex; height: 14px; gap: 2px; border-radius: var(--r-full); overflow: hidden; background: var(--surface-2); } -.ov-stack > * { display: block; min-width: 3px; transition: opacity var(--t-fast); } -.ov-stack > a:hover { opacity: 0.8; } -.p-crit { background: var(--danger); } .p-high { background: var(--viz-2); } .p-med { background: var(--viz-1); } .p-low { background: var(--faint); } .p-none { background: var(--surface-3); } -.ov-legend { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 20px; font-size: 12px; } -.ov-legend li { display: inline-flex; align-items: center; gap: 6px; } -.ov-legend i { width: 10px; height: 10px; border-radius: 2px; } -.ov-legend a { color: var(--text); font-family: var(--mono); } -.ov-legend b { font-variant-numeric: tabular-nums; } -.ov-cols { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 20px 28px; } -.ov-sec { min-width: 0; } +.p-crit { background: var(--danger); } .p-high { background: var(--viz-2); } .p-med { background: var(--viz-1); } .p-low { background: var(--faint); } .ov-bars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; } .ov-bar { display: grid; grid-template-columns: minmax(118px, 0.48fr) minmax(40px, 1fr) 6.5em; gap: 10px; align-items: center; padding: 4px 6px; margin: 0 -6px; border-radius: var(--r-xs); color: var(--text); text-decoration: none; } a.ov-bar:hover { background: var(--surface-2); text-decoration: none; } .ov-bar-l { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 13px; overflow: hidden; } .ov-bar-l .tag { flex: none; max-width: 100%; overflow: hidden; text-overflow: ellipsis; } .ov-bars.wide .ov-bar { grid-template-columns: minmax(118px, 0.48fr) minmax(40px, 1fr) 10.5em; } -.ov-bar-t { display: flex; height: 8px; border-radius: var(--r-full); background: var(--surface-2); overflow: hidden; } -.ov-bar-t i { display: block; height: 100%; background: var(--viz-1); border-radius: var(--r-full); } -.ov-bars.two .ov-bar-t i { border-radius: 0; } -.ov-bar-t i.a { background: var(--viz-1); } -.ov-bar-t i.s { background: var(--viz-4); } -.ov-bar-t i.none { background: var(--warn); } -.ov-bar-t i.conf { background: var(--viz-3); } -.ov-bar-t i.skip { background: var(--faint); } -.ov-bar-t i.p-crit { background: var(--danger); } .ov-bar-t i.p-high { background: var(--viz-2); } .ov-bar-t i.p-med { background: var(--viz-1); } .ov-bar-t i.p-low { background: var(--faint); } +.ov-bar-t { display: block; min-width: 0; } +.ov-bar-t .v1, .ov-bar-t .a, .ov-bar-t .p-med { fill: var(--viz-1); } +.ov-bar-t .s { fill: var(--viz-4); } +.ov-bar-t .conf { fill: var(--viz-3); } +.ov-bar-t .skip, .ov-bar-t .p-low { fill: var(--faint); } +.ov-bar-t .p-crit { fill: var(--danger); } .ov-bar-t .p-high { fill: var(--viz-2); } .ov-bar-n { display: inline-flex; align-items: baseline; gap: 6px; font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; } .ov-bar-n .muted { font-size: 11px; } .ov-bar-x { font-size: 11px; color: var(--muted); } -.ov-none-l { font-size: 12px; color: var(--warn-text); font-weight: 500; } .ov-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; } .ov-key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin: 0 4px 0 10px; vertical-align: -1px; } .ov-key.a { background: var(--viz-1); } .ov-key.s { background: var(--viz-4); } .ov-sub { margin: 16px 0 8px; font-size: 13px; font-weight: 600; } .ov-none { margin: 0; } -.ov-grid { grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); } -.ov-empty-cat .empty { padding: 16px 8px; } +.ov-grid { grid-template-columns: repeat(auto-fit, minmax(min(380px, 100%), 1fr)); } + +/* Labels on open issues: one table, a group per category, every bar out of all open issues. */ +.lt-tools { display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; margin-bottom: 12px; } +.lt-tools .search { margin-left: auto; } +.lt-table { border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; margin-bottom: 4px; } +.lt-head, .lt-row { display: grid; grid-template-columns: minmax(0, 18rem) 6.5rem minmax(0, 1fr) 2.75rem; align-items: center; } +.lt-head { height: 34px; font-size: 12px; font-weight: 500; color: var(--muted); } +.lt-head > span:first-child { padding-left: 16px; } +.lt-n { text-align: right; padding-right: 16px; font-variant-numeric: tabular-nums; } +.lt-bar { display: flex; align-items: center; gap: 12px; min-width: 0; padding: 0 16px; } +.lt-track, .lt-scale { position: relative; flex: 1; min-width: 0; } +.lt-track { padding: 6px 0; background: linear-gradient(90deg, var(--border) 1px, transparent 1px) 0 0 / 25% 100% repeat-x; } +.lt-track .meter-track { fill: var(--surface-3); } +.lt-pct { flex: none; width: 3em; text-align: right; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; } +.lt-scale { height: 16px; font-variant-numeric: tabular-nums; } +.lt-scale i { position: absolute; top: 0; font-style: normal; line-height: 16px; transform: translateX(-50%); } +.lt-scale i:first-child { left: 0; transform: none; } +.lt-scale .t25 { left: 25%; } .lt-scale .t50 { left: 50%; } .lt-scale .t75 { left: 75%; } +.lt-scale .t100 { right: 0; transform: none; } +.lt-head .lt-pct { font-size: inherit; color: inherit; } +.lt-group { border-top: 1px solid var(--border); } +.lt-gh { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 6px 12px; flex-wrap: wrap; min-height: 46px; padding: 6px 16px 6px 12px; background: var(--surface-2); } +.lt-gh::-webkit-details-marker { display: none; } +.lt-chev { display: inline-flex; color: var(--muted); transition: transform var(--t-fast); } +.lt-group[open] > .lt-gh .lt-chev { transform: rotate(90deg); } +.lt-gh:hover .lt-chev { color: var(--text); } +.lt-gname { font-size: 13px; font-weight: 600; } +.lt-kind { font-size: 12px; color: var(--muted); } +.lt-cov { display: inline-flex; align-items: center; gap: 8px; margin-left: 4px; font-size: 12px; color: var(--muted); white-space: nowrap; } +.lt-cov b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; } +.lt-cov.low b { color: var(--warn-text); } +.lt-cov-bar { display: block; width: 96px; } +.lt-cov-bar .meter-track { fill: var(--surface-3); } +.lt-cov-fill, .lt-fill { fill: var(--accent); } +.lt-sum { flex: 1 1 200px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: var(--muted); } +.lt-sum b { color: var(--text); font-weight: 500; font-variant-numeric: tabular-nums; } +.lt-group[open] .lt-sum { display: none; } +.lt-act { margin-left: auto; } +.lt-rows { list-style: none; margin: 0; padding: 0; } +.lt-rows > li { border-top: 1px solid var(--border); } +.lt-row { min-height: 36px; color: var(--text); text-decoration: none; } +.lt-row:hover { background: var(--surface-2); text-decoration: none; } +.lt-row.zero { opacity: 0.55; } +.lt-l { display: flex; min-width: 0; padding-left: 40px; } +.lt-l .tag { max-width: 100%; overflow: hidden; text-overflow: ellipsis; } +.lt-row .lt-n { font-size: 13px; font-weight: 600; } +.lt-nolabel { font-size: 13px; font-weight: 500; color: var(--muted); } +.lt-nolabel.warn { color: var(--warn-text); } +.lt-go { justify-self: center; display: inline-flex; color: var(--faint); } +.lt-row:hover .lt-go { color: var(--text); } +.lt-nil { margin: 0; padding: 12px 16px 12px 40px; font-size: 13px; color: var(--muted); border-top: 1px solid var(--border); } +.lt-nomatch { padding-left: 16px; } +.lt-empty { border-top: 1px solid var(--border); } +.lt-empty .empty { padding: 16px 8px; } @media (max-width: 720px) { - .ov-cols { grid-template-columns: minmax(0, 1fr); } .ov-ch-a { margin-left: 0; } + .lt-tools .search { margin-left: 0; width: 100%; } + .lt-head { display: none; } + .lt-row { grid-template-columns: minmax(0, 1fr) auto; row-gap: 6px; padding: 8px 0; } + .lt-l { padding-left: 16px; } + .lt-row .lt-bar { grid-column: 1 / -1; padding-left: 16px; } + .lt-go { display: none; } + .lt-cov { margin-left: 0; } + .lt-act { margin-left: 0; } } /* Re-run: what a run will cost, by Start; and on a running one, what it cost so far. */ diff --git a/src/web/public/app.js b/src/web/public/app.js index 0ad9a7b..be0dd71 100644 --- a/src/web/public/app.js +++ b/src/web/public/app.js @@ -426,6 +426,53 @@ if (clear) clear.addEventListener('click', function (e) { e.preventDefault(); input.value = ''; run(); input.focus(); }); run(); }); + + // AI triage › Overview: the labels table shows one category, or the labels a search finds. The + // groups that show open; clearing it puts each group back as it was. + $$('[data-lt]').forEach(function (table) { + var tools = $('[data-lt-tools]', table); + var find = $('[data-lt-find]', table); + var nothing = $('[data-lt-none]', table); + var groups = $$('[data-lt-group]', table); + var buttons = $$('[data-lt-show]', table); + if (!tools || !find) return; + tools.hidden = false; + var show = 'all'; + var saved = null; + function run() { + var q = find.value.trim().toLowerCase(); + var filtered = Boolean(q) || show !== 'all'; + if (filtered && !saved) saved = groups.map(function (g) { return g.open; }); + var any = false; + groups.forEach(function (g) { + var hits = 0; + $$('.lt-rows > li', g).forEach(function (li) { + var name = li.getAttribute('data-lt-name'); + var hit = !q || (name !== null && name.indexOf(q) !== -1); + li.hidden = !hit; + if (hit) hits++; + }); + var on = (show === 'all' || g.getAttribute('data-lt-group') === show) && (!q || hits > 0); + g.hidden = !on; + if (on) any = true; + if (on && filtered) g.open = true; + }); + if (!filtered && saved) { + groups.forEach(function (g, i) { g.open = saved[i]; }); + saved = null; + } + $$('[data-lt-extra]', table).forEach(function (el) { el.hidden = filtered; }); + if (nothing) nothing.hidden = any; + } + buttons.forEach(function (b) { + b.addEventListener('click', function () { + show = b.getAttribute('data-lt-show'); + buttons.forEach(function (x) { x.setAttribute('aria-pressed', x === b ? 'true' : 'false'); }); + run(); + }); + }); + find.addEventListener('input', run); + }); $$('[data-toggle-filters]').forEach(function (b) { b.addEventListener('click', function () { var target = document.getElementById(b.getAttribute('data-toggle-filters')); diff --git a/src/web/routes/triage-config.ts b/src/web/routes/triage-config.ts index 6339d86..e14a08f 100644 --- a/src/web/routes/triage-config.ts +++ b/src/web/routes/triage-config.ts @@ -31,7 +31,7 @@ import { } from '../../triage/settings.js'; import { setFlash } from '../session.js'; import type { Web, WorkspaceRequestContext } from '../server.js'; -import { csrfField, empty, icon, iconBtn, labelTag, linkBtn, menu, notice, pageHeader, pill, postBtn, segRadios, selectWrap, submitBtn, timeAgo, type Tone } from '../ui.js'; +import { csrfField, empty, icon, iconBtn, labelTag, linkBtn, menu, meter, notice, pageHeader, pill, postBtn, segRadios, selectWrap, submitBtn, timeAgo, type Tone } from '../ui.js'; import { openLabels, openMissing } from '../../triage/label-stats.js'; import { textField } from './panel.js'; import { areaHref, canOpen, knowledgeHref, pageLink, toolHeader, toolHref } from './tool.js'; @@ -146,7 +146,7 @@ export function registerTriageConfigRoutes(app: FastifyInstance, web: Web): void ${pill(`Discord: ${MODE_NAMES[g.mode]}`, MODE_TONE[g.mode])}${pill(`GitHub: ${MODE_NAMES[ghMode]}`, MODE_TONE[ghMode])} - ${open.open ? html`${String(done)}% labelled${none ? html` · ${n(none)} have none` : ''}` : ''} + ${open.open ? html`${meter([{ pct: done, cls: 'cl-cover-fill' }])}${String(done)}% labelled${none ? html` · ${n(none)} have none` : ''}` : ''} diff --git a/src/web/routes/triage-overview.ts b/src/web/routes/triage-overview.ts index b6a3ce8..bcc86da 100644 --- a/src/web/routes/triage-overview.ts +++ b/src/web/routes/triage-overview.ts @@ -12,9 +12,9 @@ import { listApps } from '../../domain/store.js'; import { html, raw, type SafeHtml } from '../../lib/html.js'; import { openLabels, openMissing, type OpenLabels } from '../../triage/label-stats.js'; import { triageOverview, type TriageOverview } from '../../triage/overview.js'; -import { FLAGS, getTriageSettings, groupKind, PRIORITIES, tokenCost, type LabelGroup, type TriageConfig } from '../../triage/settings.js'; +import { FLAGS, getTriageSettings, groupKind, PRIORITIES, tokenCost, type TriageConfig } from '../../triage/settings.js'; import type { Web, WorkspaceRequestContext } from '../server.js'; -import { empty, labelTag, linkBtn, notice, segLinks, selectWrap } from '../ui.js'; +import { empty, icon, labelTag, linkBtn, meter, meterDefs, notice, plural, segLinks, selectWrap } from '../ui.js'; import { compact, delta, type Better } from './analytics.js'; import { areaHref, canOpen, toolHeader } from './tool.js'; import { FLAG_COPY } from './triage.js'; @@ -47,7 +47,7 @@ function bars(items: Bar[], o: { of: number; empty: string; max?: number }): Saf const most = Math.max(1, ...shown.map((b) => b.n)); return html``; @@ -165,51 +165,85 @@ export function registerTriageOverviewRoutes(app: FastifyInstance, web: Web): vo `; } + /** + * Every label on the open issues as one table, a group per category (priority, each custom + * category, triage's own, the rest), each bar out of all open issues. app.js adds the category + * filter and the label search. + */ function labelsCard(ctx: WorkspaceRequestContext, c: TriageConfig, l: OpenLabels, missing: Map, o: { search: (terms: string) => string; runs: string | null; app: string | null }): SafeHtml { const has = (name: string) => l.byLabel.get(name.toLowerCase()) ?? 0; const gh = (name: string) => o.search(`label:"${name}"`); - const prio = PRIORITIES.map((p) => ({ p, name: c.priority.labels[p], n: has(c.priority.labels[p]) })); + const without = (names: string[]) => o.search(names.map((x) => `-label:"${x}"`).join(' ')); + const prio = PRIORITIES.map((p) => ({ name: c.priority.labels[p], n: has(c.priority.labels[p]) })); const prioritized = prio.reduce((t, x) => t + x.n, 0); - const noPriority = Math.max(0, l.open - prioritized); - const flagLabels = [...new Map(FLAGS.filter((f) => c[f].label.trim()).map((f) => [c[f].label.toLowerCase(), { name: c[f].label, title: FLAG_COPY[f].title }])).values()]; - const known = new Set([...prio.map((x) => x.name.toLowerCase()), ...flagLabels.map((x) => x.name.toLowerCase()), ...c.labelGroups.flatMap((g) => g.options.map((x) => x.label.toLowerCase()))]); + const flagLabels = [...new Map(FLAGS.filter((f) => c[f].label.trim()).map((f) => [c[f].label.toLowerCase(), c[f].label])).values()]; + const known = new Set([...prio.map((x) => x.name.toLowerCase()), ...flagLabels.map((x) => x.toLowerCase()), ...c.labelGroups.flatMap((g) => g.options.map((x) => x.label.toLowerCase()))]); const others = [...l.byLabel].filter(([k]) => !known.has(k)).sort((a, b) => b[1] - a[1]).map(([k, v]) => ({ name: l.names.get(k) ?? k, n: v })); - const backfill = (g: LabelGroup) => (o.runs ? `${o.runs}?what=labels&group=${encodeURIComponent(g.id)}` : null); - const category = (g: LabelGroup) => { - const none = missing.get(g.id) ?? 0; - const link = backfill(g); - return html`
-

${g.name}

custom labels${link && none ? linkBtn(link, `Backfill ${n(none)}`, { size: 'sm', variant: 'ghost', icon: 'history', title: `Add ${g.name} labels to the open tickets and issues that have none` }) : ''}
- ${bars([ - ...g.options.map((x) => ({ label: labelTag(x.label), n: has(x.label), href: gh(x.label) })).sort((a, b) => b.n - a.n), - { label: html`None yet`, n: none, href: o.search(g.options.map((x) => `-label:"${x.label}"`).join(' ')), tone: 'none' }, - ], { of: l.open, empty: 'No labels in this category.' })} -
`; + const byCount = (a: { n: number }, b: { n: number }) => b.n - a.n; + + interface Row { name: string; n: number; href: string; none?: 'warn' | 'muted' } + interface Group { key: string; name: string; short?: string; kind: string; open: boolean; rows: Row[]; empty: string; cover?: { labelled: number; word: string; hatch: 'warn' | 'muted' }; backfill?: { href: string; none: number; name: string } | null } + const groups: Group[] = [ + { + key: 'priority', name: 'Priority', kind: 'set by triage', open: true, empty: '', + cover: { labelled: prioritized, word: 'have one', hatch: 'muted' }, + rows: [...prio.map((x) => ({ ...x, href: gh(x.name) })), { name: 'No priority', n: Math.max(0, l.open - prioritized), href: without(prio.map((x) => x.name)), none: 'muted' }], + }, + ...c.labelGroups.map((g): Group => { + const none = missing.get(g.id) ?? 0; + const runs = o.runs ? `${o.runs}?what=labels&group=${encodeURIComponent(g.id)}` : null; + return { + key: `g-${g.id}`, name: g.name, kind: 'custom labels', open: true, empty: 'No labels in this category.', + cover: { labelled: Math.max(0, l.open - none), word: 'labelled', hatch: 'warn' }, + backfill: runs && none ? { href: runs, none, name: g.name } : null, + rows: [...g.options.map((x) => ({ name: x.label, n: has(x.label), href: gh(x.label) })).sort(byCount), { name: 'None yet', n: none, href: without(g.options.map((x) => x.label)), none: 'warn' }], + }; + }), + { key: 'triage', name: 'From triage', kind: 'its own labels', open: false, empty: 'Triage adds no labels of its own.', rows: flagLabels.map((x) => ({ name: x, n: has(x), href: gh(x) })).sort(byCount) }, + { key: 'other', name: 'Your other labels', short: 'Other', kind: 'added by people or ticket types', open: false, empty: 'None.', rows: others.slice(0, 50).map((x) => ({ ...x, href: gh(x.name) })) }, + ]; + + const share = (x: number) => (x ? Math.max(0.6, (x / l.open) * 100) : 0); + const row = (r: Row) => html`
  • + + ${r.none ? html`${r.name}` : labelTag(r.name)} + ${n(r.n)} + ${meter([r.none ? { pct: share(r.n), hatch: r.none } : { pct: share(r.n), cls: 'lt-fill' }])}${pct(r.n, l.open)} + ${icon('arrow-up-right', 14)} + +
  • `; + const group = (g: Group) => { + const labels = g.rows.filter((r) => !r.none); + const top = [...labels].sort(byCount).slice(0, 3); + const cover = g.cover; + const done = cover && l.open ? (cover.labelled / l.open) * 100 : 0; + return html`
    + + + ${g.name} + ${g.kind} + ${cover ? html`${meter([{ pct: done, cls: 'lt-cov-fill' }, { pct: 100 - done, hatch: cover.hatch }])}${pct(cover.labelled, l.open)} ${cover.word}` : ''} + ${labels.length ? html`${plural(labels.length, 'label')}${top.map((t) => html` · ${t.name} ${n(t.n)}`)}${labels.length > 3 ? ` · +${String(labels.length - 3)} more` : ''}` : ''} + ${g.backfill ? html`${linkBtn(g.backfill.href, `Backfill ${n(g.backfill.none)}`, { size: 'sm', variant: 'secondary', icon: 'history', title: `Add ${g.backfill.name} labels to the open tickets and issues that have none` })}` : ''} + + ${g.rows.length ? html`` : html`

    ${g.empty}

    `} +
    `; }; + const noCustom = c.labelGroups.length ? '' : html`
    ${empty('tags', 'No custom labels yet', html`Sort every ticket into your own labels, such as bug, parity or plugins.`, canOpen(ctx.membership, 'triage.labels') ? linkBtn(areaHref(ctx, 'triage.labels'), 'Add custom labels', { size: 'sm', trail: 'arrow-right' }) : null)}
    `; + return html`

    Labels on open issues

    ${n(l.open)} open issues · as on GitHub now · click a label to see its issues ${canOpen(ctx.membership, 'triage.labels') ? html`${linkBtn(areaHref(ctx, 'triage.labels'), 'Custom labels', { size: 'sm', variant: 'ghost', trail: 'arrow-right' })}` : ''}
    - ${l.open ? html` -
    -

    Priority

    ${pct(prioritized, l.open)} of open issues have one
    -
    `; } @@ -222,7 +256,7 @@ export function registerTriageOverviewRoutes(app: FastifyInstance, web: Web): vo ${rows.length ? html`` : html`

    Nothing in this period.

    `} diff --git a/src/web/routes/triage-runs.ts b/src/web/routes/triage-runs.ts index 263db12..c71e140 100644 --- a/src/web/routes/triage-runs.ts +++ b/src/web/routes/triage-runs.ts @@ -53,6 +53,7 @@ import { labelTag, linkBtn, menu, + meter, notice, pageHeader, pill, @@ -675,7 +676,7 @@ export function registerTriageRunRoutes(app: FastifyInstance, web: Web): void { ${totals.length ? html`` : html`

    ${counts.pending ? 'Labels show up here as Claude reads each ticket.' : 'Claude found no labels to add.'}

    `} diff --git a/src/web/ui.ts b/src/web/ui.ts index eb21e88..5c031a9 100644 --- a/src/web/ui.ts +++ b/src/web/ui.ts @@ -254,6 +254,29 @@ export function labelTag(name: string): SafeHtml { return html`${name}`; } +/** + * A bar in parts, each a share (0–100) of its length, coloured by its class in app.css. Drawn in SVG: + * the CSP blocks inline widths. A `hatch` part is striped instead, with `meterDefs()` once on the page. + */ +export function meter(parts: { pct: number; cls?: string; hatch?: 'warn' | 'muted' }[], o: { h?: number; title?: string } = {}): SafeHtml { + const h = o.h ?? 6; + const round = parts.length === 1 ? raw(` rx="${String(h / 2)}"`) : ''; + let x = 0; + const rects = parts.map((p) => { + const at = x; + const w = Math.max(0, Math.min(100 - at, p.pct)); + x += w; + return w ? html`` : ''; + }); + return html`${rects}`; +} + +/** The stripes of `hatch` meter parts. */ +export function meterDefs(): SafeHtml { + const stripes = (id: string) => ``; + return raw(``); +} + /** A Discord role chip; `index` picks a stable color from the role palette. */ export function roleTag(name: string, index: number): SafeHtml { return html`@${name}`; diff --git a/test/custom-labels.test.ts b/test/custom-labels.test.ts index 136f32e..92d49e7 100644 --- a/test/custom-labels.test.ts +++ b/test/custom-labels.test.ts @@ -239,9 +239,12 @@ describe('AI triage › Overview', () => { expect(res.body).toContain('Labels on open issues'); expect(res.body).toContain('3 open issues'); // Priority, the custom categories with what still has none, and a backfill for them. - expect(res.body).toMatch(/medium<\/a>3<\/b>/); - expect(res.body).toContain('

    Kind

    '); - expect(res.body).toContain('None yet'); + expect(res.body).toMatch(/medium: 3 open issues, 100%/); + expect(res.body).toContain('data-lt-group="g-kind1" open'); + expect(res.body).toContain('Kind'); + expect(res.body).toContain('None yet'); + // Bars are SVG: the CSP blocks inline styles, which drew them empty. + expect(res.body).not.toContain('style="'); expect(res.body).toContain('/triage/runs?what=labels&group=kind1'); expect(res.body).toContain(encodeURIComponent('label:"parity"')); expect(res.body).toContain('What triage did');