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

A like can be taken back in one tap, and the decision ledger records the withdrawal #13555

Merged opened this

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

Merged

The behaviour was already on main, so this pull adds only the missing test, test/feed-unlike.test.ts. It passes, bun x tsc --noEmit is clean, and scripts/gate.ts --fix printed nothing. I ran only this one test file, not the wider suite.

Notes

shipped production is serving it deploy 59903fa

opened this

The behaviour was already on main, so this pull adds only the missing test, test/feed-unlike.test.ts. It passes, bun x tsc --noEmit is clean, and scripts/gate.ts --fix printed nothing. I ran only this one test file, not the wider suite. The test is not one that fails without a change, because there was no change to make.

What already held on main (setLike/toggleLike in src/feed/likes.ts; the like, ledger and ranking paths were not changed):

  • One tap: a second press on a liked item removes the like, and the item shows unliked on reload.
  • Ledger: the withdrawal is a new unlike row in feed_signal beside the original like. History is only added to, and the current-state row in feed_like is the only thing removed.
  • API: the same action exists as POST /api/v1/feed/interactions with kind unliked, as the feed_like MCP tool with act unlike, and as /feed/like.
  • Count: it is read from feed_like, so it drops by one. Withdrawing when nothing is liked writes no row and cannot go below zero.
  • Ranking input: rankInputs includes the feed_like row count, so a withdrawal changes it and the feed re-ranks.

What the new test checks, through the API:

  • Two people like an item. One withdraws.
  • The count goes from 2 to 1, and the withdrawer sees it unliked on reload.
  • The other person's like is unaffected.
  • The ledger reads bob:unlike, carol:like, bob:like.
  • The ranking input changes.
  • Repeating the withdrawal, or withdrawing without having liked, writes no row and leaves the count at 0.

I did not touch src/feed/interact.ts, because it only checks that the viewer may act on the item and does not handle likes themselves. I did not add a UI test, because the live like script is already tested in test/feed-like.test.ts.

To try it, run bun test test/feed-unlike.test.ts.

🤖 Generated with Claude Code

Closes #13522

commented

The behaviour was already on main, so this pull adds only the missing test, test/feed-unlike.test.ts. It passes, bun x tsc --noEmit is clean, and scripts/gate.ts --fix printed nothing. I ran only this one test file, not the wider suite. The test is not one that fails without a change, because there was no change to make.

What already held on main (setLike/toggleLike in src/feed/likes.ts; the like, ledger and ranking paths were not changed):

  • One tap: a second press on a liked item removes the like, and the item shows unliked on reload.
  • Ledger: the withdrawal is a new unlike row in feed_signal beside the original like. History is only added to, and the current-state row in feed_like is the only thing removed.
  • API: the same action exists as POST /api/v1/feed/interactions with kind unliked, as the feed_like MCP tool with act unlike, and as /feed/like.
  • Count: it is read from feed_like, so it drops by one. Withdrawing when nothing is liked writes no row and cannot go below zero.
  • Ranking input: rankInputs includes the feed_like row count, so a withdrawal changes it and the feed re-ranks.

What the new test checks, through the API:

  • Two people like an item. One withdraws.
  • The count goes from 2 to 1, and the withdrawer sees it unliked on reload.
  • The other person's like is unaffected.
  • The ledger reads bob:unlike, carol:like, bob:like.
  • The ranking input changes.
  • Repeating the withdrawal, or withdrawing without having liked, writes no row and leaves the count at 0.

I did not touch src/feed/interact.ts, because it only checks that the viewer may act on the item and does not handle likes themselves. I did not add a UI test, because the live like script is already tested in test/feed-like.test.ts.

To try it, run bun test test/feed-unlike.test.ts.

🤖 Generated with Claude Code

Approved

Test-only pull: the unlike behaviour already lives on main (setLike/toggleLike, POST /api/v1/feed/interactions, feed_like MCP tool), and this adds a regression test through the API covering count drop, reload state, withdrawn ledger row beside the like, rankInputs change, and idempotent/no-op withdrawals. No security, UI or dependency surface is touched, and docs/features/feed-like-ledger.md already exists. Next two things I would do: (1) assert the terminal door also withdraws and reaches web viewers live; (2) assert a cross-origin/anonymous POST of unliked is refused.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs