Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

fix(mobile): keep edge swipe from leaving the agent pager

tony1766e3d7c3af
diff --git a/mobile/lib/phone/agent_swipe.dart b/mobile/lib/phone/agent_swipe.dart
index bf65f9903..2edb8a7f0 100644
--- a/mobile/lib/phone/agent_swipe.dart
+++ b/mobile/lib/phone/agent_swipe.dart
@@ -185,9 +185,11 @@ class _AgentSwipeHostState extends State<AgentSwipeHost> {
return PageView.builder(
controller: controller,
// The terminal below scrolls vertically and selects text only with a mouse, so the horizontal
- // axis is free. The one gesture still competing for it is the route's own edge-swipe back,
- // which wins at the left margin because it is registered above this in the tree — deliberately
- // kept: that is how a page goes back on iOS, and the page slides out the way it came in.
+ // axis is free — and here it is the pager's ALONE. The route's own edge-swipe back used to
+ // compete for it and win at the left margin, being registered above this in the tree: a drag
+ // started near the edge to reach the previous AGENT left the screen instead. The route is
+ // pushed without that gesture now (see `phoneRoute`'s `swipeToGoBack`), so going back is the
+ // header's back band, or Android's back button.
physics: const PageScrollPhysics(),
// No count is what makes it endless: the builder answers for any page, and the modulo below
// wraps it back onto the list. A one-agent list keeps its single page instead — see
diff --git a/mobile/lib/phone/phone_navigation.dart b/mobile/lib/phone/phone_navigation.dart
index 740b756ec..6f80e6a3d 100644
--- a/mobile/lib/phone/phone_navigation.dart
+++ b/mobile/lib/phone/phone_navigation.dart
@@ -9,9 +9,33 @@ import 'agents_page.dart';
import 'link_page.dart';
import 'machine_swipe.dart';
-/// Every phone page slides in the iOS way, and goes back with the edge swipe.
-Route<void> phoneRoute(WidgetBuilder builder) =>
- CupertinoPageRoute<void>(builder: builder);
+/// Every phone page slides in the iOS way, and goes back with the edge swipe — unless
+/// [swipeToGoBack] is off, which is how a page that wants the horizontal axis for itself keeps it.
+Route<void> phoneRoute(WidgetBuilder builder, {bool swipeToGoBack = true}) =>
+ swipeToGoBack
+ ? CupertinoPageRoute<void>(builder: builder)
+ : _NoSwipeBackRoute<void>(builder: builder);
+
+/// A phone page that slides and animates exactly like every other one, but cannot be dragged away
+/// from the left edge.
+///
+/// ⚠️ **It turns off the GESTURE only, and that distinction is the whole point.** `popGestureEnabled`
+/// is read by `_CupertinoBackGestureDetector` and by nothing else, so every other way out still
+/// works untouched: the header's chevron and its back band (`Navigator.maybePop`), Android's back
+/// button and predictive-back (which go through `popDisposition`), and a page popping itself — the
+/// terminal page does exactly that when its pane disappears.
+///
+/// Used by the agent pager, where the horizontal drag belongs to the pager. The edge swipe and the
+/// PageView were competing for the same axis: the route's detector sits ABOVE the pager in the tree
+/// and wins at the left margin, so a swipe started near the edge to reach the previous AGENT left
+/// the screen instead. Only the header now goes back, which is what the whole band across the top is
+/// widened for.
+class _NoSwipeBackRoute<T> extends CupertinoPageRoute<T> {
+ _NoSwipeBackRoute({required super.builder});
+
+ @override
+ bool get popGestureEnabled => false;
+}
/// Where a tap on a machine goes. A machine this device holds no link to opens on ITS password
/// form — each machine has its own remote password — and only a linked one opens on its agents.
@@ -93,6 +117,9 @@ void openAgent(
agentId: agentId,
neighbours: swipeNeighbours,
),
+ // The horizontal axis belongs to the pager here — see [_NoSwipeBackRoute]. The way out is the
+ // header's back band, and on Android the back button as well.
+ swipeToGoBack: false,
),
);
unawaited(_openPane(notifier, machineId, agentId, keepOthers: swipeNeighbours != null));