Repository navigation
Conversation
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — This is a localized mobile bug fix that stabilizes existing split-view inspector registration across navigation focus changes and removes duplicate path normalization. It does not introduce new capabilities, schema changes, production configuration, or static-analysis overrides. You can add or adjust custom eligibility rules. Learn more. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
2b90c4b to
0c3d401
Compare
Dismissing prior approval to re-evaluate 0c3d401
0c3d401 to
4e3e322
Compare
|
Closing in favour of #25197, which makes the same change. Thanks for the work here! |
Note
🤖 Claude Opus 5.5 on behalf of Oliver
Problem
In split view, a screen that shows a workspace inspector (thread Files/Git, file screen) deactivates and re-registers it on almost every render. Each re-registration writes
{ render, active: true }into layout state, so the whole workspace layout re-renders again while a turn streams.There are two causes:
useRegisterWorkspaceInspector: perf(mobile): home, workspace layout and overlay pieces compile with the React Compiler #21133 passed an inline callback touseFocusEffect, and that callback calls auseEffectEventfunction. An effect event changes identity on every render, so the compiled callback changes on every render too.useFocusEffectre-runs when its callback changes, which means a deactivate and a register on every render. Effect events are only meant to be called from inside effects, not used as an identity anything depends on. This was the re-register half of the loop in [Bug]: Android split-view sidebar crashes with "Maximum update depth exceeded" after the inspector opens #21866. fix(mobile): the split-view sidebar no longer crashes in an update loop #21867 stopped the context churn, which ended the crash, but not this.ThreadFileScreen:relativePathcame from a plain call,normalizeRoutePath(params.path). The compiler can't tell that its result is never mutated, so it treats it as live while it's passed to later functions, and that range crosses several hook calls. The compiler prunes any scope that spans a hook, so one pruned block took 24 values with it,renderInspectoramong them. A newrenderInspectormeant a new inspector renderer on every render, and the hook's[wrappedRender]effect re-registered each time.Change
focusandblurevents in a plainuseEffectkeyed on[navigation], and calls the effect event only inside those listeners. Nothing depends on the effect event's identity anymore. Unmount cleanup moved into the same effect. I didn't useuseIsFocused, because react-native-screens freezes blurred screens, so a screen that has to re-render to notice a blur would leak its pane.useThreadFilesWorkspacenow resolvesrelativePathalong with the rest of the route's workspace. A hook's return value is frozen, so nothing spans the later hooks, and the compiler cachesrenderInspectorwithout any manual memo.There's no
useMemo,useCallback, or stable-callbackuseState/useRef. The hook still re-registers when the inspector's content changes, because that's how the pane gets new content.Scope and approval
This is a small, focused fix for a regression from #21133, and it finishes the loop fix from #21866 / #21867. It touches only the registration hook and the file screen. It changes no behavior and no UI.
Validation
Compiler output (repo babel config, the same setup as
reactCompilerCoverage.test.ts):mainThreadFileScreenmemo blocksThreadFileScreenpruned blocks (values)useRegisterWorkspaceInspectorNothing new bails out in either file. The registration effect's dependency array is now just
[navigation].useThreadFilesWorkspacekeeps the 1 pruned block it already has onmain.Registration counts (jsdom). I compiled the real hook source with the React Compiler, mounted it under a workspace host and a mock navigation object, and rendered the registering screen 20 times:
mainBlur, a render while blurred, refocus, and unmount behave the same on both: blur deactivates once, nothing registers while blurred, and refocus registers once. These harness numbers replace the earlier iPad simulator counts, which were measured on the previous version of this fix.
Checks:
reactCompilerCoverage.test.tspasses (894 tests).vp run typecheckinapps/mobilepasses.vp linton both files reports the same 3 warnings asmain.ThreadRouteScreen's own inspector renderer still changes whenever the thread does. That's a separate cause, and this PR doesn't change it.Claude Opus 5.5 via Claude Code in T3 Code