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

A person likes a post in the feed: one press records a like, a second takes it back, and the post shows how many #7765

Parked opened this
Closed without merging

Every feed post now has a Like button with a count. One press likes it, a second press takes the like back, and a person counts once however often they press. liked and unliked are interaction kinds, but their rows go in a new append-only table, itemlike (migration 20261101220516-item-like, pinned).

Notes

stopped parked by the crew deploy c581f78

opened this

Every feed post now has a Like button with a count. One press likes it, a second press takes the like back, and a person counts once however often they press.

liked and unliked are interaction kinds, but their rows go in a new append-only table, item_like (migration 20261101220516-item-like, pinned). The interaction table's CHECK on kind can't be widened without a rebuild, and an old process running alongside the new one during a roll would not survive that (#875). proof_run dealt with the same limit the same way. recordInteraction writes like rows to the new table and listInteractions reads both tables together, so callers see likes as ordinary interactions. A person likes an item while their newest row for it says liked. Rows are never edited.

  • API: POST /api/v1/feed/interactions with kind: "liked" toggles the like. It goes through the same access check as the other kinds (readInteraction in src/feed/interact.ts). An optional liked: true|false sets the state instead of flipping it, so a replayed request lands the same. kind: "unliked" takes the like back. It answers 201 { likes, liked }, and a bad liked value is 422 invalid_liked. The action itself is in src/feed/like.ts.
  • Feed: every item from GET /api/v1/feed carries likes and liked, filled for the whole page in one query (likesOf in src/core/interactions.ts).
  • Card: likeControl in src/web/studio/feed.ts draws a plain form posting to POST /feed/like. It checks the same origin, redirects back to /, and works without JavaScript. With the script, the button turns at once, the server's count replaces the guess, and a refused request puts it back and says why. The count is the button's last word, so a new number moves nothing else. Signed out, the card shows "N likes" with no button, and nothing at zero.
  • Affinity: a like weighs 2, the same as shared. Only a like that still stands counts; one taken back counts for nothing.
  • Docs: docs/FEED.md, the OpenAPI entries for both feed routes, and docs/design/areas/feed.md (no new CSS class).

test/feed-like.test.ts (10 tests, which fail without the change) covers:

  • like and unlike, and that a second like by the same person does not double count;
  • an item the viewer cannot read is a 404 through both the API and the form, and nothing is written;
  • a form from another site is refused, and a signed-out post writes nothing;
  • the card markup signed in and signed out;
  • the affinity weight.

Test I changed: test/front-door-timing.test.ts compared the feed page to the raw ranking field for field. Pages now also carry likes: 0, liked: false, so I added those to the expected value; it still checks the order.

Tests run: type check, the design lint, test/mcp-size.test.ts, and every feed, home, OpenAPI, migration and MCP-feed test pass. One test fails here: test/composer-draft.test.ts, because Chromium can't start in this sandbox. It fails the same way without this change.

Left out: an MCP tool and ranking apps by likes (both out of scope in the issue), and a heart icon (the button says Like/Liked).

To try it on the preview: sign in, press Like on a post and watch the count change in place, then press again to take it back. With JavaScript off, the same press posts the form and returns to /.

🤖 Generated with Claude Code

Closes #7751

5 earlier comments
commented

Every feed post now has a Like button with a count. One press likes it, a second press takes the like back, and a person counts once however often they press.

liked and unliked are interaction kinds, but their rows go in a new append-only table, item_like (migration 20261101220516-item-like, pinned). The interaction table's CHECK on kind can't be widened without a rebuild, and an old process running alongside the new one during a roll would not survive that (#875). proof_run dealt with the same limit the same way. recordInteraction writes like rows to the new table and listInteractions reads both tables together, so callers see likes as ordinary interactions. A person likes an item while their newest row for it says liked. Rows are never edited.

  • API: POST /api/v1/feed/interactions with kind: "liked" toggles the like. It goes through the same access check as the other kinds (readInteraction in src/feed/interact.ts). An optional liked: true|false sets the state instead of flipping it, so a replayed request lands the same. kind: "unliked" takes the like back. It answers 201 { likes, liked }, and a bad liked value is 422 invalid_liked. The action itself is in src/feed/like.ts.
  • Feed: every item from GET /api/v1/feed carries likes and liked, filled for the whole page in one query (likesOf in src/core/interactions.ts).
  • Card: likeControl in src/web/studio/feed.ts draws a plain form posting to POST /feed/like. It checks the same origin, redirects back to /, and works without JavaScript. With the script, the button turns at once, the server's count replaces the guess, and a refused request puts it back and says why. The count is the button's last word, so a new number moves nothing else. Signed out, the card shows "N likes" with no button, and nothing at zero.
  • Affinity: a like weighs 2, the same as shared. Only a like that still stands counts; one taken back counts for nothing.
  • Docs: docs/FEED.md, the OpenAPI entries for both feed routes, and docs/design/areas/feed.md (no new CSS class).

test/feed-like.test.ts (10 tests, which fail without the change) covers:

  • like and unlike, and that a second like by the same person does not double count;
  • an item the viewer cannot read is a 404 through both the API and the form, and nothing is written;
  • a form from another site is refused, and a signed-out post writes nothing;
  • the card markup signed in and signed out;
  • the affinity weight.

Test I changed: test/front-door-timing.test.ts compared the feed page to the raw ranking field for field. Pages now also carry likes: 0, liked: false, so I added those to the expected value; it still checks the order.

Tests run: type check, the design lint, test/mcp-size.test.ts, and every feed, home, OpenAPI, migration and MCP-feed test pass. One test fails here: test/composer-draft.test.ts, because Chromium can't start in this sandbox. It fails the same way without this change.

Left out: an MCP tool and ranking apps by likes (both out of scope in the issue), and a heart icon (the button says Like/Liked).

To try it on the preview: sign in, press Like on a post and watch the count change in place, then press again to take it back. With JavaScript off, the same press posts the form and returns to /.

🤖 Generated with Claude Code

commented

I merged main into the branch, resolved the two conflicts, and pushed. The 146 feed tests pass, tsc is clean apart from a missing happy-dom type declaration in test/changelog.test.ts, and the design lint is clean. I did not run bun scripts/gate.ts as its own step (it printed nothing in the combined command). I also did not run the full suite; the forge's check does that on the push.

  • src/web/studio/feed.ts: feedCard now takes both arguments, signedIn (the Like control) and mayReply (the Reply form from #8211). I updated the call in drawRegion and the calls in test/feed-reply.test.ts to match.
  • docs/FEED.md: the Like paragraph and the Reply paragraph both stay.
  • Like form redirect: main moved the feed from / to /feed, so the plain Like form was sending people to a page without the feed. likeSubmit in src/web/studio/actions.ts now returns to /feed. test/feed-like.test.ts and the redirect line in docs/FEED.md follow.

A person still reaches Like from the feed in two taps. Like and Reply both show on a card.

commented

I fixed one of the four failures and pushed. I couldn't reproduce the other three.

  • Fixed: "the forge over MCP > map and wait_for are the plan's own actions". Since #8226 (first: N), the MCP map tool counts as a write and no longer reports readOnlyHint: true. The test still expected the old value, so it was out of date. I changed test/mcp.test.ts to expect false for both map and wait_for. The failure showed up in my runs after I merged origin/main into the branch.
  • Not reproduced: the subscriptions-screen test and the two forge-webspec tests (canonical address, walked repository pages). They failed in 1–2 ms inside the full sharded run. They pass here, on their own and next to the feed and MCP suites, so I treat them as load-related flakes. I changed nothing for them. If they fail again on the forge's check, that log is the next thing to read.

The scripts/gate.ts run and bun x tsc --noEmit printed no errors. The three test files above pass (56 tests). I did not run the full suite, as instructed.

The pull is still the like button: the like form returns to /feed after a like, as in the earlier merge commit. This push adds only the merge of main and the test fix.

commented

I merged main into the branch and pushed it. The only conflict was in test/mcp.test.ts.

The conflict: both sides had changed the map read-only-hint assertion to [false, false] and differed only in the comment above it. I kept main's comment, "map writes only when given first, so it spells no read-only hint."

Checks: I ran bun x tsc --noEmit, bun scripts/gate.ts, and the MCP and feed tests (216 passed, 0 failed); all came back clean. I did not run the full suite; the forge's check does that on the push.

The pull itself is unchanged: a person likes a post in the feed, and the like form returns to /feed.

commented

I found nothing to fix for "image blob pages > a PNG's header size reserves the box before the bytes arrive", so I pushed a fresh merge of main to get the check re-run.

  • No failure here: test/render-image.test.ts passed all 12 tests on three runs in a row.
  • Not my change: the branch has no diff against main in src/web/render, src/web/pages/repo.ts or that test. The like-button work doesn't touch image rendering.
  • Looks like load: in the check it failed in 7.8 ms, and the log says it "fails only beside others" and was not re-run alone. I couldn't reproduce that here.
  • Not found: I didn't find the cause, so I changed nothing in the test or the code.
  • Checks: bun x tsc --noEmit and bun scripts/gate.ts printed no errors. The render-image and feed tests passed (182 passed, 0 failed). I did not run the full suite.

If the check fails the same way again, the next step is to read that run's log for what the blob page returned.

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