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

A chip on the home feed is drawn only when pressing it changes the posts on the page #6866

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

A kind chip on the home feed is now drawn only when the page has posts of its kind, and it shows its count (`Releases 3`). I started fresh from main rather than finishing on #5815, so the two are separate. `bun test` on `test/feed-chips.test.ts`, `ui-sweep` and `archive-web`, `tsc --noEmit` and the design lint all pass; I did not run the whole suite.

shipped production is serving it deploy f0961d3

opened this

A kind chip on the home feed is now drawn only when the page has posts of its kind, and it shows its count (Releases 3). I started fresh from main rather than finishing on #5815, so the two are separate. bun test on test/feed-chips.test.ts, ui-sweep and archive-web, tsc --noEmit and the design lint all pass; I did not run the whole suite.

  • Counts: chipCounts(items) in src/feed/chips.ts counts the posts the home draws (the page's items), using the same kind-to-chip map as the filter. There is no second rank of the feed and no waitingOn read, so asks never enter a count.
  • Drawing: chipsBar in src/web/studio/feed.ts leaves out a chip with a count of 0. A chip the viewer switched off stays drawn (unpressed, no count) so it can be switched back on. Person chips are unchanged.
  • Tests: test/feed-chips.test.ts seeds a home, reads the drawn chips and their counts, presses each one through the API and checks the visible posts drop by one. It also checks that a pull opened by someone else leaves the Pull requests count equal to the pull posts actually drawn.
  • What the tests do not cover: I did not build a seeded ask the home pins aside, because seeding one was more setup than this change warranted. "A seeded ask adds nothing" is only covered through that pull-count check. What a chip does to asks is not tested on /asks.
  • Duplicate line: I removed a duplicated withoutAsks: true line in readRegion.

To try it, open / as a user with a few kinds of post and press a chip: the posts and its count change. A kind with nothing on the page has no chip.

Closes #6849

Approved

Does what the issue asks: a kind chip is drawn only when the page has a post of that kind, or when it is switched off, so it can always be turned back on. It is still a button with aria-pressed, there is no new markup or class, and it works without JavaScript. The counts come from the same CHIP_OF map the filter uses, so they cannot drift from what pressing the chip hides. The tests would fail without the change. They press every drawn chip and assert the post count drops by one, and they check that a count follows the posts actually drawn. The preview answered, but its feed needs a session, so I did not see the chips there. I checked this from the diff and the tests.

Two things I would do next:

  1. Say the count in the accessible name. A label like "Crew words 1" reads oddly to a screen reader. Put the number in a span with a visually hidden "posts", or use aria-label="Crew words, 1 post".
  2. Apply the same rule to person chips. Check that each one is drawn only when the person has a post on the page or is hidden. Add a test for it.

The import of chipCounts from ../../feed/chips.ts sits next to core/feed_chips.ts. That is fine, but keep an eye on the split.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs