fix(mobile): the split-view sidebar no longer crashes in an update loop#21867
Fixes #21866.
Problem
On an unfolded Android foldable, opening a thread's inspector in split view crashes the sidebar with Maximum update depth exceeded ("The sidebar couldn't be displayed").
#21133 left AdaptiveWorkspaceLayout's baseLayout, layout, fileInspector, and panes to the React Compiler. The compiler can't memoize them because they stay live across later hook calls, so the compiled component rebuilds all four on every render. That gives the workspace context a new value on every render, which then loops:
- The thread screen's
useRegisterWorkspaceInspectorregisters its inspector, which sets layout state. - The layout re-renders and publishes a new context.
- The thread screen re-renders, passes a new inspector renderer, and registers again.
One inspector open produced about 100 back-to-back registrations. The sidebar re-renders on every pass and its LegendList throws first.
Fix
AdaptiveWorkspaceLayoutmemoizes the four derivations again, with the dependencies they had before #21133. A comment says why the compiler can't.ThreadNavigationSidebarmemoizesprojectScopes,projectTitleByProjectKey,projectByKey, andthreadSearchMatchByKeyagain, which #21145 also left to the compiler. They reachLegendListasextraData, so a fresh copy on each sidebar render re-rendered every row. This alone doesn't stop the loop, but it is the same compiler gap and the reason every pass reached the list.
Mobile lint allows memo hooks (allowMemoHooks), and both files still compile under the React Compiler.
Why this qualifies as a small focused fix
It's one regression: derived values the compiler can't memoize, in the two components the loop runs through. Both changes restore the memoization those files had before #21133 and #21145.
Verification
On the Android 17 Pixel 9 Pro Fold emulator, unfolded, with the showcase Moonbase fixtures, opening a thread, then opening and closing the inspector:
- Bisect: the commit before #21133 never loops, and #21133 loops on every run. Restoring only the old
AdaptiveWorkspaceLayout.tsxstops it. - This branch, rebased on
b20f55248d: 0Maximum update deptherrors in fresh sessions, wheremainhits it every time. extraData: an instrumented build showed the sidebar'sextraDatachanging on every render onmain(35 times during one inspector open), against 2 real changes with this branch.- Checks:
vp run typecheckinapps/mobilepasses.vp linton both files reports the same warnings asmain.reactCompilerCoverage.test.tspasses (878 tests).
#20813 also edits the layout, fileInspector, and panes calls, adding the rail width, and keeps them unmemoized. Whichever lands second needs a small conflict resolution and should keep the memoization, adding navigationRailWidth and width to the dependencies.
Before / After
Android 17 Pixel 9 Pro Fold emulator, unfolded, demo data. Each run opens a thread, then opens and closes the inspector.
Before (main) | After (this branch) |
|---|---|
| External image | External image External image |
Opening the inspector ends in Maximum update depth exceeded. | The inspector opens and closes, and the sidebar comes back. |
| Video | Video |
Model: Claude Opus 5.5 | Harness: Claude Code in T3 Code
Checks
Added 2 commits
Approvability
Verdict: Approved at 4b89f48
Macroscope's review found this PR approvable — This is a focused mobile bug fix that memoizes existing layout and sidebar derivations to stabilize context and list inputs, preventing the reported update loop and reducing unnecessary rerenders. It introduces no new capability, schema, infrastructure, security, billing, or static-analysis configuration changes.
You can add or adjust custom eligibility rules. Learn more.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
- Configuration used: Path: .coderabbit.config.ts
- Review profile: CHILL
- Plan: Advanced
- Run ID:
a0f37abe-ba80-45b7-9d5f-5ccd70e40939
📥 Commits
Reviewing files that changed from the base of the PR and between 034b50616165fc25195e25bfddb188639bfefa34 and 4b89f488c90b92e6611fc1b860fe74dc8dea47c7.
📒 Files selected for processing: 2
apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsxapps/mobile/src/features/threads/ThreadNavigationSidebar.tsx
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
📝 Walkthrough
The mobile workspace layout now memoizes derived layout objects. The thread navigation sidebar now memoizes search-match and project lookup data using their source inputs.
Changes: Adaptive workspace layout
Layer / File(s) Summary Memoize workspace layout derivations
apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsxThe base layout, hinge-aligned layout, file inspector, and panes are memoized with relevant input dependencies. Thread navigation sidebar
Layer / File(s) Summary Memoize sidebar lookup data
apps/mobile/src/features/threads/ThreadNavigationSidebar.tsxSearch-match data and project scopes and lookup maps are memoized using their source data and relevant filter inputs. Priority: ➖ Normal
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix · Severity of issue fixed: Medium
Suggested reviewers:
juliusmarminge
Merge Risk: ⚪ Minimal · up to 4b89f
This change restores memoization to stop the Android split-view inspector update loop. It does not change layout or filtering logic. No actionable merge-blocking risk was found.
Pre-merge checks: Passed 4
Check name Status Explanation Description check Passed The description is complete and directly matches the required template. It explains the problem, fix, scope, linked issue, verification results, UI evidence, and agent details. Title check Passed The title clearly and concisely describes the main fix: preventing the mobile split-view sidebar from crashing in an update loop. Linked Issues check Passed The PR addresses the coding requirement in #21866.AdaptiveWorkspaceLayoutContentmemoizesbaseLayout,layout,fileInspector, andpanes, which stabilizes the workspace context inputs used du…Out of Scope Changes check Passed The diff changes only AdaptiveWorkspaceLayout.tsxandThreadNavigationSidebar.tsx. The added memoization and comments directly support the#21866update-loop fix and sidebar rendering stability. N…Full details: Linked Issues check
Explanation
The PR addresses the coding requirement in
#21866.AdaptiveWorkspaceLayoutContentmemoizesbaseLayout,layout,fileInspector, andpanes, which stabilizes the workspace context inputs used during inspector registration.ThreadNavigationSidebarPanememoizes the four derived maps passed through sidebar rendering andLegendListextraData. The reported unfolded Android verification shows the inspector opens and closes without update-depth errors. The reportedapps/mobiletypecheck and React Compiler coverage test also pass.
Full details: Out of Scope Changes check
Explanation
The diff changes only
AdaptiveWorkspaceLayout.tsxandThreadNavigationSidebar.tsx. The added memoization and comments directly support the#21866update-loop fix and sidebar rendering stability. No unrelated behavior or files are included.
✨ Finishing Touches
🧪 Generate unit tests (beta)
- 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.