Skip to content

fix(mobile): Stabilize native stack option updates#4037

Open
juliusmarminge wants to merge 5 commits into
pingdotgg:mainfrom
juliusmarminge:codex/pr3910-stack-options
Open

fix(mobile): Stabilize native stack option updates#4037
juliusmarminge wants to merge 5 commits into
pingdotgg:mainfrom
juliusmarminge:codex/pr3910-stack-options

Conversation

@juliusmarminge

@juliusmarminge juliusmarminge commented Jul 16, 2026

Copy link
Copy Markdown
Member

Extracted from #3910.

Avoids redundant native-stack setOptions updates during busy thread renders, preventing the PreventRemoveProvider maximum-update-depth failure. Includes the matching patched-dependency lockfile update.

Validation inherited from #3910: vp check and mobile native lint passed before the split. The full typecheck is currently blocked in this workspace by unavailable mobile dependencies (expo-blur, expo-quick-actions, and @tabler/icons-react-native).

Note

Stabilize native stack option updates to prevent redundant navigation.setOptions calls

  • Adds optionsSignature to produce a stable string fingerprint of an options object, handling primitives, functions (via source), arrays, and objects with cycle detection and stable key ordering.
  • Adds stabilizeOptionFunctions to replace function-valued options with stable wrapper references that always delegate to the latest implementation, preventing reference churn on re-renders.
  • In NativeStackScreenOptions, computes a signature of the stable options on each render and skips calling navigation.setOptions if the signature matches the previously applied one.
  • Behavioral Change: navigation.setOptions is now a no-op when options are semantically unchanged; function options are passed as persistent wrapper references rather than new closures each render.

Macroscope summarized f3d9691.


Note

Medium Risk
Changes navigation header update timing for all native-stack screens; incorrect signature or wrapper logic could leave stale headers or miss legitimate option updates.

Overview
Stops redundant navigation.setOptions on busy thread screens by treating semantically equal header options as unchanged, addressing PreventRemoveProvider maximum-update-depth failures during re-renders.

NativeStackScreenOptions now builds stable option objects via stabilizeOptionFunctions (stable wrapper identities for inline header factories while still calling the latest closures) and compares an optionsSignature (deep structural hash with function source text and refs ignored) before applying. setOptions runs only when that signature changes, not on every layout pass from fresh object literals.

The @react-navigation/native-stack patch lockfile hash is updated to match the current patched dependency artifact.

Reviewed by Cursor Bugbot for commit f3d9691. Bugbot is set up for automated code reviews on this repo. Configure here.

juliusmarminge and others added 2 commits July 16, 2026 10:54
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 1de05edb-24eb-414e-b422-3300504b150c

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
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@github-actions github-actions Bot added the vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. label Jul 16, 2026
@github-actions github-actions Bot added the size:S 10-29 changed lines (additions + deletions). label Jul 16, 2026
Comment thread apps/mobile/src/native/StackHeader.tsx Outdated
@juliusmarminge juliusmarminge marked this pull request as ready for review July 16, 2026 09:25
@macroscopeapp

macroscopeapp Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved

...

You can customize Macroscope's approvability policy. Learn more.

Co-authored-by: codex <codex@users.noreply.github.com>
@github-actions github-actions Bot added size:M 30-99 changed lines (additions + deletions). and removed size:S 10-29 changed lines (additions + deletions). labels Jul 16, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is ON, but it could not run because the branch was deleted or merged before autofix could start.

Reviewed by Cursor Bugbot for commit f356466. Configure here.

Comment thread apps/mobile/src/native/StackHeader.tsx
Co-authored-by: codex <codex@users.noreply.github.com>
@github-actions github-actions Bot added size:L 100-499 changed lines (additions + deletions). and removed size:M 30-99 changed lines (additions + deletions). labels Jul 16, 2026
Comment thread apps/mobile/src/native/StackHeader.tsx
Co-authored-by: codex <codex@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant