Skip to content

perf(mobile): reduce chat feed sorting overhead - #12792

Closed
robertnisipeanu wants to merge 1 commit into
pingdotgg:mainfrom
robertnisipeanu:perf/mobile-feed-sort
Closed

robertnisipeanu wants to merge 1 commit into
pingdotgg:mainfrom
robertnisipeanu:perf/mobile-feed-sort

Conversation

@robertnisipeanu

@robertnisipeanu robertnisipeanu commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

Long mobile chat feeds pay for Date objects and generic tuple comparisons whenever messages update. Sort temporary numeric timestamp keys directly, preserving absolute-time ordering, stable ties, and the existing feed objects without adding a retained cache.

Validation: 109 focused feed tests, mobile package typecheck, targeted lint/format checks, and native iOS Release verification. The added test covers timezone offsets, equal timestamps, and unchanged source arrays.

Synthetic benchmark inside the native app’s Hermes engine: alternating baseline/patch order, four warmups and 40 measured feed rebuilds with a changed message per round. Median time fell from 8.61 to 5.43 ms for 1,000 rows and 50.18 to 31.22 ms for 4,000 rows; serialized output matched throughout. These are feed-computation measurements on an iOS Simulator, not end-to-end loading, physical-phone CPU/RAM, or battery measurements. All published benchmark inputs are invented.

Implemented with GPT-6 Astra (high reasoning) using the Codex harness.

Summary by CodeRabbit

  • Bug Fixes
    • Improved chronological ordering of combined messages and activities across different timezone offsets.
    • Preserved the original order of entries with identical timestamps.
    • Ensured feed generation does not modify the original message or activity lists.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Sep 20, 2026
@macroscopeapp

macroscopeapp Bot commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at b9ecdf4

Macroscope's review found this PR approvable — This is a localized mobile performance refactor that replaces repeated date-object sorting work with cached numeric timestamps while preserving feed ordering and entry reuse. Focused tests cover timezone ordering, stable ties, and input immutability, with no product-default or static-analysis changes.

No code changes detected at 86af057. Prior analysis still applies.

You can add or adjust custom eligibility rules. Learn more.

@coderabbitai

coderabbitai Bot commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

⚙️ Run configuration

Configuration used: Repository: pingdotgg/t3code/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 3548d30b-a4ea-4946-88d1-a845b1d24a0a

📥 Commits

Reviewing files that changed from the base of the PR and between b9ecdf4 and 86af057.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: pingdotgg/t3code/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 2ae794f5-4d1a-4493-8ded-14f224754ba5

📥 Commits

Reviewing files that changed from the base of the PR and between 55c2427 and b9ecdf4.

📒 Files selected for processing (2)
  • apps/mobile/src/lib/threadActivity.test.ts
  • apps/mobile/src/lib/threadActivity.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

buildThreadFeed now precomputes parsed timestamps before sorting. A new test covers timezone offsets, equal-time ordering, and preservation of the input arrays.

Changes

Thread feed timestamp sorting

Layer / File(s) Summary
Timestamp sort and validation
apps/mobile/src/lib/threadActivity.ts, apps/mobile/src/lib/threadActivity.test.ts
buildThreadFeed uses Date.parse and numeric comparison for ascending chronological order. Tests cover mixed timezone offsets, stable ordering for equal timestamps, and non-mutating behavior.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Refactor

Suggested reviewers: t3dotgg

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: reducing mobile chat feed sorting overhead.
Description check ✅ Passed The description explains the change, rationale, performance results, validation, and benchmark limitations. It does not use the template headings or include the checklist, but the required information…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

Comment @coderabbitai help to get the list of available commands.

@juliusmarminge juliusmarminge added the macroscope-review Opt PRs made by unvouched contributors in for Macroscope review. Vouched contributors auto-reviews label Oct 1, 2026 — with ChatGPT Codex Connector
@juliusmarminge

Copy link
Copy Markdown
Member

Thanks for working on this. We merged the orchestrator V2 rewrite in #2829, and we are closing this PR as part of that transition.

The patch conflicts with the rewrite in apps/mobile/src/lib/threadActivity.ts. Even where the conflict is small enough to rebase, we are asking for fresh PRs against the new base so we can review and verify the behavior in V2.

Sorry for the extra work this creates. If the change is still needed on V2, please rebuild it on current main, verify it there, and open a new PR linking back here. We're closing the current implementation without assuming the underlying request is resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

macroscope-review Opt PRs made by unvouched contributors in for Macroscope review. Vouched contributors auto-reviews size:S 10-29 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants