Skip to content

perf(mobile): reuse unchanged tool rows during chat sync - #12759

Closed
robertnisipeanu wants to merge 3 commits into
pingdotgg:mainfrom
robertnisipeanu:fix/mobile-sync-load
Closed

robertnisipeanu wants to merge 3 commits into
pingdotgg:mainfrom
robertnisipeanu:fix/mobile-sync-load

Conversation

@robertnisipeanu

@robertnisipeanu robertnisipeanu commented Sep 20, 2026 •

Copy link
Copy Markdown

Tool updates in a large mobile conversation rebuild unchanged work-log rows and repeatedly scan historical command output. This adds CPU work to live sync and invalidates rows the feed could reuse.

Cache derived activities by their immutable source objects, merged tool lifecycles by both inputs, and rendered activity rows by the derived entry. Weak keys allow unused history to be collected. Replaced activities and changes to loaded history still recompute their rows.

Validation: 140 focused tests, mobile typecheck, and targeted lint/format checks pass. The row-stability regression test fails on the base revision. The reviewed shipping diff is unchanged after native verification.

A wholly synthetic workload was exercised in the native iOS Release client on an iPhone 17 Pro simulator running iOS 26.5. With more than 100 invented thread summaries and a selected history of 500 tool calls, 100 scripted client-side activity updates reduced median feed derivation time from 258.76 ms to 4.06 ms. Both builds used the same temporary timing probe and fixture; the probe is not included in the change. This measures feed derivation inside Hermes, not whole-app CPU, network streaming throughput, or physical-device battery life. An earlier standalone synthetic Mac benchmark also verified equivalent serialized output.

The change affects the iOS/Android mobile feed; Android native behavior was not exercised. There is no intended visual change. Physical iPhone thermal/battery impact and the reported black-screen/reconnect symptom remain unverified; this PR addresses the measured feed-processing hotspot. All published fixtures and measurements are synthetic.

Created with GPT-6 Astra in Codex.

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

macroscopeapp Bot commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at b3eb122

Macroscope's review found this PR approvable — This is a focused mobile-feed performance optimization that reuses unchanged derived and rendered work-log rows while recomputing changed activity inputs. It adds targeted regression coverage without changing APIs, product defaults, deployment behavior, or other sensitive paths.

No code changes detected at c80e307. 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

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: fdb362b5-8529-4dc8-b2f1-d9bb73646566

📥 Commits

Reviewing files that changed from the base of the PR and between 1b2b99d and c80e307.

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: 1609be4f-72ef-4cc4-b869-7d361d7c5d9d

📥 Commits

Reviewing files that changed from the base of the PR and between b3eb122 and c5e083f.

📒 Files selected for processing (2)
  • packages/client-runtime/src/work-log/presentation.test.ts
  • packages/client-runtime/src/work-log/presentation.ts

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


📝 Walkthrough

Walkthrough

The PR adds WeakMap memoization to thread activity derivation and expands tests for identity and pagination behavior. It also guards exit-code failure checks and adds tests for failure markers and legacy field combinations.

Changes

Thread activity and tool failure handling

Layer / File(s) Summary
Memoized derivation pipeline
apps/mobile/src/lib/threadActivity.ts, apps/mobile/src/lib/threadActivity.test.ts
WeakMap caches reuse derived activity entries, merged work entries, and thread feed activity entries. Tests verify stable row identity, affected-row recomputation, and correct merge results when pagination changes activity records.
Guarded failure detection
packages/client-runtime/src/work-log/presentation.ts, packages/client-runtime/src/work-log/presentation.test.ts
Exit-code regex checks run only when normalized text contains exit code. Tests cover long successful output, non-failure markers, and failure phrases split across legacy fields.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Refactor

Suggested reviewers: juliusmarminge

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly summarizes the primary change: reusing unchanged mobile tool rows during chat synchronization.
Description check ✅ Passed The description explains what changed, why it changed, validation results, performance measurements, scope, and known limitations. It does not reproduce the template headings or checklist, but the req…
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

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

@robertnisipeanu robertnisipeanu changed the title perf(mobile): reuse unchanged tool rows during chat sync perf(client): reduce large thread feed processing Sep 20, 2026
@robertnisipeanu robertnisipeanu changed the title perf(client): reduce large thread feed processing perf(mobile): reuse unchanged tool rows during chat sync Sep 20, 2026
incognitojam added a commit to incognitojam/styal that referenced this pull request Sep 25, 2026
After Android resumes an open thread, synchronizing a large backlog can
stall the UI. Upstream has merged `pingdotgg#11302` and `pingdotgg#8309` for related
replay work and has `pingdotgg#12759` open for mobile feed processing, but the
fork's intake report did not call them out.

Track all three with focused reasons so the upstream lag report keeps
their status visible. This records related work; it does not change app
behavior or establish the cause of the reported blank screen.

Validation: parsed the tracking JSON, confirmed the entries are unique
and sorted, and generated the upstream tracking report. It reports
`pingdotgg#8309` and `pingdotgg#11302` as pending and `pingdotgg#12759` as open.

---
Written by an agent (Codex, GPT-6).
@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:M 30-99 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