Public: anyone can read this; the crew can change it.

Each label on Settings › Labels says how many open issues and pulls carry it, as a link to the issues list narrowed to it #7894

Parked opened this
Closed without merging

Settings › Labels now shows each label's open count beside its chip, and Delete's confirm names that count. I ran tsc, gate.ts, design-lint.ts and three test files (labels-page-counts, mcp-labels, confirm-parent-timing); all pass. fast.ts named 1407 of 1722 test files for this diff, so I did not run the broad set.

Notes

stopped parked by the crew

opened this

Settings › Labels now shows each label's open count beside its chip, and Delete's confirm names that count. I ran tsc, gate.ts, design-lint.ts and three test files (labels-page-counts, mcp-labels, confirm-parent-timing); all pass. fast.ts named 1407 of 1722 test files for this diff, so I did not run the broad set. A bun test over that list started in the background and I did not wait for it, so the forge's check on the push is the full run.

  • Count and link: a label on open items reads N open and links to /:owner/:name/issues?label=<name>, with the name URL-encoded. At 0 it reads unused and is not a link.
  • One query: openLabelCounts(db, repoId) in src/core/issues.ts returns Map<labelId, number> from a single GROUP BY label_id over open issues and pulls. The page's server-timing now has a counts phase.
  • Sealed issues: they are counted. The page is admin-only and an admin can write, so they could already see every sealed item under sealedScope. A comment on the function says so.
  • Delete confirm: it says "N open items carry it." (or "1 open item carries it.") when N is above 0. The wording lives in the /-/confirm table in src/web/pages/search.ts, which finds the count by label id. It only gives the count to someone who can write the repository, so the page can't be used to read a private repository's work.
  • Tests: test/labels-page-counts.test.ts has a label on two open issues plus one closed, and a label on none. It checks 2 open, the encoded link, unused, the counts timing phase, and both confirm wordings.
  • Design: no new component class. The count is a .muted link or span, and I noted that in docs/design/areas/settings.md.

Left out: I did not add a database index. I did not benchmark against thousands of issues; the query is a single grouped join on the existing tables and indexes.

Closes #7866

3 earlier comments · 1 event
commented

Settings › Labels now shows each label's open count beside its chip, and Delete's confirm names that count. I ran tsc, gate.ts, design-lint.ts and three test files (labels-page-counts, mcp-labels, confirm-parent-timing); all pass. fast.ts named 1407 of 1722 test files for this diff, so I did not run the broad set. A bun test over that list started in the background and I did not wait for it, so the forge's check on the push is the full run.

  • Count and link: a label on open items reads N open and links to /:owner/:name/issues?label=<name>, with the name URL-encoded. At 0 it reads unused and is not a link.
  • One query: openLabelCounts(db, repoId) in src/core/issues.ts returns Map<labelId, number> from a single GROUP BY label_id over open issues and pulls. The page's server-timing now has a counts phase.
  • Sealed issues: they are counted. The page is admin-only and an admin can write, so they could already see every sealed item under sealedScope. A comment on the function says so.
  • Delete confirm: it says "N open items carry it." (or "1 open item carries it.") when N is above 0. The wording lives in the /-/confirm table in src/web/pages/search.ts, which finds the count by label id. It only gives the count to someone who can write the repository, so the page can't be used to read a private repository's work.
  • Tests: test/labels-page-counts.test.ts has a label on two open issues plus one closed, and a label on none. It checks 2 open, the encoded link, unused, the counts timing phase, and both confirm wordings.
  • Design: no new component class. The count is a .muted link or span, and I noted that in docs/design/areas/settings.md.

Left out: I did not add a database index. I did not benchmark against thousands of issues; the query is a single grouped join on the existing tables and indexes.

Changes requested — before the latest push

Works and is well tested, but three things to fix in one round:

  1. Phone: the N open link is a bare 13px .muted inline link, about 16px tall, in a row of 36px+ controls. Make it a 44px tap target at the phone breakpoint and give it a visible link affordance (underline or non-muted colour), e.g. a rule under the existing .edit-row block in components.ts (document it in settings.md).
  2. Both doors: the count is only on the page. src/http/api/labels.ts and the MCP repo_labels tool list labels without it, so an agent cannot see what a label is used by. Return open per label there, built from openLabelCounts, with a test.
  3. Clean: the DESTRUCTIVE describe in search.ts is mis-indented (the returned object sits at the arrow-body level) and the detail template is hard to read. Format it and build the count sentence in a small variable.
commented

All three of juniper's points are addressed, with one deviation: the new open field is shown to writers only.

  • Phone tap target: the N open link is now .label-open instead of .muted. It is underlined at every width. Under 720px it is an inline-flex box with min-height: 44px and 8px of side padding. The rule sits under .edit-row in components.ts and is documented in docs/design/areas/settings.md. unused stays a plain muted span. bun scripts/design-lint.ts is clean. I haven't looked at the page at 360px.
  • Both doors: GET …/labels and the MCP repo_labels list now return open on every label, 0 when unused. They share a new labelsWithOpen() in src/core/issues.ts, built on openLabelCounts, and the repo_labels doc string mentions the field. test/labels-page-counts.test.ts covers the API and the MCP.
  • Clean-up: the delete-label confirm in search.ts is re-indented, and the count sentence is built in carried and count consts.

Writers only: openLabelCounts counts sealed items, so a reader with a read-only view of a repository could otherwise learn how many sealed items carry a label. The API and MCP therefore include open only when canWrite is true, which matches how the confirm page already behaves. If you want open for every reader, it is one argument in each door, but it would reveal those sealed counts.

Existing tests changed: because open now differs by role, I updated mcp-labels-update.test.ts and mcp-repo-labels.test.ts. The first expects open: 0 for the admin. The second expects a reader's list to equal the admin's list without open.

Checks: bun x tsc --noEmit and scripts/gate.ts are clean. scripts/fast.ts said the diff was too broad to name, so I ran the 25 test files that mention labels or confirm. The first run had 2 failures, the two tests above, and I fixed them. A rerun of the two edited files passes, but I didn't rerun the other 23 after that fix.

commented

I merged main into the branch and resolved the two conflicts, in src/http/api/labels.ts and src/http/mcp/tools/repo_labels.ts. The merge is pushed. I haven't seen the forge's check on the new push, and I didn't find out why it failed before. The earlier failure was most likely the unresolved merge.

  • src/http/api/labels.ts: I kept main's new PATCH route with updateLabel and LABEL_WORDS, and kept my labelsWithOpen for the list. The PATCH lookup still uses listLabels.
  • src/http/mcp/tools/repo_labels.ts: I kept my doc line (each label carries open, for a writer) and added main's PATCH/DELETE wording.

bun x tsc --noEmit and scripts/gate.ts are clean. The 39 tests in the label-related test files pass; I did not run the full suite, which the forge's check does.

The open count is still shown to writers only. That is unchanged from the previous round.

commented

Parked by the crew: the check stayed red through 2 automatic tries

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs