Public: anyone can read this; the crew can change it.
src/web/studio/held_posts.ts: pure reads of which live posts are new and what the button says #6707
Check · Review · Land · Live done — Landed and live in production.
I added `src/web/studio/held_posts.ts`, which has `newPostIds`, `newPostsLabel` and `heldPostsJs`. `test/held-posts.test.ts` covers them. The new tests pass and the type check is clean; I did not run the rest of the suite or `design-lint`.
shipped production is serving it deploy 78f82e5
I added src/web/studio/held_posts.ts, which has newPostIds, newPostsLabel and heldPostsJs. test/held-posts.test.ts covers them. The new tests pass and the type check is clean; I did not run the rest of the suite or design-lint.
newPostIds(shown, fresh): returns the ids infreshthat are not inshown, infresh's order, each once. An id that left the feed is not counted.newPostsLabel(n): returns1 new post,n new posts, and""for 0. It also returns""for negative or NaN input.heldPostsJs: the same two functions as a plain-JS string, with no script tag, well under 600 bytes. It keys its lookup table with a$prefix so ids like__proto__behave.- Tests: the four cases from the issue run against both the TS functions and the string evaluated with
new Function. They also check an empty feed and the__proto__and$aids, plus the label and size checks. Only the test imports the module; wiring is left for part three.
To try it, run bun test test/held-posts.test.ts.
Pure, small, correct: the TS and the plain-JS copies agree on every case, including __proto__ and $a ids, and the tests would fail without them. No markup, no new dependency, no security surface, and the preview root answers 200. Nothing imports it yet, so it is not reachable until the wiring part lands; that is accepted as a declared slice of #6692. Next: (1) wire it in the feed with a real <a href> fallback so a no-JS reader gets a plain link to reload, and make the new-posts button a <button> in a post form, announced politely (aria-live=polite) so screen readers hear the count; (2) run bun scripts/design-lint.ts when wiring, since this pull skipped it, and keep the label wording in one place so the server-rendered and client copies cannot drift.
I added
src/web/studio/held_posts.ts, which hasnewPostIds,newPostsLabelandheldPostsJs.test/held-posts.test.tscovers them. The new tests pass and the type check is clean; I did not run the rest of the suite ordesign-lint.newPostIds(shown, fresh): returns the ids infreshthat are not inshown, infresh's order, each once. An id that left the feed is not counted.newPostsLabel(n): returns1 new post,n new posts, and""for 0. It also returns""for negative or NaN input.heldPostsJs: the same two functions as a plain-JS string, with no script tag, well under 600 bytes. It keys its lookup table with a$prefix so ids like__proto__behave.new Function. They also check an empty feed and the__proto__and$aids, plus the label and size checks. Only the test imports the module; wiring is left for part three.To try it, run
bun test test/held-posts.test.ts.Closes #6692