fix(mobile): give a sideways drag on the terminal to the session swipe alone

The terminal's touch handler and the session swipe judged every gesture separately, so a sideways flick also ended as a tap on the session being left (a link, a CLI click, a keyboard toggle) or as a vertical scroll. The terminal now locks the dominant axis past the tap slop, hands a sideways drag it cannot pan to the swipe and publishes the axis, and the swipe stands aside for scrolls, pans, a lift the terminal consumed (its selection gesture), touch selections, a second finger and surfaces with controls of their own. A touch that starts outside the terminal resets the published axis, so swiping from the phone home screen into a session keeps working after a terminal scroll. A deliberate swipe gets 500ms instead of 300ms, and vertical drift cancels it mid-gesture instead of only at the lift.
This commit is contained in:
JD committed 2026-10-21 21:40:27 -04:00
1 parent 39077281d1
commit 63cada938d
8 files changed
+221 -28

No files matched your search

+1 -1
View File
@@ -130,7 +130,7 @@ The unified `showKeyboard(page, height, options?)` tries Layer 1 → 2 → 3 aut
| **CDP `Input.dispatchTouchEvent`** | Chromium | `true` | Default for swipe/tap tests |
| **Synthetic `TouchEvent`** | Cross-engine | `false` | WebKit fallback, still triggers handlers |
Swipe simulation includes intermediate move points and timing to satisfy `SwipeHandler` thresholds (≥80px distance, ≤300ms duration, ≤100px vertical drift).
Swipe simulation includes intermediate move points and timing to satisfy `SwipeHandler` thresholds (≥80px distance, ≤500ms duration, ≤50px vertical drift).
### Visual Regression
+3 -3
View File
@@ -68,11 +68,11 @@ export const KEYBOARD = {
CONFIRM_TIMEOUT: 2000,
} as const;
// Swipe constants (match app.js SwipeHandler)
// Swipe constants (match SwipeHandler in mobile-handlers.js)
export const SWIPE = {
MIN_DISTANCE: 80,
MAX_TIME: 300,
MAX_VERTICAL_DRIFT: 100,
MAX_TIME: 500,
MAX_VERTICAL_DRIFT: 50,
} as const;
// Subagent window constants
+2 -2
View File
@@ -420,11 +420,11 @@ describe('Tab Navigation', () => {
expect(log).toEqual([]);
});
it('slow swipe (>300ms) does not trigger navigation', async () => {
it('slow swipe (past the time limit) does not trigger navigation', async () => {
await clearSwipeLog();
await installSwipeSpy();
// Duration exceeds MAX_TIME threshold
await swipeViaCDP(page, 'left', { distance: SWIPE.MIN_DISTANCE + 20, duration: 400 });
await swipeViaCDP(page, 'left', { distance: SWIPE.MIN_DISTANCE + 20, duration: SWIPE.MAX_TIME + 150 });
await page.waitForTimeout(200);
const log = await getSwipeLog();
expect(log).toEqual([]);