Skip to content
Source
Sign inSign up
pingdotgg/t3code

perf(mobile): stop menu fault logging and whole-list re-renders on Home #24646

Mergedjuliusmarmingemerged 4 commits intomain fromrefs/pull/24646/headmerged by juliusmarminge View on GitHub

juliusmarmingecommented

Opening a workspace tab for the first time felt slow, and Home kept re-rendering its whole thread list while nothing was happening. Profiling on the iPhone Duo simulator found three causes, all already on main.

Menu actions without an icon logged a CoreUI fault each

Fabric sends a menu action's missing image as "". @react-native-menu/menu tried UIImage(systemName: ""), then UIImage(named: ""), and every empty asset lookup logged a CoreUI fault with a backtrace: thousands per session, and about 50 ms of main-thread work while the Pull requests tab first mounts, since its filter menus build many actions. Our existing patch now treats an empty image as no image. 2.0.0 is still the latest release and has the same code.

This changes native code, so it needs a new native build.

Home rebuilt its whole thread list on unrelated renders

Home and the thread sidebar built their list inline and recorded inbox returns as a side effect during render. The React Compiler could cache none of it: the list's inputs stayed open to mutation across the screen's other hooks. So every render of Home rebuilt the list, re-rendered every visible row and re-registered the thread jump shortcuts. Home re-renders whenever the connection status flips, every few seconds, and when you leave the Chats tab.

  • useThreadListV2 builds the list for both screens, so its result reaches them as one cached value.
  • The inbox tracker's observe returns a fixed lookup per observation and runs only when the threads change.
  • The row select handler no longer depends on the rebuilt layout or on Home's whole props object.

Measurements

iPhone Duo simulator, dev build, Chats tab idle, render timings from React's per-fiber durations:

CommitsFull-list re-rendersRender time
Before, 40 s69221278 ms
After, 70 s571322 ms

The remaining full-list commit is the once-a-minute snooze-menu clock, which every row legitimately shows. Leaving Chats for another tab no longer re-renders the Chats list.

Production bundle on the same simulator, cold switch to Pull requests: main-thread view creation went from about 85 ms to about 20 ms, and CoreUI "Invalid asset name" faults from thousands per session to 0.

Verification

  • vp run check:changed passes, and the React Compiler coverage test, home and threads suites (1171 tests).
  • The tracker's test covers the new contract: an earlier observation's lookup keeps its answer.
  • Compiled output checked: the layout, list items and Home's select handler sit behind cache checks.
  • Not measured: iPad and iPhone, and a streaming turn. Thread rows now re-render only when their own item changes, which is what a streaming turn needs.

Claude Opus 5.5 in Claude Code, running in T3 Code.

🤖 Generated with Claude Code

    1. github-actions[bot](GitHub profile, opens in a new tab) added labels📱 Native Change

    2. Approvability

      Verdict: Approved at 18fc403

      Macroscope's review found this PR approvable — This is a bounded mobile performance fix that centralizes existing thread-list construction, stabilizes row callbacks, snapshots inbox ordering, and skips empty native menu image lookups. It changes rendering efficiency and native fault logging without introducing new product capability, schema changes, or product-default changes.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    3. Thread transfer impact

      ✅ Thread transfer remains within every enforced ceiling.

      ProviderMetricMain baselineThis PRImpactPR ceiling
      CodexTotal thread wire5.0 KiB5.0 KiB0 B (0.0%)6.8 KiB✅
      CodexThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      CodexLive turn WebSocket wire1.2 KiB1.2 KiB0 B (0.0%)2.0 KiB✅
      CodexLive turn WebSocket decoded20.9 KiB20.9 KiB0 B (0.0%)29.3 KiB✅
      CodexLive turn messages220 (0.0%)8✅
      ClaudeTotal thread wire5.0 KiB5.0 KiB0 B (0.0%)6.8 KiB✅
      ClaudeThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      ClaudeLive turn WebSocket wire1.2 KiB1.2 KiB0 B (0.0%)2.0 KiB✅
      ClaudeLive turn WebSocket decoded21.2 KiB21.2 KiB0 B (0.0%)29.3 KiB✅
      ClaudeLive turn messages220 (0.0%)8✅

      Baseline: 6548c00 · PR result: 18fc403 · Source CI: success

      Scenario and decoded snapshot size

      10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

      • Codex decoded thread snapshot: 108.5 KiB
      • Claude decoded thread snapshot: 108.8 KiB

      Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

    4. Review in Change Stack →

      No actionable comments were generated in the recent review.

      Recent review info
      Run configuration
      Commits

      Reviewing files that changed from the base of the PR and between 6548c006d429e7242ebc10c34946420418a276ec and 18fc403714dcc03a86301fbb09909bb56f7ab594.

      Files ignored due to path filters: 1
      • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
      Files selected for processing: 6
      • apps/mobile/src/features/home/HomeScreen.tsx
      • apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx
      • apps/mobile/src/features/threads/useThreadListV2.ts
      • packages/client-runtime/src/state/threadInbox.test.ts
      • packages/client-runtime/src/state/threadInbox.ts
      • patches/@react-native-menu__menu@2.0.0.patch

      Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

      Walkthrough

      The home screen and navigation sidebar now use useThreadListV2 to build thread lists. Inbox-return observations now provide snapshot-based timestamp lookups. The iOS menu patch also changes menu presentation, action conversion, and image lookup behavior.

      Changes: Thread List Construction

      Layer / File(s)Summary
      Inbox return timestamp snapshots
      packages/client-runtime/src/state/threadInbox.ts, packages/client-runtime/src/state/threadInbox.test.ts
      observe now returns a timestamp lookup based on a snapshot of the tracker state. Tests check that lookups from earlier observations retain their original results.
      Shared thread-list hook
      apps/mobile/src/features/threads/useThreadListV2.ts
      The new hook builds the thread-list layout and items, filters pending tasks, computes move availability, and returns content-only thread keys.
      Home screen integration
      apps/mobile/src/features/home/HomeScreen.tsx
      The home screen uses the hook’s layout, items, and content-only keys for selection and search-match handling.
      Sidebar integration
      apps/mobile/src/features/threads/ThreadNavigationSidebar.tsx
      The sidebar uses the hook’s layout, items, and content-only keys. It appends a show-more row when the settled shelf is expanded and hidden items remain.

      iOS Menu Patch

      Layer / File(s)Summary
      Native menu behavior updates
      patches/@react-native-menu__menu@2.0.0.patch
      The patch adds menu interaction-start events, updates menu presentation while menus are active, serializes an additional action level, assigns stable submenu identifiers, and adds iOS 15+ submenu subtitles. Image lookup skips empty names.
      Priority: Normal

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

      Change: Bug fix

      Suggested labels: bugfix, 📱 Native Change

      Suggested reviewers: t3dotgg, maria-rcks

      Merge Risk: Minimal · up to 18fc4

      The supplied evidence does not establish a merge-blocking issue; the reported checks still need their normal validation before merging.

      Pre-merge checks: Passed 3 · Failed 1
      Failed Failed checks: 1 warning
      Check nameStatusExplanationResolution
      Description checkWarningThe description explains the problem, implementation, measurements, verification, and limitations. It omits the required Scope and approval section and does not include the required before/after UI ev…Add a Scope and approval section with the related issue or explicit maintainer approval, or explain why this focused fix qualifies for an exemption. Add clear before/after screenshots for the UI performance changes.
      Passed Passed checks: 3 passed
      Check nameStatusExplanation
      Title checkPassedThe title clearly identifies both primary changes: stopping menu fault logging and preventing unnecessary whole-list re-renders on Home.
      Linked Issues checkPassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes checkPassedCheck skipped because no linked issues were found for this pull request.
      Full details: Description check

      Explanation

      The description explains the problem, implementation, measurements, verification, and limitations. It omits the required Scope and approval section and does not include the required before/after UI evidence.

      Resolution

      Add a Scope and approval section with the related issue or explicit maintainer approval, or explain why this focused fix qualifies for an exemption. Add clear before/after screenshots for the UI performance changes.

      Finishing Touches
      📝 Generate docstrings
      • Commit to this branch
      • Create a new PR
      🧪 Generate unit tests (beta)
      • Commit to this branch
      • Create a new PR
      • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
      Comment `@coderabbitai help` to get the list of available commands.
    5. juliusmarminge merged this62eb35b

    6. juliusmarminge closed this

Sign in to join this conversation.