Repository navigation
fix(mobile): swipe back from a thread on no3y iOS - #452
Conversation
The no3y thread header hides the native navigation bar to draw its own glass bubbles, and UIKit's back-swipe delegate drops every touch while the bar is hidden. The vendored react-native-screens is now a build of NoahHendrickson/react-native-screens no3y/hidden-bar-back-swipe (ca56dc59, on t3.61) whose stack stops forwarding that UIKit hook while the bar is hidden. Screens with a visible bar keep UIKit's behaviour. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
NoahHendrickson
left a comment
There was a problem hiding this comment.
Code quality review of e3c5293c82a36b54bd66bd76c644ff0a6208a75e
I diffed the shipped react-native-screens-5.0.0-t3.61.tgz against the new …-ca56dc59.tgz. They differ only in ios/helpers/stack/RNSStackNavigationController.mm (+3 hunks) and t3-fork.json, as the description says. The fork commit ca56dc59 also changes scripts/pack-t3.mjs, which only updates the provenance URL. The lockfile and package.json changes are mechanical. Every finding below is about the native patch or its docs.
1. The patch adds a mode that three separate sites have to keep in sync. Can we drop the mode?
The fix depends on navigationBarHidden in three places that have to agree:
respondsToSelector:hides_gestureRecognizer:shouldReceiveEvent:only while the bar is hidden. It finds the selector by string comparison on every call.gestureRecognizerShouldBegin:repeats the samenavigationBarHiddencheck to add back the transition guard that UIKit's hook would have applied.- A new
setNavigationBarHidden:animated:override sets both pop recognizers' delegates to nil and back again. It exists only because UIKit caches therespondsToSelector:answer, and that answer now changes over time.
So the delegate now reports different capabilities depending on outside state, and a controller override exists only to make UIKit notice that change. That last part is the most fragile piece. As I read it, the bar also flips while a swipe is in progress (the destination screen's will-appear shows the bar, and a cancelled swipe hides it again). The re-attach therefore runs against a recognizer that is already tracking a touch. The simulator checks passed, but correctness here depends on undocumented UIKit behaviour around re-setting a delegate mid-gesture, which the code never has to rely on if the answer never changes.
The simpler version: make the answer fixed. The delegate never advertises the private hook, and gestureRecognizerShouldBegin: makes the whole decision for every screen:
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
{
RNSStackNavigationController *navigation = self.navigationController;
if (navigation.viewControllers.count < 2 || navigation.transitionCoordinator != nil ||
navigation.topViewController.navigationItem.hidesBackButton)
return NO;
UIViewController *destination = navigation.viewControllers[navigation.viewControllers.count - 2];
if ([navigation shouldPreventNativePopToController:destination])
return NO;
...
}
- (BOOL)respondsToSelector:(SEL)selector
{
static SEL uikitEventHook;
static dispatch_once_t once;
dispatch_once(&once, ^{ uikitEventHook = NSSelectorFromString(@"_gestureRecognizer:shouldReceiveEvent:"); });
return selector != uikitEventHook &&
([super respondsToSelector:selector] || [self.originalDelegate respondsToSelector:selector]);
}This deletes the setNavigationBarHidden:animated: override and the delete-and-reattach of both delegates, along with both navigationBarHidden branches. The behaviour becomes one rule that applies to every screen, and nothing depends on when UIKit reads the delegate. The two guards Sol found missing in round 1 (hidden Back button, transition in flight) become explicit public-API checks instead of side effects of a private hook we sometimes keep.
The cost is real and should be stated plainly: screens with a visible bar would no longer get whatever else UIKit's hook checks beyond those two guards. They would need the same simulator matrix you ran: bar-shown Settings › General, the iPad scheduled-task editor, and a guarded route. If you keep the hook on bar-shown screens deliberately, please say why in the respondsToSelector: comment. Even then, see #2.
2. Run the checks with no side effects before the one that emits an event
shouldPreventNativePopToController: is not a pure check. It calls emitOnNativeDismissPrevented. The new transition guard runs after it, so a hidden-bar swipe during a transition can tell JS "dismiss prevented" and then get rejected for a different reason. That is the nit from Sol's round 2 that was deferred. The fix is to move a one-line guard up two lines, inside the hunk this PR already adds, so it doesn't need a follow-up: return early on transitionCoordinator != nil before asking the controller anything that has side effects. The sketch in #1 already does this.
3. The canonical Screens doc now describes a different tarball
docs/operations/mobile-screens-fork.md is the "Building the mobile Screens dependency" page. In this fork it is now wrong:
- It says the archive comes from
pingdotgg/react-native-screensand that "the app does not patch this package". - It says to bump
5.0.0-t3.N, tagt3-v<version>, and replace the archive.
The new build procedure was added to apps/mobile/deps/README.md instead. Until now that file covered Enriched Markdown only, and it has no headings. Its procedure names the archive by commit hash, keeps the version at t3.61, and doesn't tag. The customizations.yaml thread-header entry is a third copy of the provenance.
A maintainer who follows the doc named after the dependency will rebuild from Julius's fork and silently lose the back swipe. Please keep one source of truth. Either add a short fork note at the top of mobile-screens-fork.md that points to the README paragraph, or give the README a ## react-native-screens heading and link it from that doc. Then trim the customizations.yaml text to the why plus a pointer, the same way the enriched-markdown entry defers to deps/README.md.
Not raised
- The scope widening (every headerless pushed stack screen now swipes back, not just the thread) looks intended.
gestureEnabled: falseroutes are still stopped byshouldPreventNativePopToController:throughpreventedRoutes. - No file-size, layering, or contract concerns. Changing the vendored tarball through its fork, not with a pnpm patch, is the right place for this change.
Verdict: not approving. #1 is a clear chance to replace a three-site mode and a delegate re-attach with one fixed rule. #2 is a one-line reorder. #3 leaves two build procedures for the same tarball that disagree.
NoahHendrickson
left a comment
There was a problem hiding this comment.
Code review: e3c5293c82a36b54bd66bd76c644ff0a6208a75e
No blocking bugs found. I left one small nit about check order, plus a few things that are verified and a few that aren't.
What I checked
- I extracted the old
react-native-screens-5.0.0-t3.61.tgzand the new…-ca56dc59.tgzand diffed them. Onlyios/helpers/stack/RNSStackNavigationController.mmandt3-fork.jsonchanged, as the description says. - Source commit
ca56dc59is public onNoahHendrickson/react-native-screens. Its parent is the old tarball's recorded commit,c213f92b. It changes only that.mmfile (+26) andscripts/pack-t3.mjs, so the tarball matches its source. - Every RNS v5 path that hides the bar goes through
-setNavigationBarHidden:animated::RNSHeaderCoordinator→RNSStackNavigationBarCoordinator, and the split host's hide/show toggle. The override catches all of them, so the cachedrespondsToSelector:answer stays in step with the bar. Calls beforeviewDidLoadreturn early, andviewDidLoadthen attaches the delegates with the current state. gestureEnabled: falseroutes still block.createV5StackNavigator.ios.tsxmaps them topreventNativeDismiss, whichshouldPreventNativePopToController:checks first.
Nit: check the transition before calling shouldPreventNativePopToController:
RNSStackNavigationController.mm:34-38: shouldPreventNativePopToController: has a side effect. It emits onNativeDismissPrevented, and createV5StackNavigator.ios.tsx:176 answers that by calling descriptor.navigation.goBack() for preventRemove routes, which runs the screen's usePreventRemove callback. With the bar hidden, an edge swipe during a push into a guarded screen (for example NewTaskDraftScreen while checkoutPending) now fires that goBack() mid-transition, and only then does the new transition check reject the swipe. Before this change it couldn't happen, because UIKit dropped those touches.
The PR description says this is a follow-up. It's a two-line swap and safe: the new check only runs while the bar is hidden, and on bar-shown screens UIKit's hook already rejects swipes mid-transition before gestureRecognizerShouldBegin: runs. So it could just go in this PR:
if (navigation.navigationBarHidden && navigation.transitionCoordinator != nil)
return NO;
UIViewController *destination = navigation.viewControllers[navigation.viewControllers.count - 2];
if ([navigation shouldPreventNativePopToController:destination])
return NO;Worth knowing (not bugs)
- Scope. The change applies to the whole app, not just the thread page: every v5 stack screen with a hidden bar now has a native back swipe, edge and iOS 26 content pop. I didn't find a screen that relied on the old no-swipe behavior without
gestureEnabled: false(most root pages usepageRoute, which shows the header), but the description only talks about the thread page. - Not tested: a swipe that crosses hidden → shown. For example, a hidden-bar screen above a bar-shown one. Here the delegates are re-attached in the middle of the gesture, when the destination's
willAppearshows the bar. Worth one manual check: cancel that swipe partway, then swipe again, and confirm the second swipe still starts. The verified cases look like hidden → hidden (thread → Threads with bottom nav) and shown → shown (Settings › General). - Not tested: iPad with a trackpad. UIKit's private hook may also filter indirect or scroll events. Without it, while the bar is hidden, a two-finger horizontal trackpad scroll could start a pop. This adds to the iPad/physical-device gap the description already lists.
- Docs.
docs/operations/mobile-screens-fork.mdstill describes only the upstreampingdotggflow (pack:t3,t3-v<version>tags). The newapps/mobile/deps/README.mdparagraph covers the no3y rebuild, so leaving the upstream doc alone is fine for syncs. Anyone following the ops doc alone would just miss the no3y step.
CI was still pending (Build and Typecheck, Test, Test Server shards) at review time.
🤖 Reviewed by Claude Opus 5.5 (claude-opus-5-5) via Claude Code
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Other scenariosAll 64 scenario measurements match All 64 scenario measurements
Baseline: Scenario and decoded snapshot size10 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.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed. |
…ts at it Repacks react-native-screens from af5cf075, which checks the transition before the dismiss guard so a hidden-bar swipe mid-transition never emits onNativeDismissPrevented. The Screens build doc now notes that this fork carries its own build and points to apps/mobile/deps/README.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks for both reviews. Pushed Check order (review 1 #2, review 2 nit): fixed. The hidden-bar transition check now runs before Screens build doc (review 1 #3): fixed. One fixed rule instead of a hidden-bar mode (review 1 #1): not changing. This shape was chosen on purpose:
Still not verified: iPad split view, physical device, trackpad. |
Problem
Inside a thread on the no3y iPhone app, swiping right from the left edge didn't go back to Threads. The no3y thread header hides the native navigation bar to draw its own glass bubbles (#b5ba223541). UIKit's back-swipe delegate has a private event hook,
_gestureRecognizer:shouldReceiveEvent:, that drops every touch while the bar is hidden. react-native-screens wraps that delegate and forwarded the hook, so the swipe never got a touch. I confirmed this on an iOS 27.2 simulator: with the bar shown the swipe works, with it hidden UIKit never asks the delegate anything.Fix
The vendored react-native-screens tarball is now built from a no3y fork:
NoahHendrickson/react-native-screens, branchno3y/hidden-bar-back-swipe(af5cf075, on Julius's t3.61). It is identical to the shipped t3.61 tarball apart fromios/helpers/stack/RNSStackNavigationController.mmandt3-fork.json. I checked this by extracting both and diffing them.onNativeDismissPrevented.shouldPreventNativePopToController:first.apps/mobile/deps/README.md, the thread-header entry in.fork/customizations.yamland a fenced note indocs/operations/mobile-screens-fork.mdsay where the tarball comes from. They also say to rebuild this change on top of any new upstream tarball, otherwise the thread loses its back swipe again.Verification
vp run check:changedpasses: format, knip, typecheck (44 packages), 125 test files / 874 tests.Reviewed with sol-loop: 2 rounds with GPT-6.2 Sol (Codex) on high. Sol verdict: approved.
onNativeDismissPreventedcould fire before the transition check rejects the swipe. Both PR reviews asked for it too, so the checks are now reordered (af5cf075).🤖 Signed: Claude Opus 5.5 (
claude-opus-5-5) via Claude Code🤖 Reviewer: GPT-6.2 Sol (
gpt-6.2-sol, high) via Codex, reviewed the change in two rounds; its two findings were applied