Repository navigation
perf(mobile): precompute task sort keys and reuse repository collation - #20233
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: 📒 Files selected for processing (5)
Included review availability: Your plan provides up to 10 included reviews per hour; 4 remain after this review. 📝 WalkthroughWalkthroughThe change replaces separate mobile task comparators with Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to The sorting refactor is covered by parity and behavior tests with no actionable regression identified. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description is detailed and covers the change, rationale, testing, visual impact, review notes, and checklist. However, the required Linked Issue section explicitly states that no issue was supplied, and the template requires one.
✨ 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
Replaces the two exported task comparators with a single key-precomputing sortMobileTaskItems, updates the picker memo to call it, adds focused behavioral/call-count tests, refreshes the refactor-parity fingerprints for the deliberate change, and checks in a benchmark script that asserts output parity against the baseline implementation.
sortMobileTaskItems(mobile-tasks-repository-presentation.ts) — decorates each item once with its parsed timestamp and (for repository order) repository label, sorts with a single hoistedIntl.Collator(undefined, { sensitivity: 'base' }), then returns the original task references. The<2early return mirrors the old[...items].- Picker projection (
use-mobile-tasks-picker-projection.tsx) — theuseMemobody delegates to the helper with unchanged dependencies. - Tests — new
mobile-task-sort.test.tspins ordering parity, immutable input, recompute-on-repo-change, and per-item call counts;mobile-tasks-refactor-parity.test.tsrenamesPRE_REFACTOR_*toEXPECTED_*and updates four hashes plus two counts for the deliberate computation change. - Benchmark —
config/scripts/mobile-task-sort-benchmark.mjsloads the baseline file at the given ref and the current file, assertsdeepEqualordering, and reports counterbalanced timings plusDate.parsecounts.
The comparator rewrite is behaviorally exact: (collator?.compare(...) ?? 0) || b.updatedAt - a.updatedAt reproduces the old labelCompare || updatedCompare, and the array is stable, so ties keep input order. The removed comparator exports have no remaining consumers.
ℹ️ Collation equivalence is asserted on V8, not Hermes
The parity test and benchmark both run under Node/V8 while the shipping engine is Hermes. The Intl.Collator this PR switches to is supported on Hermes in RN 0.83 / Expo 55 (Hermes builds with HERMES_ENABLE_INTL on both platforms, and String.prototype.localeCompare routes through the same native Collator::create/compare), so the ordering is unchanged and nothing needs to change here. Noting it only because CI would not catch a future engine-level divergence between the two APIs.
openrouter/deepseek/deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

ELI5
Mobile task sorting now computes dates and repository labels once for each task instead of recomputing them each time two tasks are compared.
What Changed
Replace the two comparator exports with
sortMobileTaskItems, called from the existing memo with unchanged dependencies. Decorate tasks with their timestamp and, for repository order, their existing repository label; reuse one current-locale/base-sensitivity collator, then return original task references in sorted order. Empty and singleton inputs still return a fresh array without key setup.Why
The previous repository comparator repeatedly built metadata (including badge-color hashing), resolved optioned locale collation, and parsed timestamp ties. The update-order comparator repeatedly parsed dates as well.
Counterbalanced Node 24/macOS benchmark, ten samples per arm, synthetic tasks already sorted by update time across 25 repositories. Full output parity is asserted against the actual baseline comparator exports at
20ab9950654.At 1,000 tasks, date parses fall from 1,998 to 1,000 for update order and from 4,548 to 1,000 for repository order. At 25 unique repository labels the old repository sort parses no dates and the new sort parses 25; total runtime still decreases. These are helper microbenchmarks, not phone/Hermes latency measurements. The harness resolves the UI dependency barrel's colors export directly to the real theme in both arms so it can run in Node.
Linked Issue
User-requested performance audit; no linked issue supplied.
Visual Proof
N/A — same ordered task references and memo dependencies, with unchanged render/style fingerprints.
Testing
ORCA_BACKGROUND_LAUNCH=1 pnpm --dir mobile test src/tasks— 271 tests in 35 files passed.ORCA_BACKGROUND_LAUNCH=1 pnpm --dir mobile typecheck— passed.node config/scripts/mobile-task-sort-benchmark.mjs 20ab9950654reproduces parity and timing/count evidence.The existing refactor fingerprint suite passed on the unmodified baseline. Four source fingerprints and two counts were updated for this deliberate computation change; hook count, statement count, rendered expressions, diff hooks, and styles retain their existing guards. Constants now say EXPECTED instead of PRE_REFACTOR. Behavioral tests and before/after production comparisons supply the ordering evidence that source hashes alone cannot provide.
Review
Sort keys and collator are per-call, with no persistent cache/invalidation burden. All providers continue using
taskRepositoryMetaand the existingtaskTimeinvalid-date fallback. No new Git commands, host execution, RPC fields, filesystem operations, or workspace-kind assumptions; SSH and folder-workspace presentation stay unchanged.Agent skill upstream boundary
Checklist