Repository navigation
perf(mobile): reuse Linear grouping between list and board - #20431
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📥 CommitsReviewing files that changed from the base of the PR and between 67726aed657187e4a8d22c78be140dc5989066ca and af1a312. 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 2 remain after this review. 📝 WalkthroughWalkthroughThe hook now reuses Priority: ⬇️ Low Merge Risk: 🔵 Low · up to The production projection change has parity and transition coverage, but one performance-oriented test may be flaky on supported JavaScript engines despite correct behavior. This is a bounded test-maintenance risk rather than a production regression. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description gives detailed scope, rationale, behavior preservation, testing, limitations, and risk information. However, it omits the required Linked Issue section and Visual Proof section, and it does not include the repository checklist sections. Resolution Add a Linked Issue with the issue reference, add a Visual Proof section with
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Board reuses list sections —
linearBoardSectionsnow returnslinearIssueSectionsfor every grouping exceptnone, which still computes its ownstatussplit for columns. - Memo deps widened —
linearIssueSectionsjoins the board memo's dep array; since it is a pure function of the existing(linearGroupBy, linearIssuesForView, linearOrderBy)deps, invalidation is unchanged. - New parity test suite — 17 cases in
mobile/src/tasks/use-mobile-tasks-provider-view-projection.test.tsxassert board/list array identity, byte-for-byte shape parity against the kept pre-change implementation across 5 groupings × 3 orderings, transition/identity behavior, non-mutation, and differential grouping counts.
The aliasing between linearIssueSections and linearBoardSections is safe: groupLinearIssues sorts a copy and allocates fresh section arrays, and both consumers (mobile-tasks-linear-list.tsx and the hook's linearListEntries flatMap) only read them. A search of mobile/src/tasks confirms the sole section.issues.push is the build-time call inside groupLinearIssues itself.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: dca0d3eb-d285-4b6d-a3b2-66caf4d69d2c
📥 Commits
Reviewing files that changed from the base of the PR and between cf7ce05 and 67726aed657187e4a8d22c78be140dc5989066ca.
📒 Files selected for processing (3)
mobile/src/tasks/mobile-tasks-refactor-parity.test.tsmobile/src/tasks/use-mobile-tasks-provider-view-projection.test.tsxmobile/src/tasks/use-mobile-tasks-provider-view-projection.tsx
Included review availability: Your plan provides up to 10 included reviews per hour; 3 remain after this review.
| expect(before.issueVisits).toBe(100) | ||
| expect(after.issueVisits).toBe(50) | ||
| // The dropped grouping re-sorted an already sorted 50-issue array: n-1 comparisons. | ||
| expect(before.comparisons - after.comparisons).toBe(input.items.length - 1) |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
Remove the engine-specific sort-count assertion.
countLinearWork counts calls to the comparator passed to Array.prototype.sort. The JavaScript specification does not guarantee that count. The groupingCalls and issueVisits assertions already verify the duplicate grouping reduction.
Proposed fix
- // The dropped grouping re-sorted an already sorted 50-issue array: n-1 comparisons.
- expect(before.comparisons - after.comparisons).toBe(input.items.length - 1)There was a problem hiding this comment.
Important
The new parity-hash regeneration is correct for this branch's base, but main has since rewritten the same test and this branch now conflicts on mobile/src/tasks/mobile-tasks-refactor-parity.test.ts. Rebase and regenerate rather than keeping these values.
Reviewed changes
- Regenerated refactor parity hashes —
67726aedupdatesPRE_REFACTOR_SCREEN_HOOKSandPRE_REFACTOR_STATEMENTSinmobile-tasks-refactor-parity.test.tsto match thelinearBoardSectionsmemo edit from the previous commit; the other five constants are unchanged. - Verified the parity suite passes 6/6 at
67726aed, withmobile/node_modules/typescriptsymlinked to the repo's[email protected]and a stubbedexpo/tsconfig.base.json(mobile deps are not installed in this checkout).
⚠️ Parity constants are stale against main and the file conflicts
This branch is based on cf7ce05827…, where the constants were still named PRE_REFACTOR_*. main has since landed #20233 and #20249, which rewrite the same file: every constant is renamed to EXPECTED_*, four values change (SCREEN_HOOKS, STATEMENTS, DECLARATIONS, SEMANTICS), and a comment is added. A three-way merge conflicts on exactly the constant block at lines 19-25. Because both sides edit those lines, resolving the conflict by keeping this branch's side would revert main's rename and baseline updates, and the two values regenerated here are also computed without main's source changes. Rebase onto main, keep the EXPECTED_* naming and values, and regenerate only the constants that diverge after the rebase.
Technical details
# Rebase and regenerate refactor parity hashes
## Affected sites
- `mobile/src/tasks/mobile-tasks-refactor-parity.test.ts:19` — `PRE_REFACTOR_SCREEN_HOOKS`/`PRE_REFACTOR_STATEMENTS` regenerated against a base `main` has replaced.
- `mobile/src/tasks/mobile-tasks-refactor-parity.test.ts:19-25` — conflict block vs `origin/main` (renamed to `EXPECTED_*`; `DECLARATIONS`/`SEMANTICS` values and counts also changed).
## Evidence
- `git merge-base origin/main HEAD` = `cf7ce05827…`; `origin/main` has `a045af3618` and `701dc2211c` on this file after that.
- `git merge-file -p --diff3 HEAD <base> origin/main` exits 1 with a conflict spanning lines 19-25.
- `origin/main` also adds `// Task and Linear sort tests cover computation changes; render/style guards remain.`
## Required outcome
- After rebasing onto `main`, the `use-mobile-tasks-provider-view-projection.tsx` edit should move only the hook/statement hashes on top of `main`'s `EXPECTED_*` constants, without dropping `main`'s rename or its other baseline updates.
## Suggested approach (optional)
- Rebase onto `main`, run `cd mobile && vitest run src/tasks/mobile-tasks-refactor-parity.test.ts`, and update only the constants that actually diverge.DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
Rebasing onto main surfaced two breakages that the earlier ratchet-only fix could not have caught, because it was computed against a base main had already superseded: - The parity oracle called compareLinearIssues, which #20249 deleted in favour of sortLinearIssues. Rewrote the oracle to use sortLinearIssues, matching what the production memo now calls, and dropped the stale mock override. - Regenerated EXPECTED_SCREEN_HOOKS and EXPECTED_STATEMENTS from an observed run on the rebased tree. Arity assertions (350 hooks, 417 statements) unchanged. mobile/src/tasks: 37 files, 295 tests pass.
67726ae to
af1a312
Compare
|
Rebased onto current The earlier ratchet-only fix regenerated hashes against Rebasing then surfaced a second, more substantive breakage the ratchet fix could not have caught: the parity oracle called
Also worth recording, since an earlier pass of mine got this wrong: this PR and #20314 are not duplicates. They optimize orthogonal halves of the same expression — this one removes a duplicate |
There was a problem hiding this comment.
✅ No new issues found.
The prior must-address concern — the branch conflicted with main on the refactor parity file and carried stale baseline values — is resolved. HEAD is now rebased onto main (5127d1eb is an ancestor of af1a312958), the file adopts main's EXPECTED_* naming and values, and only the two hashes the source edit actually moves are regenerated. I re-ran both mobile test files locally and they are green.
Reviewed changes
- Rebased onto current
main—af1a312958replays the branch on5127d1eb, so the refactor parity file no longer conflicts and the conflict-resolution problem from the previous review is gone. - Regenerated only the moved parity baselines —
EXPECTED_SCREEN_HOOKSandEXPECTED_STATEMENTSwere recomputed for thelinearBoardSectionsmemo edit;EXPECTED_DIFF_HOOKS,EXPECTED_DECLARATIONS,EXPECTED_SEMANTICS,EXPECTED_STYLESandEXPECTED_RENDER_TREEkeepmain's values. The length assertions (350 / 417 / 192 / 3,500 / 35,195) are unchanged. - Adapted the new projection test to
main's sort helper — the oracle now calls the sharedsortLinearIssues(issues, orderBy)instead of the removedcompareLinearIssuescomparator, and themobile-tasks-legacy-foundationmock spreads...linearsosortLinearIssuesis exposed alongside the wrappedgroupLinearIssues.
Verification this run (mobile dependencies are not installed in the checkout, so this used the repo vitest 4.1.11 with mobile/vitest.config.ts, mobile/node_modules/typescript symlinked to the pinned [email protected], a stubbed expo/tsconfig.base.json, and [email protected] deduped to the repo's react):
vitest run src/tasks/mobile-tasks-refactor-parity.test.ts→ 6 passed.vitest run src/tasks/use-mobile-tasks-provider-view-projection.test.tsx→ 17 passed.
The production diff in this PR is unchanged from the version previously approved, and both consumers of the shared sections remain read-only.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

What
useMobileTasksProviderViewProjectiongrouped the same pre-sorted Linear issue list twice perrender: once for the list sections and once for the board columns. For every grouping except
none, those two calls receive identical arguments and produce identical sections, so the boardnow reuses
linearIssueSections.nonekeeps its ownstatusgrouping, because the listcollapses to a single "Issues" section while the board still needs one column per status.
Six lines changed in
mobile/src/tasks/use-mobile-tasks-provider-view-projection.tsx; the memobody becomes a ternary and
linearIssueSectionsjoins its dep array.Behavior preserved
Sections, their order, keys, labels, colors, and per-section issue order are asserted equal to the
pre-change implementation (kept verbatim inline in the test as an oracle) across all five groupings
x three orderings. The
nonebranch is byte-identical to the old code, including its separateboard grouping. The new dep
linearIssueSectionsis a strict function of the three deps alreadypresent, so there is no added or missed invalidation.
The one observable difference is that
linearBoardSectionsandlinearIssueSectionsare now thesame array object when grouping is not
none. Both consumers are read-only:mobile-tasks-linear-list.tsxmaps over them, and the hook flat-maps them into
linearListEntries. A search overmobile/srcfound the only write to
section.issuesis the build-timepushinsidegroupLinearIssuesitself; no
sort,splice, orreverseon a section anywhere. A test asserts section shapes areunchanged after
linearListEntriesis built.Measurement
Operation counts for one mount with 50 grouped issues, from a real React mount measured against the
inline pre-change oracle. Instrumented with a wrapping
groupLinearIssuesplus a scopedArray.prototype.sortcomparator counter. Command:Byte-identical across three consecutive runs. With
none, all three counts are unchanged(2 / 100 / equal), which is asserted.
Two caveats on these numbers:
2 -> 1grouping calls and100 -> 50issue visits are engine-independent.n - 1because the removed pass re-sorted an already-sorted arrayunder V8's TimSort in Node. The app itself runs Hermes, whose sort is a different algorithm, so
the shape of that delta does not transfer to the device.
316 -> 267is a 15% cut of thecomparisons in the measured window, not a halving — most of the remainder comes from the
linearIssuesForViewsort, which this PR does not touch.These are operation counts. They are not time, CPU, latency, throughput, or heap.
Tests
New
mobile/src/tasks/use-mobile-tasks-provider-view-projection.test.tsx: 17 cases, 415 lines,react-test-renderer, matching the existing mobile hook-test idiom. Coverage: board/list array
identity per grouping,
noneseparation, full parity against the oracle for every grouping xordering, grouping transitions, order transitions, unrelated rerenders, list/board view switches,
refreshed-but-equal arrays, non-mutation, and the differential counts.
Does CI run this? Yes — with one live caveat you should know before trusting it.
.github/workflows/mobile.yml(jobverify) triggers on any PR touchingmobile/**and runspnpm testwithworking-directory: mobile. That resolves tovitest runagainstmobile/vitest.config.ts, whoseincludeissrc/**/*.test.tsandsrc/**/*.test.tsx. Thisfile matches. (
config/vitest.config.tsis the desktop suite and covers onlysrc/**,config/scripts/**andtests/**— mobile has its own separate runner, not a missing one.)pnpm install --frozen-lockfile, failsat HEAD. I reproduced it on a pristine temp copy of HEAD's own
mobile/package.json,pnpm-lock.yaml,pnpm-workspace.yamlandpatches/, under both the repo-pinned pnpm 12.0.0and pnpm 10.33.2:
ERR_PNPM_LOCKFILE_CONFIG_MISMATCH ... "patchedDependencies" configuration doesn't match the value found in the lockfile— even though all three patch sha256s match thelockfile byte-for-byte. This is pre-existing on HEAD and unrelated to this PR, but if it also
reproduces on the GitHub runner then the Mobile Checks job never reaches its Test step and this
file is effectively local-only until the lockfile is repaired. I could not verify the runner's
behavior (no CI runs inspected). Do not assume this test is guarding the change in CI until
you have seen a green Mobile Checks run on this PR.
mobile/tsconfig.jsonsets"exclude": ["**/*.test.ts", "**/*.test.tsx"], sopnpm typecheckskips every mobile test file, this one included. That is adeliberate repo-wide posture —
mobile/vitest.config.tssetsoxc: { tsconfig: false }with acomment naming exactly this reason — not something this PR introduces, but it does mean a type
error in this file would surface only as a runtime test failure.
Local commands and results:
cd mobile && vitest run src/tasks/use-mobile-tasks-provider-view-projection.test.tsx-> 17 passed (1 file).are the parity and
nonecases, which are supposed to hold either way.oxlint --config mobile/.oxlintrc.json src/tasks/-> exit 0 (oxlint does lint test files).oxfmt --check-> clean. Nomax-linesdisable and no per-file bump added.Trimmed from the first draft: dropped a label/color self-consistency case already subsumed by the
oracle parity check, and dropped three parameterized repeats of the comparator-delta assertion,
which restated an engine-specific invariant without adding independent coverage. 441 -> 415 lines,
21 -> 17 cases.
ELI5
The tasks screen bucketed your Linear issues into groups twice in a row and threw one copy away —
like alphabetizing the same deck of cards twice and only using the second result. Now it does the
work once and hands the same stacks to both the list view and the board view. The single case where
the two views genuinely need different stacks — "no grouping", which is a flat list but still has
status columns on the board — still does its own separate pass. You will not perceive any
difference: nothing looks different, nothing moves faster in a way you could notice, and no setting
changes. This is invisible tidying, not a speed-up you can feel.
Merge risk
Low. Blast radius is the Linear list and board on mobile; nothing else imports these values. The
riskiest line is
: linearIssueSections— the branch that hands the list's array to the board. Ifthe reasoning were wrong (a consumer mutates a section, or the two groupings were not actually
identical for some grouping) the two views would corrupt each other's contents or show wrong
columns, which would show up immediately as duplicated or missing issues, or a wrong column header,
on the Linear tab. The memo body is self-contained, so revert is a one-hunk change.
The real residual risk is not the code, it is the evidence: see the CI caveat in Tests.
User-facing trade-offs
None identified. What justifies that:
implementation for all 5 groupings x 3 orderings.
confirming both are read-only.
noneasserted unchanged in both output and operation counts.allocated per render, and no new retention, since the board now points at an object the list
already holds instead of keeping a second copy alive.
What is unproven:
step at HEAD.
mobile pnpm typecheckandmobile pnpm lintwere never run as CI runs them, because the mobilelockfile does not install. Lint was run directly with the mobile oxlint config; typecheck would
skip this file regardless.
visits) are structural, but the comparator numbers are Node/V8 only.
Limitations
The test suite was run with the repository's root vitest 4.1.11 binary against
mobile/vitest.config.ts, withreactand[email protected]symlinked into thegitignored
mobile/node_modulesplus anexpo/tsconfig.base.jsonstub, becausepnpm install --frozen-lockfilefails at HEAD (see Tests). That is the same config and the samevitest major CI would use, but it is not a full mobile dependency tree.
The comparator count is measured by patching
Array.prototype.sortduring the measured window, soit reflects V8's TimSort; the asserted
n - 1invariant would need revisiting on another engine.All counts come from a single fixture of 50 issues with a fixed field distribution, so they do not
characterize large workspaces.
This PR removes the duplicate grouping pass only. The projection still re-groups from scratch
whenever
items, the grouping, or the ordering change — that cost is unchanged.