Repository navigation
fix(mobile): move the composer with the keyboard - #359
Merged
Merged
Conversation
nixuuu
marked this pull request as ready for review
November 8, 2026 13:59
nixuuu
added a commit
that referenced
this pull request
Nov 8, 2026
…367) Folding the mobile composer changed the inverted timeline's header after the animation, moving messages independently of the reader's finger. Returning to the end revealed partly clipped controls and then moved the last message again when the reserve caught up. The composer now retains its measured expanded input reserve through both directions. Folding and opening animate only the overlay; the last message already has room throughout opening. Controls get their full row height before fading in and disappear before that height closes. Motion keeps the existing `medium`/`slow` tokens, `smoothOut`, and instant reduced-motion path. Writing still transfers the secondary row's height to the field; attach/model/effort remain available. Fixes: #359 Related: #308 Related: #352 ### Root causes 1. **Reserve changes after the motion.** #308 retained the expanded reserve. #359 changed `animate` to call `settle` in both directions and allowed folded measurements to update `height`. During a fold, `progress` moves from 1 to 0 and `measured.current` becomes the pill height, while the list still reserves the expanded height. The completion callback then clears `moving` and schedules `settle` on JS, which assigns the smaller height to the list header and `ChatKeyboard` offset. Native anchoring/scroll clamping happens in a later layout, outside the finger movement. Opening does the reverse: the overlay grows over the smaller reserve, then the header grows at completion. The new fold completion never assigns reserve height; delayed partial opening measurements cannot shrink the retained reserve. Safe area, keyboard, empty status slots and suggestions remain excluded. The deliberate tradeoff is that a folded input retains only its actual expanded input space until it reopens; this does not restore the former empty status/fade reserve. 2. **Wrong anchor index.** `minIndexForVisible: 1` was intended to skip the reserve, but RN 0.88.1 `VirtualizedList` already adds one for `ListHeaderComponent`. The resulting native index was 2, skipping the newest turn and potentially anchoring a later/offscreen turn while reading a long newest turn. Keep the following-list index at 0 so the native index becomes 1. #358 changed routing/settings, not this geometry. The supplied recording shows the large discontinuity; its exact near-screen magnitude was not instrumented on a compatible client. 3. **Controls painted while their clip was smaller than the row.** `ComposerFold` used the same progress for `height = naturalHeight * progress` and `opacity = progress`. At progress 0.5, a 52 dp toolbar had a 26 dp clip and was already half opaque, while the field and send button were moving. Keep the measured row mounted at its natural size, finish allocating its height over the first 80% of progress, then fade controls over the remaining progress. In reverse, the controls disappear before the clip shrinks. The writing height transfer remains linear. 4. **Scroll corrections could become reader intent.** Opening at `fromEnd <= 8` ran before checking `reader`; `onMomentumBegin` unconditionally enabled reader intent, and travel survived drag boundaries. Thus reserve/anchor scroll events could open the composer and feed offset changes back into fold travel. The suspected loop is supported by the code; a device trace of the recording's individual offsets is unavailable. Keep the 8/192/96 dp hysteresis, reset travel on each drag, consume intent after one transition, and never create intent from momentum alone. Content/viewport/inset changes, keyboard motion, reserve measurements and explicit anchor/programmatic scroll revisions cancel intent until a fresh drag. “Show latest” explicitly expands before scrolling in both thread and bot chat. ### Verification - Passed: `bun install`, `bun run gen:check`, `bun run typecheck`, `bun run lint`, `bun run format:check`, `bunx expo lint` in `apps/mobile`, and `bun run --filter @canopy/web build`. Ran `bun run format` and the approved spacing autofix. No UI tests added, per repository policy. - `bun run check:tmp`: **1817 passed, 161 skipped, 0 failed**, 324 files; exited 0 and reported no test-owned temporary files left. Opt-in live tests were skipped. - Reviewed the supplied Android recording/contact sheets, relevant #308/#352/#358/#359 history, RN's installed header-index adjustment and native anchor code, and the pinned keyboard-controller adapter. The fixed 32 dp fade, keyboard frame handling, safe-area normalization and native dependency/config files are unchanged. - Visual verification is **not completed**. Through T3 device tools, the installed Android client failed with `The package 'react-native-keyboard-controller' doesn't seem to be linked`; the installed iOS client failed with `Cannot find native module 'ExpoUpdates'`. Neither can run the current checkout. Used an isolated Metro port and stopped it; no native/EAS build, APK, OTA publication or dependency change was made. No incompatible-client workaround is included. Physical-device parity, light/dark transitions, reduced-motion behavior and frame-by-frame motion remain to be checked on a compatible runtime. ### OTA fingerprints Generated before and after using EAS CLI **27.4.1**, profile **production**, for each platform: ```text 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 | Before | After | Result | | --- | --- | --- | --- | | iOS | `2a0ef03a2a0fda8e7fad2e3df8609803d2edbda3` | `2a0ef03a2a0fda8e7fad2e3df8609803d2edbda3` | Unchanged | | Android | `c5c880ae8d0f5d7bc867fcbaf8f756b2ca56a07d` | `c5c880ae8d0f5d7bc867fcbaf8f756b2ca56a07d` | Unchanged | ### Manual device checks 1. On compatible Android and iOS runtimes, open a thread with a newest turn taller than the viewport and an empty composer. Drag toward older messages through 192 dp with at least 96 dp travel. Follow a line under the finger: it must move only with the gesture, with no blank frame or extra movement at completion. Repeat with a fling and several shorter drags. 2. Return to within 8 dp of the end. Controls must appear whole at natural size as the composer grows. The last message must remain fully above it, and its position must not change when opening completes. Repeat with slow drags and flings, and use “Show latest”. 3. Make small back-and-forth drags near the bottom during and after opening. One gesture must not reverse a transition. After opening completes, folding again must require a fresh drag reaching the distance/travel thresholds. Repeat while content streams and after toggling a timeline fold; those corrections must not collapse/open the composer on their own. 4. Repeat in light/dark, phone/unfolded widths, and system reduced motion. Include short and long model/worker names. Check typing, a long draft, clearing/sending, attachments, synchronous questions, opening/hiding the keyboard and interactive dismissal. Attach/model/effort must remain usable, the writing handoff must keep its size, and the fade must stay 32 dp. Smoke-check bot chat folding and “Show latest” because it shares the hook. Copy audit: no UI text changed.
nixuuu
added a commit
that referenced
this pull request
Nov 8, 2026
Opening a mobile thread could show `opus`, add the effort and permission controls, then move the last answer while the push was still running. Initialize the composer at its expanded size, preload cached history before list navigation, and keep model/effort slots and the ended-turn footer stable as their values arrive. Fixes: #292 Related: #367 Related: #359 ### Causes and changes 1. **Composer rows and timeline reserve started at zero.** `ComposerFold` measured an absolutely positioned child after mount; until that callback, its clip had height 0. `useFloatingComposer` also initialized the inverted-list reserve to 0. This path was introduced with the floating composer in #292 and remained through #367. Both control rows now start at their expanded heights, and thread screens reserve **186 dp** immediately: input 64 + toolbar 56 + secondary row 36 + gap 8 + padding 20 + borders 2. The toolbar's attach button is 36 dp plus 20 dp padding, so its actual expanded height is 56, despite the old 52 dp minimum. Native measurements still handle real content changes. #367's retained expanded reserve, gesture rules and partial-opening guard remain intact; keyboard motion, safe areas, accessories and the **32 dp fade** remain separate. 2. **Catalog values existed only after a component-local request.** `useModelCatalog` started empty on every mount, `MessageComposer` fell back to `thread.model`, and effort existed only after finding the model's supported efforts. Catalogs now belong to the current paired client, preload from the overview's available workers, share in-flight requests and supply a synchronous external-store snapshot. Model, effort and permission slots retain widths of **160/96/128 dp**. An unavailable catalog shows same-size skeletons; a model without effort leaves its slot empty. The raw thread model id is never the temporary label. The permission pill was already unconditional; allocating its secondary fold's height makes it present from the first frame. 3. **Missing timestamps removed the footer line.** `TurnDetails` returned `null` until both timestamps existed. An authoritative turn update could insert that line underneath an already visible answer. Ended turns now retain the line height while awaiting a duration, matching web's permanent `TurnDetails` row. Existing snapshot encoding already preserves turn timestamps; no protocol or cache-format change is needed. 4. **Disk cache loaded after navigation.** `useThreadSnapshot` can initialize synchronously only from `peek`; a disk-only entry previously arrived from an effect after the push began. Thread-list rows, including side/archived rows, now load that local entry before push/replace. They never wait for network data. Later navigation, another tap or a pairing change invalidates a pending open. Cache misses retain the existing timeline skeleton. `Syncing…` is already an accessory outside the measured composer and list header; its appearance/disappearance changes neither the reserve nor composer position, so it stays there. The supplied recording's frames 37–40 support the label/row/footer sequence. They do not isolate how much of the large jump comes from the footer versus the reserve. No recording, frames, logs or machine-specific paths are included in this change. ### Verification - Passed: `bun install`, `bun run gen:check`, `bun run typecheck`, `bun run lint`, `bun run format:check`, and `bun run --filter @canopy/web build`. Ran `bun run format`. ESLint for every changed mobile file is also clean. No UI tests added. - Final full foreground `bun run check:tmp`: **1,842 passed, 161 skipped, 0 failed**, 327 files, exit 0; **nothing left in the test-owned temp directory**. Opt-in live tests were skipped. Earlier full runs each had 1,841 passed, 161 skipped and one failure: unchanged `linked-list-retention.test.ts:118` (`awayReason(...)` was undefined), then unchanged `config-sync-projects.test.ts:308` (`response.attached` was false). Other agents were running full suites on the same machine with shared memory; load-related timing is suspected. Both tests passed in the final full run. No gateway or test workaround is included. - Both files pass **separately on this branch**, each through foreground `check:tmp`: `linked-list-retention` **1/1**, `config-sync-projects` **11/11**, both with clean temp directories. The maintainer independently reported the same separate-file results on current **`dev`: 1/1 and 11/11**. CI remains the gate; the final full run passed without needing the maintainer's exception for these two load-sensitive failures. - Additional whole-app Expo lint exposes existing errors in unchanged `state/gateway-departure.ts` (`react-hooks/purity`, `react-hooks/set-state-in-effect`) and an existing `react-hooks/exhaustive-deps` warning in `features/updates/state.tsx`. The required root lint and changed-file ESLint pass. - Device verification is **not performed**: installed simulator clients lack native modules required by the checkout. No native/EAS builds, OTA publication or server startup attempted. Root-cause review includes the supplied iPhone frames and the shared iOS/Android implementation; the precise manual checks below remain to be run on compatible clients. **OTA compatibility:** JS/TS and documentation only; no dependencies, native modules or runtime configuration changed. Before and after, from `apps/mobile`, ran `bunx [email protected] fingerprint:generate --platform <ios|android> --build-profile production --json --non-interactive` for both platforms: | Platform | Before | After | | --- | --- | --- | | iOS | `2a0ef03a2a0fda8e7fad2e3df8609803d2edbda3` | `2a0ef03a2a0fda8e7fad2e3df8609803d2edbda3` | | Android | `c5c880ae8d0f5d7bc867fcbaf8f756b2ca56a07d` | `c5c880ae8d0f5d7bc867fcbaf8f756b2ca56a07d` | ### Manual checks on compatible iOS and Android clients 1. Open a completed thread with model alias `opus` from the list. Record the push: the model display name (or reserved skeleton), effort and permission row must already occupy their final slots; composer height and the last answer must remain fixed. Return and reopen, then repeat after restarting the app so the history is disk-only. Repeat offline with cached history, and with a cache miss online. Rapidly tap different threads or navigate elsewhere during a disk read; no delayed extra push should occur. 2. Test native and custom provider profiles, explicit/default effort, models without effort, and unknown models/catalog failures. Use short, typical and long model/worker names at narrow phone and tablet widths. Labels must truncate within their slots and remain accessible; horizontal toolbar scrolling and model/effort/permission pickers must work without moving adjacent controls. 3. Open an ended turn with cached timestamps, then older cached data without timestamps and let it synchronize. A duration must fill its reserved line without moving the answer. Change between connecting, syncing, live and reconnecting; `Syncing…` must not change the list reserve or composer position. Check that the fade remains 32 dp. 4. Repeat #367's folding checks: drag at least 96 dp toward history past 192 dp from the end, then return within 8 dp or tap “Show latest”. No completion jump, clipped controls or programmatic-scroll fold should occur. Test typing, multiline drafts, clearing/sending, attachments, synchronous questions, keyboard open/hide/interactive dismissal, and shared bot-composer folding. 5. Repeat in light/dark, reduced motion, portrait/landscape and larger system text. Confirm the writing handoff retains its height and the last message stays above the composer. Initial size at non-default accessibility font scales still requires device confirmation because native text measurement can exceed the baseline geometry. Copy audit (§8): temporary raw model id → catalog display name or same-size skeleton; no new UI strings. Existing “Model”, effort and permission labels retain their copy. Single-line truncation and full accessibility labels are preserved in code; device/width checks are explicitly pending above.
This was referenced Nov 13, 2026
nixuuu
added a commit
that referenced
this pull request
Nov 15, 2026
Android can open the IME over the floating composer without moving the latest content. Wide Markdown blocks also need to share gesture ownership with the vertical thread list. This adds JS-only recovery for settled keyboard bounds and moves Android gesture roots to each native window. - Keep native keyboard frames for animation. Reconcile show, hide, and height changes through React Native's independent Keyboard events, including a keyboard already open at mount. Defer reconciliation during a native animation and normalize the navigation-bar inset. - Add only the difference between reconciled bounds and the keyboard inset already supplied by KeyboardChatScrollView. Retain #759's stable composer reserve and anchoring, without restoring Android autoscroll-to-zero. - Put the Android GestureHandlerRootView above both vertical and horizontal scroll views, including modal windows. Keep native directional arbitration and nestedScrollEnabled for tables, code, and diffs. The iOS root hierarchy and scroll adapter remain unchanged. Related: #759 Related: #359 Related: #571 ### Recording and history Inspected the supplied 16.05-second recording using a full 4 fps frame strip and separate keyboard/table strips. Around 0.75–1.75 s and again after 2.5 s, the keyboard covers a stationary composer and message content. The later table gestures move the feed vertically without exposing more columns. The recording cannot establish native callback delivery or exact gesture direction. Compared git log -p and the parent of b99ac10. #759 changed the reserve, fold intent, clipping, and Android autoscroll threshold; it did not change KeyboardWindow, FloatingComposer, ChatKeyboard, or HorizontalScroll. The frame-only keyboard path dates to 49db26e (#359); the block-local gesture roots date to b6dca61 (#571). These are the code paths addressed here, but the native trigger and introducing commit for the reported failures are not confirmed. There is no evidence sufficient to label #759 as the introducing regression, so this uses Related rather than Fixes. ### Verification - Passed with nice and TMPDIR=/var/tmp: bun install, repository typecheck, mobile typecheck, repository lint, format, and format:check. Changed-file Expo ESLint also passes. No UI tests added. - Full mobile Expo lint reports 112 errors and 25 warnings outside the changed files. This additional check is not claimed as passed. - Nightly fingerprints generated before/after with expo-updates fingerprint:generate are byte-for-byte identical: Android 141ef4e8c825ee4fc5d22c499402b284741b0970; iOS 83794f069934a7374461427d89b8d008cec19d97. No native module, dependency, config, plugin, or native setting changed. - Device acceptance remains unverified. Local discovery reports no Android SDK. MacStudio discovery timed out twice with no devices returned. EAS device_open failed because frameAncestors/corsOrigins require Production or Enterprise and the account has Starter. No emulator was driven, no existing AVD was modified, and no after-shots are claimed. - No EAS update/build, tags, releases, production services, reserved ports, web build, native generation, or full integration/E2E suite was run. Source and documentation are the only committed artifacts. ### Outstanding acceptance Keep this PR draft until the same installed Android Nightly native build can run this JS: check IME open/close, suggestions/emoji and IME height changes, writing visibility and latest content, fold/expand without feed displacement, horizontal/vertical drags from table text and padding, long code/diffs, and modal viewers. Repeat the existing iOS flow for parity. The fallback repairs missing animation updates; it does not change a native soft-input setting. A demonstrated need to change that setting must be reported separately. ### Copy audit (§8) No UI text changed. The change affects keyboard bounds and gesture ownership; device layout and accessibility acceptance remain open.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The mobile composer now follows native keyboard frames on the UI thread, including interactive movement. Thread and bot conversations adjust their bottom inset with the keyboard. The composer fade is fixed at 32 dp and the feed reserves only the composer's actual settled height.
Fixes: #292
Related: #308
Recording findings and fixes
KeyboardAreaand JS keyboard listeners withreact-native-keyboard-controller1.22.7, a provider per native window, and native frame worklets. Use frame positions rather than iOS start-event destinations; no separate keyboard easing.Writing mode retains attach/model/effort controls, scroll compaction stays gesture-driven, and the same keyboard container serves bot chat. Package changes are limited to the keyboard dependency and its lock entries. Mobile architecture documentation is updated.
Evidence and verification
run-as: package not an application: com.android.settings; stopped after the advised retry. Android keyboard/interactive/predictive/edge-to-edge checks, phone dark checks, and Fold portrait/landscape light/dark visual checks remain unverified. No new AVD was created.development-simulatorbuild, b145130c, including the keyboard native module. Both native clients predate the separately merged OTA dependency (feat(mobile): ship js changes over the air #357). After rebasing onto feat(mobile): ship js changes over the air #357/fix(mobile): clean settings transitions and back navigation #358, the verification-only source copy retains the pre-OTA General Settings file to avoid importing an absent Expo Updates native module; keyboard code and the new route structure match this branch. Exact-head native startup with OTA, physical iOS devices, hardware keyboard, and system reduced-motion behavior remain unverified (reduced-motion paths reviewed in code). No compatibility workaround is committed and no second EAS build was run.bun install,bun run gen:check, root/mobile typecheck, root lint/format check,bunx expo lint, Expo Doctor (20/20), web build, CNG generation, both final native JS exports, Android native compilation and the approved iOS native build.bun run check:tmp: 1799 passed, 161 skipped, 0 failed, no test-owned temp leftovers. Rebased onto currentorigin/dev, including the(main)route moves from fix(mobile): clean settings transitions and back navigation #358.Draft pending the remaining native visual checks. Evidence videos/frames stay outside version control.
Review