Skip to content

Count slots beside the Build tab, and keep the count up to date - #1077

Merged
richshaw merged 5 commits into
mainfrom
claude/issue-597-build-count
Nov 25, 2026
Merged

richshaw merged 5 commits into
mainfrom
claude/issue-597-build-count

Conversation

@richshaw

@richshaw richshaw commented Nov 19, 2026 •

Copy link
Copy Markdown
Owner

Fixes #597.

The problem

The number beside a signup's Build tab was fields + slots, so 4 slots and 3 fields read "Build 7", a number that matches nothing on the page. The layout worked it out on the server, so adding, duplicating or deleting a slot left it as it was until a reload. A screen reader heard "Build 7" with nothing to say what it counts.

The fix

  • Counts slots. The layout passes sig.slots.length (with its words for a screen reader) to BuildBridge and TabsNav.
  • Kept up to date. The Build tab reports its slot count through BuildBridge (useReportSlotCount, fed from useBuildState's rows), and TabsNav reads it with useSlotCount(). The count sits in a context of its own beside the bridge's, so a change re-renders only what reads it. The bridge lives in the layout, so Responses and Settings keep the new count after the organizer leaves Build. When the layout loads again (Publish, Close, a Settings save), its fresh server count replaces the reported one, since a connected assistant may have added slots meanwhile. No polling, as the issue asks.
  • Says what it counts. The badge is aria-hidden, and visually hidden text after the tab name gives the count in words, so Chromium's accessible name is "Build 4 slots". The issue suggested "Build, 4 slots". A comma would mean a hard-coded separator in JSX (the hard-coded-text lint forbids it) or a message that repeats the tab's name, so I left it out. Responses keeps its plain number.
  • New message organizer.build.sheet.slotCount. The server formats the first value, and the Build tab (which already has organizer.build messages) formats the ones after it. That way the layout still sends the browser no translator. Translated into Swedish ("{count, number} pass") and German ("… Aufgabe/Aufgaben") and marked.
  • Budget: /app/signups/[id]/build goes from 151.6 to 151.8 kB (measured 151.5 kB on main, 151.8 kB here). It's the reporting hook and the count's context. I cut a first version (151.9 kB) down by replacing a ref-and-layout-effect with state derived from props.
  • e2e helper: measureLabel in tests/e2e/helpers/label-fit.ts now skips text in a 1px box (sr-only). It counted the hidden "44 Aufgaben" as a second line of the tab, failing the 320px fit check in Swedish and German. The check still measures every visible word.
  • CHANGELOG entry under Fixed.

Translation review

A different model reviewed the two translations against the glossaries in docs/translating.md:

  • sv organizer.build.sheet.slotCount: correct (pass is the glossary word and the same in the plural). It suggested the plain form "{count, number} pass" over a plural with two identical branches, as organizer.aiDraft.title writes it. Taken.
  • de organizer.build.sheet.slotCount: correct (Aufgabe/Aufgaben, {count, number}). No change.

Tests

  • BuildBridge.test.tsx: the count starts from the layout's slots, follows the Build tab as slots come and go, stays on another tab, and gives way to a fresh load's count.
  • TabsNav.test.tsx: Build's accessible name says "2 slots" in place of the bare number, and Responses keeps its number.
  • Ran and passed: pnpm lint && pnpm format:check && pnpm typecheck && pnpm knip && pnpm test (3769 passed), pnpm build && pnpm budgets, and the e2e specs for tabs-focus-ring, responses, organizer, translated-organizer, organizer-language, a11y, slot-row-layout and help/* (container config, chromium). CI is green on 46a373b.

Before merging

This raises the Build page's number in budgets.json (151.6 → 151.8 kB), for the reason above.

Built in session: https://claude.ai/code/session_016YZ9SUiiX78YRCR84dpJve

🤖 Generated with Claude Code

The Build tab's number added slots and fields together and changed only on
a reload. It now counts slots: the layout passes its count to BuildBridge,
the Build tab reports its own as slots are added, duplicated or deleted,
and the tabs show the reported count until the layout loads again. A
screen reader hears "Build 4 slots" in place of the bare number, from a new
organizer.build.sheet.slotCount message, translated into Swedish and German.

The Build page's budget goes from 151.6 to 151.8 kB for the reporting hook.
The e2e label-fit helper skips visually hidden text, which is on no line.

Fixes #597.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016YZ9SUiiX78YRCR84dpJve
@richshaw richshaw added pipeline:ux Changes what a person using OpenSignup sees or does pipeline:working A session is working on it right now labels Nov 19, 2026 — with Claude
@richshaw
richshaw requested a balanced review from Copilot November 19, 2026 07:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@richshaw richshaw added pipeline:tophat and removed pipeline:working A session is working on it right now labels Nov 19, 2026 — with Claude
@richshaw richshaw added the pipeline:working A session is working on it right now label Nov 19, 2026 — with Claude

Copy link
Copy Markdown
Owner Author

Tophat: passed

Ran 46a373b locally with pnpm dev, Postgres 16, Chromium at 1280×900, 390×844 and 320×700. Made-up data only (one organizer, pat@example.com; one signup, "Snack duty — Spring season", with 2 fields).

Check Result What I saw
Before, on the base (b761220) ✅ reproduced The tab read "Build 12" with 10 slots and 2 fields. After Add a slot it still read 12 (there were now 11 slots).
Counts slots ✅ On the head the same signup reads "Build 11", then "Build 1" for a one-slot signup. Responses still shows its plain number.
Follows add, duplicate, delete with no reload ✅ Add a slot 3→4 and 11→12, Duplicate 3→4, Delete 4→3, each updated the tab within about a second. A reload gives the same number, so the server agrees.
Kept on other tabs ✅ After adding a slot on Build (4), the count stayed 4 on Responses and Settings and back on Build.
A fresh load's count wins ✅ With the page open on Settings, I added a slot through POST /api/signups/{id}/slots. The tab stayed at 5 until Publish and share, which made it 6. The same thing happened on Build with Reopen signup (9→10).
Accessible name ✅ The tablist's accessibility tree has tab "Build 1 slot" and tab "Build 12 slots". The badge is hidden and the words come after it. Responses still reads tab "Responses 0".
Phone (390 px) ✅ The tab strip is 390 wide in a 390 viewport, with no horizontal scroll.
Swedish (organizer stored as sv) ✅ The tab reads tab "Bygg 12 pass". Deleting a slot made it "Bygg 11", with no reload.
Console and server log ✅ No console errors in any run. The only server error is the health check's query of pgboss.job, because no worker was running.

Not caused by this PR, but seen along the way:

  • At 320 px the Swedish tab strip is 373 px wide in a 320 px box, the same on the base and the head (Bygg's tab is 92 px before, 91 after). Issue The Swedish signup tabs don't fit at 320 px, so Inställningar is half off-screen #1022 already covers this.
  • When a slot is added somewhere else and the layout then reloads (Reopen), the tab shows the server's 10, but the Build sheet still lists the 9 rows it had. The sheet has never picked up slots added somewhere else, and the tab now takes the fresh number, as the PR says. Until the next reload, the badge can be one ahead of the rows on screen.
  • I didn't check German at runtime. It hasn't shipped, so it would need a server restarted with E2E_UNSHIPPED_LOCALES. The PR's e2e run covered it.

For the owner (UX): The number beside a signup's Build tab now counts only its slots, and it changes the moment a slot is added, duplicated or deleted, rather than on the next reload. A screen reader hears "Build 4 slots" rather than "Build 7". Shown in 1077-before-tabs / 1077-before-after-add (old: 12, and no change on add) against 1077-after-tabs / 1077-after-tabs-after-add (new: 11 then 12), plus 1077-after-phone, 1077-after-tabs-sv-desktop and 1077-after-publish.

Screenshots are in https://claude.ai/code/session_016YZ9SVEQxJF4v3jskEY71c.


Generated by Claude Code

@richshaw richshaw added pipeline:review pipeline:working A session is working on it right now and removed pipeline:tophat pipeline:working A session is working on it right now labels Nov 19, 2026 — with Claude

@richshaw richshaw left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: passed (round 1)

The Build tab's badge now counts slots only, starting from the layout's sig.slots.length and then following the Build tab's useBuildState rows (which are slots, nothing else) through a separate SlotsContext in BuildBridge, so only the tabs re-render when it changes. The derived-state reset (loaded !== slots) means a layout reload (Publish, Close, a Settings save) brings the server's count back, and a tab switch, which keeps the layout's props, keeps the reported one. reportSlots is setShownSlots, so the bridge's memo stays stable. The badge is aria-hidden and the words follow it in sr-only, so the accessible name is "Build 4 slots". TabsNav has one caller, updated. Every item in #597's "Done when" is met, except the comma in "Build, 4 slots", which the description explains (it would mean a hard-coded separator or a message that repeats the tab name). That's a fair trade.

Blocking (0): none.
Optional (2):

  • src/messages/sv.json / de.json slotCount: English writes {count, number, ::group-off}, Swedish and German plain {count, number}, so past 999 slots the spoken count is grouped ("1 000 pass") while the badge shows "1000". Harmless; only matters on very large signups.
  • BuildBridge.tsx ~L120: after a reload that follows slots added elsewhere, the badge takes the server's count while the Build sheet still lists its old rows (the tophat saw 10 vs 9). The PR says so and the issue rules out polling, so this is as designed.

Earlier threads: none (Copilot couldn't review: quota).
Checks: CI green on 46a373b (lint-type-test, e2e, CodeQL). Tophat passed on this same SHA, so no runtime change since. Read the diff, the callers of TabsNav, and useBuildState's rows locally.

Waits for the owner because it's UX (the Build tab's number and what a screen reader hears) and it raises a budget: /app/signups/[id]/build 151.6 → 151.8 kB, for the reporting hook and its context. Look at the tophat's 1077-before-* and 1077-after-* screenshots, and 1077-after-tabs-sv-desktop for Swedish.

https://claude.ai/code/session_016YZ9SVW4nwJA8hbYQ1PQ3P


Generated by Claude Code

@richshaw richshaw added pipeline:owner Passed; waits for the owner (UX or high-risk) and removed pipeline:review pipeline:working A session is working on it right now labels Nov 19, 2026 — with Claude

Copy link
Copy Markdown
Owner Author

Owner: Build page size limit raise approved

The owner approved, in a live session, raising the /app/signups/[id]/build limit in budgets.json for this PR. The approval covers the raise this PR needs on its own (151.6 → 151.8 kB), and the larger number needed when it merges after #1075, #1076 or #1079, which raise the same line: measure again with pnpm build && pnpm budgets and set the limit to what the page measures with all of them in.

main is already at 151.8 kB, so this PR's raise may already be covered once main is merged in.

This covers the size limit only. The change itself still waits at pipeline:owner for the owner's look.

https://claude.ai/code/session_016YZ9SS7PCSeTVXMcS859ee


Generated by Claude Code

@richshaw richshaw added pipeline:merge and removed pipeline:owner Passed; waits for the owner (UX or high-risk) labels Nov 24, 2026
@richshaw richshaw added the pipeline:working A session is working on it right now label Nov 24, 2026 — with Claude

Copy link
Copy Markdown
Owner Author

Approved by the owner at 46a373b.

https://claude.ai/code/session_016YZ9SUe5UE1Mx8NCe1GqEX


Generated by Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016YZ9SUe5UE1Mx8NCe1GqEX
@richshaw richshaw added pipeline:fix and removed pipeline:merge pipeline:working A session is working on it right now labels Nov 24, 2026 — with Claude

Copy link
Copy Markdown
Owner Author

Merge: not merged, sent to fix

The PR was in conflict with main only in CHANGELOG.md. I merged main in at 9bc04f8, keeping both sides' entries (main's first). The PR's own change outside the changelog is the same as at 46a373b.

One gate failed on 9bc04f8:

  • CI red: lint-type-test fails at pnpm budgets. /app/signups/[id]/build loads 151.9 kB against its 151.8 kB budget. main had already raised that line to 151.8 kB for Keep a slot row's count clear of its hover toolbar #1075, so this PR's own raise merged away and its growth is now over the limit. The other gates passed (review and tophat at 46a373b, no threads, owner approval recorded for 46a373b).

The owner's comment above already approves setting this limit to what the page measures with the other PRs in. The fix is likely a one-line budgets.json change to 151.9, measured again with pnpm build && pnpm budgets.

https://claude.ai/code/session_016YZ9SUe5UE1Mx8NCe1GqEX


Generated by Claude Code

@richshaw richshaw added the pipeline:working A session is working on it right now label Nov 24, 2026 — with Claude
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016YZ9SUe5UE1Mx8NCe1GqEX
main raised the line to 151.8 kB for #1075's own code, so this PR's raise
merged away. With both in, the page loads 151.949 kB (pnpm build &&
pnpm budgets with CI's NEXT_PUBLIC_* values); budgets are one decimal, so
152.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016YZ9SUe5UE1Mx8NCe1GqEX

Copy link
Copy Markdown
Owner Author

Address: CI fixed in d90b2b7

What was wrong: pnpm budgets failed on 9bc04f8. /app/signups/[id]/build loaded 151.9 kB against its 151.8 kB budget. main had raised that line to 151.8 kB for #1075, so this PR's own raise merged away.

What changed:

  • Merged main again (#1091, service code only, no conflict).
  • budgets.json: /app/signups/[id]/build 151.8 → 152. With main and this PR together the page loads 151.949 kB (pnpm build && pnpm budgets with CI's NEXT_PUBLIC_* values). Budgets use one decimal, so 152 is the smallest that passes. The owner's earlier comment approves setting this line to what the page measures with Keep a slot row's count clear of its hover toolbar #1075 in.

Ran: pnpm lint && pnpm format:check && pnpm typecheck && pnpm knip && pnpm test (3873 passed), pnpm build && pnpm budgets (passes at 152).

No runtime code changed. The only file changed outside the merges is budgets.json.

https://claude.ai/code/session_016YZ9SUe5UE1Mx8NCe1GqEX


Generated by Claude Code

@richshaw richshaw added pipeline:review pipeline:working A session is working on it right now and removed pipeline:fix pipeline:working A session is working on it right now labels Nov 24, 2026 — with Claude

@richshaw richshaw left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: passed (round 2)

Since the last review (46a373b): two merges from main and d90b2b7, which changes only budgets.json: /app/signups/[id]/build 151.8 → 152 kB. No runtime code changed since the tophat that passed (shared check prints 0).
Budget check: my own pnpm build && pnpm budgets with CI's NEXT_PUBLIC_* values measures the Build page at 151.9 kB against 152, so it passes. Budgets use one decimal, so 152 is the smallest limit that fits.
Checks: CI green on d90b2b7 (lint-type-test, e2e, CodeQL). No review threads.

Waits for the owner: it's UX, and the approval recorded at 46a373b doesn't carry over, because d90b2b7 is a commit of the PR's own (the budget raise). The owner's earlier comment approves raising this line to what the page measures with #1075 in, which is what d90b2b7 does, so this needs only a fresh OK. No tophat card (the tophat's screenshots are in its session).

https://claude.ai/code/session_016YZ9SUXdWjAwJhK7qPRd9V


Generated by Claude Code

@richshaw richshaw added pipeline:owner Passed; waits for the owner (UX or high-risk) and removed pipeline:review pipeline:working A session is working on it right now labels Nov 24, 2026 — with Claude
@richshaw richshaw added pipeline:merge and removed pipeline:owner Passed; waits for the owner (UX or high-risk) labels Nov 25, 2026
@richshaw richshaw added the pipeline:working A session is working on it right now label Nov 25, 2026 — with Claude

Copy link
Copy Markdown
Owner Author

Approved by the owner at d90b2b7.

https://claude.ai/code/session_016YZ9SVEZdRizJssntdwLA8


Generated by Claude Code

@richshaw
richshaw merged commit 535b460 into main Nov 25, 2026
5 checks passed
@richshaw
richshaw deleted the claude/issue-597-build-count branch November 25, 2026 22:01
@richshaw richshaw removed pipeline:merge pipeline:ux Changes what a person using OpenSignup sees or does pipeline:working A session is working on it right now labels Nov 25, 2026 — with Claude
richshaw pushed a commit that referenced this pull request Nov 25, 2026
Resolves the conflict with #1077 in TabsNav: the count badge keeps
#1077's aria-hidden on Build (with its sr-only words after it) and this
branch's narrower phone spacing. CHANGELOG keeps both entries.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016YZ9SSe4RUc89LXkqYHJs6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The Build tab's count adds slots and fields together, and changes only on a reload

3 participants