fix(feed): width-change measurement invalidation + best-effort SSE counts
Post-commit review follow-ups for the batch-3 feed work.
Frontend — VirtualFeed: the guarded setOptions keyed only on (count, scrollMargin),
so a rotation (or the first-paint 0->real container width) changed colWidth / card
heights without invalidating the cached measurements, leaving getTotalSize and the
scrollbar stale until each row scrolled back through the window. Track appliedWidth
and call virtualizer.measure() on a width delta so heights re-estimate at the new
width (rendered rows re-measure immediately via their ResizeObserver). Covers list +
grid and the first-paint 120px-estimate case.
Backend — social.rs: the fresh like/comment count SELECT used `.await?`, so a
transient DB failure would 500 the request after the like/comment had already
committed. Make the count + broadcast best-effort (if let Ok { ... }); the mutation
succeeds regardless and the next event / pull-to-refresh reconciles the count.
Docs — FOLLOWUPS: record the review findings left as-is (grid-prepend tile reflow,
filtered-grid auto-load which is pre-existing, comment-delete stale count, and the
last-write-wins count ordering note).
Verified: svelte-check 0 errors, cargo build clean.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
35
FOLLOWUPS.md
35
FOLLOWUPS.md
@@ -79,6 +79,41 @@ excludes it; the SSR path is guarded by `getScrollElement()` returning null).
|
||||
- [frontend/src/routes/feed/+page.svelte](frontend/src/routes/feed/+page.svelte) — renders `VirtualFeed` for both views
|
||||
- [frontend/src/lib/components/FeedListCard.svelte](frontend/src/lib/components/FeedListCard.svelte) — `content-visibility` removed
|
||||
|
||||
**Known limitations (surfaced in the post-commit review, left as-is — low impact).**
|
||||
- **Grid prepend reflows tiles.** Grid rows are index-keyed and pack 3 tiles each, so
|
||||
an SSE `new-upload` shifts every tile by one position; `anchorTo:'start'` can only
|
||||
anchor a scrolled grid reader when the prepend crosses a 3-item boundary (it adds a
|
||||
*row*). List view is unaffected (one id-keyed row per upload). A fix would key rows
|
||||
by the first tile's id and accept partial-row churn; not worth it for the rarer
|
||||
"new upload while browsing the grid" case.
|
||||
- **Filtered grid can auto-load the whole feed.** When a grid filter matches few items
|
||||
the `VirtualFeed` is short, so the infinite-scroll sentinel sits in-viewport and
|
||||
`loadMore()` fires until `nextCursor` is null — pulling all pages to widen the
|
||||
client-side search. This is pre-existing (the old `FeedGrid` had the same shape, and
|
||||
the empty-filter copy even says "scrolle weiter"), not a virtualization regression.
|
||||
If undesired, gate auto-load to list view or to actual user scroll.
|
||||
|
||||
## Feed — comment deletion leaves a stale live count
|
||||
|
||||
**Problem.** `add_comment` now broadcasts a fresh `comment_count` so feed clients patch
|
||||
the card in place, but `delete_comment` and `host_delete_comment`
|
||||
([backend/src/handlers/social.rs](backend/src/handlers/social.rs),
|
||||
[host.rs](backend/src/handlers/host.rs)) soft-delete without broadcasting any
|
||||
count/event. So a deletion leaves the count too high on every client until a full
|
||||
refetch (pull-to-refresh or an unrelated `upload-processed` merge). `toggle_like`
|
||||
already broadcasts on both add and remove, so likes are fine — the gap is
|
||||
comments-on-delete. Pre-existing, but the in-place-patch scheme makes it observable.
|
||||
|
||||
**Fix.** Emit a `new-comment` (or a `comment-deleted`) event carrying the refreshed
|
||||
`comment_count` from both delete paths, the same best-effort way `add_comment` does;
|
||||
the frontend `patchCount(..., 'comment_count')` handler already consumes it.
|
||||
|
||||
**Note — count ordering.** The broadcast count is read just after the (auto-committed)
|
||||
mutation, not inside it, so under concurrent likes/comments on one upload the SSE
|
||||
messages are last-write-wins. The frontend *replaces* (not increments) the count, so
|
||||
steady state is correct and self-healing; only document this if strict per-event
|
||||
ordering is ever required (then compute the count in-tx with a monotonic sequence).
|
||||
|
||||
## Feed — per-image exact CLS reservation
|
||||
|
||||
**Problem.** `FeedListCard` now reserves a default `aspect-[4/5]` box for photos so
|
||||
|
||||
Reference in New Issue
Block a user