Skip to content

fork(calm home): wake revealed rows, fix shelf counts, read roles only when on - #1372

Merged
scuttletoby merged 1 commit into
mainfrom
fork/cal5-calm-minors
Nov 29, 2026
Merged

scuttletoby merged 1 commit into
mainfrom
fork/cal5-calm-minors

Conversation

@scuttletoby

Copy link
Copy Markdown
Owner

Part of #878. A follow-up to #1349 that fixes the three code-lens minors from #1349 (comment). Only fork files and the README changed. No seam line was added or moved.

What changed

  1. Swipe after opening "Other threads". A scroll wakes the calm list's own row keys. Opening or folding the group changes only the calm data, not upstream's threadListV2Items, so upstream's wake-up effect did not run again. Rows revealed this way had no swipe actions until the next scroll. Now the group row's press wakes the next layout's rows itself (calmGroupWakeKeys). It takes the index window of the rows awake now, widened by the rows the group adds (below) or removes (above), and passes it to the same activate upstream uses. If no row is awake yet, it does nothing. The alias check moved into calmRowIsActive, so the row wrapper and the wake-up share it.
  2. Shelf counts. A role thread listed in an open Working, Snoozed or Settled shelf is moved to the top. Its shelf header no longer counts it. A shelf left with no rows loses its header, as upstream draws none at zero. The README part says so.
  3. Roles atom while off. The hook reads calmRolesAtom(enabled, forkThreadRolesAtom). While the view is off, this is an empty constant atom, so role changes no longer re-render HomeScreen. The list props stay exactly {}.

Tests (failing first)

apps/mobile/src/fork/calmSidebar/calmHome.logic.test.ts. Before the fix, 6 tests failed: 3 for the wake-up, 2 for the shelf counts and 1 for the roles source. They all pass now (23/23 in the folder).

  • Wake-up: uses upstream's real createSwipeRowActivation. It wakes the closed calm rows (as a scroll does), opens the group, and checks that plain-a is dormant without the wake-up and that every row is awake after it. It also covers folding, and the case where no row is awake.
  • Shelf: a working shelf holding the orchestrator plus one other thread shows count: 1. One holding only the orchestrator loses its header.
  • Roles: with an AtomRegistry, the off path never runs the roles atom's read function, and the on path returns the roles.

vp run check:changed passes: format, lint, knip, typecheck, test and react compiler. No test here needed a local socket. Nothing was run in a real phone client (sub-agent: no dev servers).

State question

  • Old device / empty state: unchanged. A missing key reads as off, so the hook reads the empty roles atom and the list is upstream's. The group starts closed. The wake-up runs only on a press of the group row, which exists only while the view is on.
  • Half-written or garbled value: unchanged. Only the exact true is on, and each switch is one key. The wake-up writes no state: it only marks rows awake in memory, and the next scroll replaces that. If a save of the group switch fails, the store re-reads the old value. The rows woken for the layout that did not happen are a superset by index, and the next scroll or list change resets them.
  • Runs again: the layout and the shelf counts are still a pure function of upstream's items, the roles, the two switches and now, so the same input gives the same rows and counts. The wake-up computes both layouts from the same inputs, so pressing twice gives the same windows.

Left for #878: nothing from this review. A role change by itself (without an upstream item change) still does not re-run the wake-up. The lens did not raise it, and the next scroll covers it.

🤖 Generated with Claude Code

…y when on

Follow-up to the phone calm view (#878, PR #1349 code-lens minors):

- Opening or folding "Other threads" changes only the calm rows, so
  upstream's swipe wake-up did not run again and revealed rows stayed
  without swipe actions until the next scroll. The group toggle now
  wakes the next layout's rows in the awake index window.
- A role thread pulled out of an open shelf no longer counts in that
  shelf's header; a shelf left empty loses its header.
- With the calm view off, the hook reads an empty constant atom instead
  of the roles atom, so role changes no longer re-render the home list.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@scuttletoby

Copy link
Copy Markdown
Owner Author

lens: code · reviewer: Claude (lens sub-agent) · read at: 31e4f05

blocker: none
major: none
minor: expanding the group wakes [first, last + change] in the next layout, so it wakes every row the group adds, even far below the screen. With 100+ folded threads that wakes 100+ swipe rows, where upstream wakes about the screen plus 2/3 rows. The screen offset does not move when the group opens, so [first, last] in the next layout's index space (plus upstream's margin) is about the rows on screen. This is only a perf cost, and the next scroll resets it. Fine to leave for #878.

Checked:

  • Scope: the diff touches only apps/mobile/src/fork/calmSidebar/* and docs/fork/README.md. HomeScreen and every other upstream file are unchanged, and no seam line was added or moved.
  • Calm view off: calmHomeLayout returns OFF before it reads anything, so listProps is {}. The hook now reads NO_CALM_ROLES, a module constant, so a role change no longer re-renders HomeScreen. The hook calls (two switches and one atom read) are the same count as before, and the off path adds no render and no context read. CalmGroupRow's use(SwipeRowActivationContext) exists only while the view is on.
  • Wake: it calls upstream's own activation.activate on the inner upstream activation (spread through CalmRowActivation), with calm keys. Calm keys are the keys upstream's scroll wake uses too (getState().data is the calm data). Expanding: a current awake row at index i maps to i or i+change, which is inside [first, last+change], and every added row is inside too. Folding: the window [first+change, last] holds every kept row, and the removed rows are gone. The press is a list touch, so activate may land in pendingKeys. The same touch-end then runs trackTouches and applies it in either event order, so nothing waits for a second touch. If no row is awake it returns null and wakes nothing. calmRowIsActive is a straight move of the old alias check.
  • Shelf counts: a role row is subtracted only from the shelf whose header comes before it (sectionByKey), and only rows that are drawn are counted. A role thread in a folded shelf is not in items, so it is not moved and stays counted, which is right. The settled count holds threads the shell left out or paged beyond "Show more", so the header stays while any are left. It drops only when the drawn role rows were the whole count. That matches upstream's count > 0 rule for drawing a header.

State question:

  • Roles old or empty: calmPartition gives non-calm, so the layout is OFF and the list is upstream's. Turning the view on switches useAtomValue to the real roles atom, which reads fresh.
  • Role changed while the group is open: the layout and the shelf counts are recomputed from the new roles. No wake runs (noted in the PR body). Rows that move keep their swipe until the next scroll or item change. This is the same as on main, so it is not a regression.
  • Group toggled twice before a re-render: both presses read the same expanded and write the same value. The second press is a no-op and wakes a superset of the first, the same as !group.expanded before. A save that fails re-reads the old value, and the extra rows it woke are reset by the next scroll.
  • Runs again or stops half-way: the layout is pure and the wake is only in memory. Nothing is persisted beyond the existing switches.

Tests: the six new tests cover each fix and fail on the old code (per the PR body; I did not re-run them). CI Test, Lint, and Build and Typecheck pass on this head. I ran no tests: there was no suspected bug to reproduce.

🤖 Generated with Claude Code

@scuttletoby scuttletoby added the fork:merge-ready Merge conveyor: lenses done, merge when green (PRs) label Nov 29, 2026
@scuttletoby
scuttletoby merged commit efcf2cd into main Nov 29, 2026
28 checks passed
@scuttletoby
scuttletoby deleted the fork/cal5-calm-minors branch November 29, 2026 20:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork:merge-ready Merge conveyor: lenses done, merge when green (PRs)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant