Skip to content

feat(mobile): drag sheets to close with position-only motion - #425

Merged
nixuuu merged 1 commit into
devfrom
feat/mobile-sheet-gestures
Nov 9, 2026
Merged

nixuuu merged 1 commit into
devfrom
feat/mobile-sheet-gestures

Conversation

@nixuuu

@nixuuu nixuuu commented Nov 9, 2026

Copy link
Copy Markdown
Member

Updates and every mobile sheet can now be dragged down from their grabber or header. The shared surface enters, settles and exits by position only; only the backdrop fades. Compact pickers, confirmations and full-height forms share the same spring and dismissal lifecycle on iOS and Android, including wide-window cards.

The gesture follows downward travel 1:1, adds diminishing upward resistance, and dismisses after 28% of the measured height or a downward fling of at least 900 dp/s after 8 dp. It preserves release velocity, returns interrupted/short drags, and prevents a late touch event from overwriting an exit. Shared close buttons, backdrop taps, accessibility actions and Android back finish the exit before notifying a parent that may unmount the sheet. The first drag with an open keyboard dismisses the keyboard; another drag moves the sheet. Reduced motion makes automatic positioning instant.

Coverage: Overlay, PickerSheet (models, effort, permissions, projects, workers, thread actions and attachment menus), confirmations, Updates, connection/update details, goal/side-thread/queued-message forms, and all SheetSurface forms/details. Full-screen image/text/file viewers retain their own viewer behavior.

Scope and limitations

  • JS/TS only. No dependencies, app config, native modules, generated native projects or runtime policies changed. No app build, OTA publication, device/simulator run or UI tests.
  • Content scroll views keep native scrolling. With the installed modules, PanResponder cannot reliably take over an active native ScrollView at offset zero on both platforms without responder conflicts or a jump. Dragging is deliberately limited to the grabber and marked header areas.
  • PanResponder delivers touch events on JS. Gesture math, shared values, styles and springs run on the UI thread without React renders per move. No device FPS measurements were possible; a blocked JS thread can still delay touch delivery.

Validation

  • Passed: bun install, bun run gen:check, bun run typecheck, bun run lint, bun run format:check, and bun run --filter @canopy/web build.
  • Passed: bun test tests/integration/mobile-sheet-gesture.test.ts — 3 focused math tests, 27 assertions, covering dismissal distance/velocity, the rubber-band curve and re-grabbing without a position jump.
  • Passed: Expo ESLint over every changed mobile file. The additional whole-app Expo lint reports existing hook-rule violations in untouched attachment, settings and state files; they are outside this change.
  • Full-suite results are not clean locally; the unstable baseline failures and clean targeted reruns are recorded below. No gateway, worker, package or existing test code changed.

Unstable baseline tests on the shared host

This machine is shared by several agents. Timing-sensitive integration tests failed under concurrent load (host load exceeded 60). The files below are unchanged by this feature, and every affected file passed a targeted rerun. These reruns support the load-related explanation but do not establish a clean full-suite result. Per maintainer authorization, CI on isolated runners is the full-suite gate for this PR.

Full-suite attempt Observed result
bun run check:tmp 1904 passed, 161 skipped, 13 failed, 3 errors; 2078 tests across 343 files, 1693.25 s.
bun run check:tmp --timeout 30000 1916 passed, 161 skipped, 1 failed; 2078 tests across 343 files, 1241.66 s. All failures from the first run passed; only the shell Stop RPC failed.
Third full attempt with --timeout 30000 The same shell Stop RPC failure recurred. Stopped after 629 passing cases because the run was far from completion, following authorization to avoid more full runs. Only the owned checker received SIGTERM; it forwarded shutdown and exited 143 after cleanup. This attempt is incomplete.

All three attempts reported check:tmp: nothing left in the temp dir. No further full runs were started.

Affected files are under tests/integration/:

File Observed full-suite errors
agent-plugins.test.ts Tag reassignment/reinstall exceeded the default 5000 ms test timeout.
agent-skill-sources.test.ts Periodic updates and catalog/subpath/reference discovery exceeded 5000 ms; timed-out teardown also reported Fixture git failed: push and asynchronous errors.
agent-skills-files.test.ts Large concurrent drift-report case exceeded the 5000 ms timeout.
bots-harness-regressions.test.ts Claude routine/wakeup exceeded the 5000 ms timeout.
bots-harness.test.ts Grok missing-session/history retry exceeded the 5000 ms timeout.
config-sync-projects.test.ts Aliased project routing returned gRPC unavailable for the fixture peer; policy propagation failed its 20 s eventual assertion.
linked-timeouts.test.ts Local read took 511.55 ms against a <500 ms assertion; half-open recovery returned missing updates (undefined); stale-read recovery failed a 20 s eventual assertion; BFF request-slot scenario did not observe the expected peer request.
thread-mirror-deltas.test.ts Gap/epoch full/background recovery failed its 20 s cursor-convergence assertion. It passed in the second full run.
composer-shell.test.ts “Stop during a shell steer kills its group and persists the failed delivery” returned ConnectError [canceled] The operation was aborted. around the 10.1 s RPC deadline in attempts two and three. It passed in attempt one.

Clean targeted reruns (all using bun run check:tmp --timeout 30000):

  1. The seven files from agent-plugins.test.ts through linked-timeouts.test.ts listed above: 80 passed, 0 failed, 6591 assertions, 221.49 s.
  2. tests/integration/composer-shell.test.ts: 17 passed, 0 failed, 72 assertions, 14.94 s.
  3. tests/integration/thread-mirror-deltas.test.ts: 12 passed, 0 failed, 88 assertions, 22.71 s.

Every targeted rerun also confirmed the temporary directory was clean. The current isolated rerun has finished; no test run remains active.

Fingerprint command, run before and after for both platforms from apps/mobile:
bunx [email protected] fingerprint:generate --platform <ios|android> --build-profile production --json --non-interactive

Platform Before After
iOS 2a0ef03a2a0fda8e7fad2e3df8609803d2edbda3 2a0ef03a2a0fda8e7fad2e3df8609803d2edbda3
Android c5c880ae8d0f5d7bc867fcbaf8f756b2ca56a07d c5c880ae8d0f5d7bc867fcbaf8f756b2ca56a07d

Manual checks required on iOS and Android

These are not performed: the installed clients cannot run this checkout. Check both light/dark themes, phone width and a wide/foldable window.

  1. Open Updates, then close separately with ✕, backdrop tap and Android back. Reopen repeatedly. The surface must remain opaque, slide fully below the screen edge, and dim/undim only the backdrop. Check the same behavior in model/effort/project/permissions pickers, attachment menus, thread actions, connection details and a full thread/bot details sheet. Use short and long titles; check safe areas, rounded corners and seams.
  2. Drag both grabber and header slowly. Release below and above 28% of the sheet height; try a short downward fling. Short drags spring back; long drags/flings continue down with finger velocity. Drag upward, reverse direction and grab again during spring-back. Check resistance, continuous position, backdrop tracking, cancellation and Android back while a drag is active. Content must still scroll normally at every offset.
  3. Open searchable model choices and the goal/queued-message forms, focus an input and type. The sheet must stay above its own keyboard. Drag once to close only the keyboard, release, then drag again to close the sheet. Return to the composer and verify draft, choices, typing and interactive keyboard behavior remain intact.
  4. Choose an attachment action that opens the photo library/document picker. Verify the native picker opens once, after the menu has disappeared. Check Updates → Open update settings and thread actions → Rename/Goal likewise. Rotate/fold with a sheet open and verify it remains reachable.
  5. With VoiceOver/TalkBack, activate the grabber's Close action and existing close controls; test the accessibility escape gesture where supported. Enable reduced motion and repeat opening, closing, dragging and spring-back: no automatic spring/slide should play, and dragging must still work. Inspect interaction smoothness on 60/120 Hz hardware.

Copy audit (docs/copy.md §8)

Before: a decorative, unlabeled grabber. After: button label/action Close, with hint Drag down to close. The action starts with a verb; the hint has four words, sentence case and a period. The control has a spoken action and does not rely on its shape or position. Existing contextual close labels remain unchanged. No new errors, statuses, glossary terms or decorative text. The new fixed strings cannot truncate; surrounding short/long titles retain existing wrapping rules. Device checks of VoiceOver/TalkBack and visual layout are pending as described above.

Related: #371

@nixuuu
nixuuu merged commit c2fad3a into dev Nov 9, 2026
9 checks passed
@nixuuu
nixuuu deleted the feat/mobile-sheet-gestures branch November 9, 2026 16:28
nixuuu added a commit that referenced this pull request Nov 9, 2026
Dragging from a sheet's grabber or noninteractive header did nothing
after #425, while dragging Updates' refresh button could close it.
Shared chrome only requested the responder on movement; it never
explicitly claimed the initial touch. The handle was also only 28 dp
tall.

This change requests touch start in the **bubbling** phase on the shared
native drag-area View. A descendant Pressable gets first refusal, so
header buttons retain normal taps. Move capture takes over only for one
finger moving more than 6 dp vertically, with vertical travel greater
than horizontal travel. The grabber now occupies a full-width, 44 dp
zone with the visible pill centered and excluded from hit testing.

Acquiring the responder alone does not start a drag. Position work and
keyboard dismissal wait for deliberate vertical movement; a tap or
horizontal movement on plain chrome leaves both alone. The responder
factory remembers whether acquisition happened through move capture
because RN resets `dy` on grant. Existing gesture math, springs, exit
lifecycle, backdrop tracking, keyboard-first dismissal and accessibility
actions are preserved.

Fixes: #425

### Scope and responder review

- Shared `SheetDragArea` forwards handlers directly to a native View.
`SheetSurface`, `PickerSheet`, Updates and every other marked header
inherit the fix without per-screen handlers. The grabber uses the same
path. No gesture handlers were added to scrollable content.
- Inspected the shared surfaces, all grabber/header wiring and #425's
description/diff. The viewport's `pointerEvents="box-none"` leaves
children interactive; the sheet extension is below the surface and has
`pointerEvents="none"`. The existing translucent Android Modal and
safe-area layout remain unchanged.
- Reviewed [RN responder
bubbling/capture](https://reactnative.dev/docs/gesture-responder-system),
[PanResponder lifecycle](https://reactnative.dev/docs/panresponder), and
installed RN 0.88.1's `PanResponder.js` and Fabric responder
implementation. RN supports move negotiation without an existing
responder, so the refresh-button symptom is consistent with missing
initial acquisition on native chrome, rather than proof that move
negotiation always requires a child responder. Physical-device
reproduction was unavailable.
- JS/TS implementation only; no dependencies, native modules, assets,
app config or runtime policy changed. Updated the existing Polish mobile
documentation. No UI copy changed; copy audit is not applicable.

### Validation

- `bun install --frozen-lockfile` and `bun run gen:check` passed.
- `bun test tests/integration/mobile-sheet-gesture.test.ts`: **5 passed,
0 failed, 51 assertions**. Pure decision coverage includes initial
chrome acquisition, control/content exclusion, taps/jitter, vertical
direction and dominance, configurable threshold and multiple fingers;
existing distance/fling/rubber-band/re-grab coverage also passes.
- `bun run typecheck`, `bun run lint` and `bun run format:check` passed.
Expo ESLint passed for all three changed mobile source files.
- `bun run --filter @canopy/web build` passed.
- No full local `check:tmp`, UI tests, device/simulator runs, native
builds or OTA publication. CI is the full-suite gate; the device checks
below remain **unperformed**.

### OTA fingerprint comparison

Generated on clean current `dev`
(`04a871be3b18c4abf15910ec31d0071e69795d73`) before editing and on the
final implementation, from `apps/mobile`, for **both** platforms:

```sh
bunx [email protected] fingerprint:generate --platform ios --build-profile production --json --non-interactive
bunx [email protected] fingerprint:generate --platform android --build-profile production --json --non-interactive
```

| Platform | Current dev | This change |
| --- | --- | --- |
| iOS | `bf3156a1bd878e10c0b0be25d4c194a837fb1b7e` |
`bf3156a1bd878e10c0b0be25d4c194a837fb1b7e` |
| Android | `d638e5f7b7fa87f54ccc0715c5fe150b8c0ad3ae` |
`d638e5f7b7fa87f54ccc0715c5fe150b8c0ad3ae` |

Both runtime fingerprints are unchanged from current dev, including
#424's baseline changes. This supports OTA compatibility with that
runtime.

### Manual checks required on iOS and Android

Run the interaction checks for each applicable sheet in this matrix,
separately on iOS and Android. Include light/dark, a phone and a wide
window, and short/typical/long titles. These are instructions, not
claimed results.

| Sheet family | Coverage |
| --- | --- |
| Choice pickers | Model, effort, project, worker, provider/profile and
permission choices |
| Action menus | Thread actions, queued-message actions, attachment menu
and text actions |
| System sheets | Updates, connection details and gateway-update details
|
| Forms | Goal, side thread, queued-message editor, thread secrets,
search, quote editor and settings inputs |
| Full details | Thread, bot and other details/settings presented
through `SheetSurface`/`Sheet` |

| Interaction | Steps and expected result |
| --- | --- |
| Grabber | Start on the pill, then in the blank area near either side
of its full-width 44 dp zone. Drag slowly down. Each start must move the
sheet; a stationary tap must not start a drag. |
| Header empty area | Start on title text and on blank space in the
header row, away from controls. Move vertically beyond 6 dp. The sheet
must follow; horizontal movement and movement of 6 dp or less must not
begin a drag. |
| Header button drag | In Updates, start on Check now, then drag down
beyond 6 dp with vertical dominance. Repeat on a header close/action
button in a full sheet. The sheet must take over and the button action
must not fire on release. Disabled header controls must not create dead
drag zones. |
| Header button tap | Tap Check now or another enabled header action
without dragging. Its action must run once, with no sheet movement.
Repeat with small finger jitter. Tapping Close must use the normal exit
exactly once. |
| Keyboard open | In a searchable model picker and an editable form,
focus the input and type. A tap on plain chrome must leave the keyboard
alone. The first vertical drag must dismiss only the keyboard and keep
the sheet still for the rest of that touch; release, then drag again to
move/dismiss the sheet. Verify the draft remains intact. |

| Motion/lifecycle | Steps and expected result |
| --- | --- |
| Distance and fling | Without the keyboard, release a slow drag below
28% of sheet height: spring back. Release beyond 28%: dismiss. Fling
down after at least 8 dp at roughly 900 dp/s or faster: dismiss even
below 28%. Once active, slow downward travel must follow 1:1 and the
backdrop must track position. |
| Reversal and interruption | Drag up: bounded rubber-band resistance.
Reverse sharply upward before release: cancel dismissal. Re-grab during
spring-back: no position jump. Interrupt a gesture with OS controls or
Android back: no stuck sheet or stale gesture overwriting an exit. |
| Reduced motion and accessibility | Enable reduced motion: automatic
slides/springs become instant while dragging still works. With
VoiceOver/TalkBack, invoke the grabber's Close action and verify
dismissal; check accessibility escape where available. |
| Scroll and native Modal | Scroll content at the top and midway: native
scrolling must remain independent. Open/close repeatedly and
rotate/fold: no blocked hit areas, safe-area offsets or transparent
seams. On Android verify backdrop tap and back dismissal. |
nixuuu added a commit that referenced this pull request Nov 14, 2026
Android thread cards can lose their Run choice when virtualized, discard
loaded thumbnail URIs when leaving the viewport, and move the feed as
the composer folds. Thread details also share entrance progress with
drag position and have no intermediate resting position.

This change keeps HTML consent and measured heights per visual/version
for the pairing session, uses a compact 112 dp gate, preserves thumbnail
Image instances and synchronously restores cached file URIs on remount,
retains the composer scroll reserve, and separates sheet entrance from
drag offset. Thread details snap fully open or 40% down; dragging beyond
65% closes them. The scroll viewport remains usable at both positions.
Visual resize updates use the existing feed anchor, and Android clipping
no longer detaches native WebViews inside retained inverted cells.
Distant turns remain virtualized. Web behavior is unchanged.

Fixes: #719

The linked regression is specifically the per-mount HTML Run state
introduced in #719; the other behavior is pre-existing. Related: #758,
#419, #425. Rebased onto #758 and retained its notice removal and
`Custom HTML from the agent.` gate label.

### Original recording

Reviewed at 12 fps; timestamps are seconds from the start, with
approximately 0.08 s precision.

| Problem | Evidence | Change |
| --- | --- | --- |
| Tall blank HTML card; Run does not reveal content | 00.00–12.50 and
21.00–24.67; taps around 09.50/10.17 | Compact gate; session consent
across row/slot/fullscreen remounts; explicit non-flex WebView sizing;
token-validated height updates and anchored resize. Failure/watchdog
revokes consent, so failed code does not automatically run again. |
| Composer flips between compact/full | 01.00–01.50, 06.17–06.50,
10.75–11.17, 22.75–23.17 | Folding no longer releases the native list
reserve; only active finger travel can change fold state, and expansion
requires deliberate travel toward the end. Momentum interrupted by a tap
cannot inherit drag intent. |
| Details sheet jumps/rebounds; content also shifts | Opening
12.83–13.33; dragging 13.75–20.75; inner content 18.25–18.83 | Explicit
surface height and seeded modal safe areas; separate entrance/drag
values; two resting positions; bottom-only scroll viewport resize and no
native scroll bounce. Re-grabbing an opening/settling sheet retains its
position. |
| Thumbnail disappears and reloads | 22.00–24.17 | Visibility cancels
unfinished work without clearing a loaded URI. Cache peek restores the
same immutable local URI before the first remount frame, allowing native
decoded bitmap reuse. Existing memory/disk LRU budgets and pairing
cleanup remain in force. |
| Feed displacement during interactions/card changes | 06.17–06.50,
10.75–11.17 | Stable composer reserve; no Android autoscroll-to-zero
threshold; existing disclosure anchor also wraps Run and visible WebView
height changes. The recording alone cannot separate every gesture
movement from layout correction. |

### Validation

- Passed with `nice`: `bun install`, `bun run gen:check`, workspace `bun
run typecheck`, mobile typecheck, repository `bun run lint`, `bun run
format`, `bun run format:check`, and integration-test workspace
typecheck.
- Passed 10 unit tests: existing private image cache and pure sheet
gesture tests, plus session consent isolation/revocation coverage. These
are local unit tests under the existing tests directory; no UI suite or
E2E tests were added or run.
- Additional Expo lint remains failing on existing repository findings:
clean dev has **116 errors / 25 warnings**, this change has **112 errors
/ 25 warnings**. Changed image/watchdog code removes some existing
findings; the remaining Expo failures are not claimed as passed.
- Native fingerprints match clean dev before/after, including explicit
`CANOPY_CHANNEL=nightly`, using `bunx expo-updates fingerprint:generate
--platform ...`. Nightly Android:
`141ef4e8c825ee4fc5d22c499402b284741b0970`; Nightly iOS:
`83794f069934a7374461427d89b8d008cec19d97`. Default-channel Android:
`906dc944f94eb8333fa384ed9f198834fdd30d13`; iOS:
`138e0c6b171c82b4933e86808cdfef56da73b8c6`. No dependencies, native
modules, plugins, or native config changed.
- **Device acceptance is unverified.** T3 device discovery found no
local Android SDK. MacStudio device hub timed out twice (no device
returned). EAS `device_open` failed: “frameAncestors and corsOrigins are
supported on Production and Enterprise plans,” while this account has
Starter. No emulator or physical device could be opened, so first-tap
rendering, Android WebView height/gesture handling, decoded bitmap
retention, snap motion, keyboard transitions, light/dark, and TalkBack
still need device review. No after-shots are claimed. Draft PR preserves
this outstanding gate.

No web files changed; web build was not run. Full
`check:tmp`/integration runs, native prebuilds/exports, EAS
builds/updates, tags, and releases were not run. Original frame strips
are retained outside the repository; raw extracted frames were removed.
No servers, device processes, or reserved ports were used.

### Copy audit (§8)

No new UI wording. `Run`, `Retry`, and `Custom HTML from the agent.`
remain unchanged from #758; no secrets notice was reintroduced. Changes
are session behavior, geometry, cache lifetime, and motion. Device
layout/accessibility checks remain unverified.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant