Channel posts: draw only what is near; caches with a budget #270

Merged
littlefox merged 2 commits from issue-236-bounded into main 2026-10-22 06:51:27 +00:00
Owner

Closes #236

  • The channel's post list draws only what is near (WINDOW_JS: an IntersectionObserver on the reading column, 1500 px around it). Far posts become empty blocks as tall as they were, their content dropped, and are fetched again (six at a time, mostly from the cache) when they come near. Older pages load as the top comes near ("Visa äldre" stays for the keyboard); at the bottom the list stays at its bottom while it grows above, like a chat.
  • Kom's caches have budgets (kom_client::lru): 20 000 text stats, 32 MB of bodies, 5 000 conferences; past a budget the least recently used tenth goes, and is fetched again when needed.
  • The thread view keeps its cap; #242 rebuilds it on these pieces.
  • The perf spec scrolls the channel back to 520 posts (instead of 25 clicks) and saves its results after each scenario.

Measured with tools/perf.sh, scrolled back through the channel:

main after
posts drawn all 520 45 of 840
the app's wasm memory 89 MB 14 MB
DOM nodes at the end 17 187 7 074

Verified: new channel-window.spec (126 posts: placeholders far away, fewer than 80 drawn, the newest come back at the bottom); channel-posts spec adjusted (pages may come by themselves); full e2e on three profiles 335 passed; devserver tests; LRU unit tests; lint four ways.

🤖 Generated with Claude Code

https://claude.ai/code/session_01XJW2ocwLunyaLiUwCBHEP8

Closes #236 - **The channel's post list draws only what is near** (`WINDOW_JS`: an IntersectionObserver on the reading column, 1500 px around it). Far posts become empty blocks as tall as they were, their content dropped, and are fetched again (six at a time, mostly from the cache) when they come near. Older pages load as the top comes near ("Visa äldre" stays for the keyboard); at the bottom the list stays at its bottom while it grows above, like a chat. - **`Kom`'s caches have budgets** (`kom_client::lru`): 20 000 text stats, 32 MB of bodies, 5 000 conferences; past a budget the least recently used tenth goes, and is fetched again when needed. - The thread view keeps its cap; #242 rebuilds it on these pieces. - The perf spec scrolls the channel back to 520 posts (instead of 25 clicks) and saves its results after each scenario. Measured with `tools/perf.sh`, scrolled back through the channel: | | main | after | |---|---|---| | posts drawn | all 520 | 45 of 840 | | the app's wasm memory | 89 MB | 14 MB | | DOM nodes at the end | 17 187 | 7 074 | Verified: new `channel-window.spec` (126 posts: placeholders far away, fewer than 80 drawn, the newest come back at the bottom); channel-posts spec adjusted (pages may come by themselves); full e2e on three profiles 335 passed; devserver tests; LRU unit tests; lint four ways. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01XJW2ocwLunyaLiUwCBHEP8
A channel's posts kept every page ever loaded, each post drawn whole with
its pictures, and Kom kept every stat, body and conference it fetched for
the session. Now:
- the list draws only the posts within a couple of screens; far ones are
  empty blocks as tall as they were, their content dropped, fetched again
  when they come near; older pages load as the top comes near, and at the
  bottom the list stays at its bottom while it grows above;
- Kom's stats, bodies and conferences are LRU caches with budgets
  (20 000 stats, 32 MB of bodies, 5 000 conferences).

Scrolled back through 840 posts: 45 drawn, the app's memory 14 MB (89 MB
before). The perf spec scrolls back to 520 posts instead of clicking
'Visa äldre' 25 times, and saves its results after each scenario.

Closes #236

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XJW2ocwLunyaLiUwCBHEP8
Merge remote-tracking branch 'origin/main' into issue-236-bounded
All checks were successful
ci / check (push) Successful in 9m58s
ci / desktop (push) Successful in 16m8s
ci / e2e (push) Successful in 29m48s
9071f80fc3
# Conflicts:
#	crates/kom-client/src/kom.rs
littlefox referenced this pull request from a commit 2026-10-22 14:11:06 +00:00
Sign in to join this conversation.
No description provided.