Skip to content

Give bottom sheets half and full stops with content drag - #996

Merged
ivanfenenko merged 2 commits into
mainfrom
feature/sheet-detents
Nov 8, 2026
Merged

ivanfenenko merged 2 commits into
mainfrom
feature/sheet-detents

Conversation

@ivanfenenko

@ivanfenenko ivanfenenko commented Nov 8, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

The bottom sheet on both apps now behaves like iOS's native .presentationDetents([.medium, .large]) (Hex Code's Medium sheet): two resting heights, expand and collapse, drag from the content, no jumps. Behaviour only: content, header, buttons, navigation, keyboard handling and styling are unchanged, and the public API is the same, so no call site changed.

How it works on both platforms:

  • One value drives the sheet: its visible height. Between the stops the sheet takes that height; below its lowest stop it slides down instead of squashing.
  • Two stops for scrollable sheets: half height (the existing half detent) and full height (the window less the top inset and the 8 dp/pt gap, the height FitAllContent and keyboard Expand already used). Every sheet opens at half.
  • Release rules: flick up (over 900 dp/s or pt/s) goes to full; flick down goes from full to half, and from half closes; otherwise the sheet settles on the nearer stop, and closes when let go below 60 % of half. Reduce Motion / Remove animations snaps.
  • Drag from the content: pushing the body up grows the sheet to full before the body scrolls; pulling down with the body at its top shrinks the sheet and can close it. A release mid-way settles with the finger's speed and the body does not also fling. A drag that starts on a row never taps that row.
    • Android: a NestedScrollConnection on the body (OpenCodeBottomSheetDetents.kt).
    • iOS: a UIKit pan on the sheet's root, running alongside the body's scroll pan (OpenCodeBottomSheetBodyDrag.swift). Once the card reaches full, the same drag keeps scrolling the body.
  • Accessibility: TalkBack and VoiceOver get an Expand or Collapse action on the sheet title whenever it has two stops.
  • The old header-drag rule (96 dp/pt or 1,200 dp/s, down only) is gone; the header now drags both ways with the same rules.

Decisions

  • Which sheets get half and full: Half sheets, and FitContent sheets once their content passes the compact limit (Filter by project, model and agent pickers, shell output, activity, feedback, playground). This is Hex Code's Medium behaviour.
  • Short choice sheets keep fitting their content (FitContent while compact, e.g. Session actions, and FitAllContent, e.g. Timeline style). They have one stop at their content height, so they only drag down to close. Giving an action menu that fits a half or full stop would add empty space and change how it looks. A FitAllContent sheet taller than the screen rests at full with one stop, as before.
  • No jump when content arrives: a compact sheet's height also comes from the one height value, so content that grows or shrinks animates, and a FitContent sheet whose content grows past the compact limit slides from its compact height to half instead of snapping.
  • Keyboard handling is kept as it was on each platform. Keep stays at its resting height and is capped at the room above the keyboard only when it is at full (it would otherwise run under the status bar). Expand fills the room above the keyboard from either stop, shrinking from full. On iOS a Keep sheet's half stop is still half of the space the keyboard leaves, as before.
  • Tablets: the floating card gets the same two stops; its width and corner radii are unchanged.

Checks

  • iOS and Android both covered
  • Screenshots for UI changes: attached in a comment, captured against the committed store-screenshot fixtures (seeded fixture server on iOS, fixture profile on the Android emulator)
  • Tests run
    • Android: testDebugUnitTest 3,415 tests, 0 failures (new OpenCodeBottomSheetDetentsTest for settle rules, stops, nested-scroll handover; keyboard-height tests updated). OpenCodeBottomSheetTest instrumented on an emulator: 15/15, including 5 new tests (header drag half → full → half, body drag grows before scrolling and collapses at the top, flick down from half closes, Expand/Collapse actions, no action on a compact sheet). ktlintCheck and lintDebug report only findings that already exist on main.
    • iOS: OpenCodeBottomSheetDetentTests (new, 21), OpenCodeBottomSheetHeightTests (40), OpenCodeBottomSheetFollowTests (7) all pass; xcodebuild build and analyze succeed. A full OpenCode MobileTests run had failures only in MessageSyncTests and ProjectFilesRepositoryTests under heavy machine load; both pass when run alone.
    • scripts/check-string-keys.mjs passes (new bottom_sheet.expand / bottom_sheet.collapse).
  • Checked by hand on the Android emulator and the iOS simulator: Filter by project opens at half, a body drag starting on a row expands it to full, a header or body drag down returns it to half, a flick down from half closes it without tapping the row under the finger, a plain tap on a row still selects it (iOS), and the compact Session actions sheet ignores an upward drag, springs back from a short pull and closes on a longer one.

Risks / Follow-ups

  • Not checked by hand: hardware keyboard Tab/Escape and TalkBack/VoiceOver on a device (covered by the existing focus and Escape tests and the new accessibility-action test), the tablet floating card, and keyboard Keep/Expand at full height (covered by unit tests).
  • iOS: a drag that starts while a settle animation is still running picks up from the animation's end value, so the card can jump slightly. A drag on the pinned footer does not move the card (as on Android).

🤖 Generated with Claude Code


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

ivanfenenko and others added 2 commits November 8, 2026 20:07
The sheet now behaves like iOS's medium and large detents (Hex Code's
Medium sheet). One value, the visible height, drives it: a scrollable
sheet opens at half height and drags to full height (the window less the
top inset and gap), back to half, or closed. Below its lowest stop it
slides down instead of shrinking.

- Release rules: a flick up expands, a flick down drops from full to
  half and from half closes; otherwise the nearer stop, and below 60 %
  of half height it closes.
- The body hands drags to the sheet through nested scroll: pushed up,
  the sheet grows to full before the body scrolls; pulled down at the
  body's top, it shrinks and can close.
- Compact FitContent and FitAllContent sheets keep one stop at their
  content height and only drag down. Their height comes from the same
  value, so content that grows or turns scrollable animates instead of
  jumping.
- Keep caps a full-height sheet to the room above the keyboard, and
  Expand fills that room from either stop.
- TalkBack gets Expand and Collapse actions on the title.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The custom sheet overlay now behaves like the native medium and large
detents, with the same rules as Android: a scrollable sheet opens at
half height, drags to full height, back to half, or closed, and below
its lowest stop it slides down instead of shrinking.

- Release rules shared with Android: flick up expands, flick down drops
  from full to half and from half closes, otherwise the nearer stop;
  below 60 % of half height it closes. Reduce Motion snaps.
- A UIKit pan on the sheet's root hands body drags to the card: pushed
  up, the card grows to full and the same drag then scrolls the body;
  pulled down at the body's top, the card shrinks or closes. It runs
  alongside the rows' own recognizers and cancels a row's press once
  the card takes the drag, so dragging a list never taps a row.
- Compact sheets keep one stop at their content height and only drag
  down; a compact sheet whose body grows past the compact limit slides
  to half instead of jumping, and other content changes animate.
- Keyboard handling stays as it was: a Keep sheet's stops come from the
  space above the keyboard, and Expand fills that room from either stop.
- VoiceOver gets Expand and Collapse actions on the title.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ivanfenenko

Copy link
Copy Markdown
Collaborator Author

Sheet detents on the real apps, against the committed store-screenshot fixtures (Filter by project is a Half sheet; Session actions is a compact FitContent sheet).

Step iOS Android
Opens at half ios half android half
Body drag up (started on a row) → full ios full android full
Drag down → back to half, no row tapped ios half again android half again
Compact sheet: an upward drag leaves it as is; a long pull down closes it ios compact android compact

Android, flick down from half closed the sheet:

android closed

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Automated review: no finding that 2+ of 1 passes agreed on.

4 finding(s) from a single pass, not posted
  • android/app/src/main/java/dev/opencode/mobile/ui/components/chrome/OpenCodeBottomSheetDetents.kt:112 medium: Expandable threshold disagrees with iOS, splitting one-stop vs two-stop behavior (muse-spark-1.3-contributor)
  • android/app/src/main/java/dev/opencode/mobile/ui/components/chrome/OpenCodeBottomSheetDetents.kt:230 low: Fling handed to body leaves sheet just below full without snapping (muse-spark-1.3-contributor)
  • ios/OpenCode Mobile/OpenCode Mobile/Components/Chrome/OpenCodeBottomSheetBodyDrag.swift:251 low: Body pan recognizes simultaneously with any recognizer, not just body/row gestures (muse-spark-1.3-contributor)
  • ios/OpenCode Mobile/OpenCode Mobile/Components/Chrome/OpenCodeBottomSheetBodyDrag.swift:242 low: Body pan gates on instantaneous velocity instead of direction of movement (muse-spark-1.3-contributor)

opencode pr-review · passes: muse-spark-1.3-contributor, glm-5.3-flash, deepseek-v4.1-flash · $0.093 · 2 pass(es) failed

@ivanfenenko
ivanfenenko merged commit 3e487d1 into main Nov 8, 2026
@ivanfenenko
ivanfenenko deleted the feature/sheet-detents branch November 8, 2026 21:47
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