Repository navigation
fix(mobile): fold the composer on the ui thread without moving the chat - #308
Merged
Merged
Conversation
The floating composer from #292 folded with RN Animated on the JS thread (useNativeDriver false); every animation frame re-measured the composer, set React state and re-laid out the timeline spacer, so the fold ran at a few frames per second and the chat moved with it. Scroll decisions waited for a 250 ms reader window on the JS thread. Compaction is now decided in a Reanimated scroll worklet and animated on the UI thread from one shared progress value. The timeline keeps a fixed reserve (the expanded composer), so folding and opening never move a message. While the field has focus the controls fold away and the field takes over their measured room. Fixes: #292
nixuuu
added a commit
that referenced
this pull request
Nov 7, 2026
## Change Keep the mobile thread composer's trigger hint on one line in both compact and expanded states. Previously, expansion replaced `Ask anything…` with a two-line placeholder after the animation, causing a second layout change. The hint now renders outside the native multiline input's content measurement and truncates with a tail ellipsis. Composers without triggers retain their existing placeholder; web copy is unchanged. Route every mobile editable field through a shared `ui/TextInput`. On iOS it clears inherited `lineHeight`, letting UIKit use the font's native metrics for placeholders and typed text. Android receives the original styles. This covers sidebar thread search, project picker search, settings search, kit fields, project settings, queued-message editing and the composer. The pinned React Native iOS implementation applies explicit line heights as paragraph attributes. Ordinary attributed text receives `RCTApplyBaselineOffset`, while TextInput's default typing/placeholder attributes come directly from `RCTNSTextAttributesFromTextAttributes`. The shared 16/24 typography therefore pushed input glyphs down. This predates the recent composer animation changes. Related: #242, #308 ## Verification - GitHub CI at handoff: all nine checks passed, including all four test shards, static checks, typecheck and builds. - Passed: `bun install`, `bun run gen:check`, `bun run typecheck`, `bun run lint`, `bun run format:check`, web production build, mobile typecheck, `bunx expo lint`, Expo Doctor (20/20), Android native debug build, and iOS/Android production JS exports. - Full `bun run check:tmp --timeout 30000`: **not green** — 1,712 passed, 161 skipped, one setup-hook timeout in `worker-host.test.ts` and one associated HTTP/2 GOAWAY error (1,874 tests / 309 files). The temp-directory gate reported nothing left. The isolated `check:tmp tests/integration/worker-host.test.ts --timeout 30000` rerun passed all 15 tests and temp cleanup. An earlier run encountered six cascading config-sync recovery failures and exited 143 before completion; the isolated recovery file then passed all six tests. No gateway/worker code was changed. - Android: built locally with a private SDK/Gradle and installed on a temporary phone emulator and the existing Fold (private package on Fold, preserving its installed app). A temporary inspection route mounted the real composer, fold/scroll hooks and input components. Checked light/dark, phone/Fold, 280 dp truncation, compact/expanded transitions, focused writing mode with controls hidden, single/multiline drafts and the bot placeholder. Recording frames confirm one hint line throughout expansion with no delayed height jump. Checked bare thread search, settings search, project picker search, single/multiline kit fields and settings inputs with short, typical and long text. This verifies components in an offline inspection screen, not paired gateway navigation. - iOS: an iPhone simulator probe mounted the actual shared wrapper beside native inputs using the same Inter font and 16/24 typography. Checked light/dark, empty placeholders, typed single-line text and three-line drafts. The shared style moved glyphs up about 5–6 pt relative to their field borders, with no clipping. **Full iOS composer transitions and the actual sidebar/project/settings screen contexts remain unverified.** The existing dev client lacks `CanopyPinnedFetch`; private native preparation brought available disk below the required 12 GiB, so no Xcode build was started. The probe avoided transport imports. Source inspection supports the shared fix, but does not replace full iOS app verification. - No permanent UI tests or inspection routes were added. Temporary apps/AVD, native build output, private toolchains, Metro and forwarding processes were cleaned up. Inline self-review covered input/ref forwarding, all native input import sites, Android style preservation, accessibility, truncation and composer sizing. ## Copy audit (§8) - Before → after: mobile `Ask anything…` plus a second trigger line → only `/ commands · $ skills · @ files · # threads · ! shell`, identical in compact/expanded states. Removes redundant prompt copy and the late line-count change; documented in §4.9. No-trigger and web placeholders keep their existing wording. - §8.1–2: existing short trigger labels, punctuation, glossary and NBSP item grouping retained; no new terms. - §8.3–5,7–8: no changed actions, confirmations, errors, empty-state messages, dependency messages or humour. - §8.6,10: no duplicate visible prompt; the field keeps its accessible label and exposes the full hint as an accessibility hint. Meaning does not depend on colour, icon shape or position. - §8.9: Android phone, 280 dp and Fold width checked with short, typical and long text; desktop/web unchanged. iOS scope and remaining visual gaps are stated above.
nixuuu
added a commit
that referenced
this pull request
Nov 7, 2026
Opening or filtering mobile composer suggestions used to change the measured composer height and the timeline's bottom reserve, moving the conversation behind the panel. Suggestions now occupy a bounded overlay above the composer, outside its measured box, so opening, loading, filtering, resizing and closing the panel leave the feed stationary. The overlay stays below the header and above the keyboard, with a 240 dp maximum height and internal scrolling. It uses the existing `pop` motion and switches instantly with reduced motion. Scrolling and selecting suggestions preserve input focus and the keyboard. Bot chat has no suggestions panel; its model/effort sheets remain unchanged. Updated the mobile layout documentation. Related: #308 ### Verification - All requested gates passed: `bun install`, `bun run gen:check`, root typecheck/lint/format check, web build, mobile typecheck and `bunx expo lint`. `bun run check:tmp`: **1730 passed, 161 skipped, 0 failed**; temp check clean. No UI tests added. - Built an arm64 Android development client locally and verified on Medium Phone and unfolded Canopy Fold against an isolated gateway, scripted worker and Postgres fixture with 24 completed turns and 40 file-search entries. Keyboard open, light and dark: open `@`, type a filter, wait for delayed results, shrink to one result/empty results, then close. Latest-message bounds stayed identical throughout each sequence; before/after visible-feed crops had zero pixel differences on both devices in both themes. - Also verified internal list scrolling, file selection with keyboard/input focus retained, `/` commands, `$` skills, `#` threads and opening/closing with system animations disabled. Current `!` shell mode does not open a suggestions list. Self-review found no blockers. - iOS remains unverified: the installed simulator app cannot load the development bundle; no build was run on the Mac. The isolated fixture, port forwards, containers, development server and generated Android build output were cleaned up; existing emulators were preserved. Copy audit: **No UI text changed.**
nixuuu
added a commit
that referenced
this pull request
Nov 8, 2026
Keep the attachment, model, reasoning effort and send/stop toolbar visible while the mobile composer has focus. Only the secondary worker/goal/permission row folds, and the text field takes over that row's measured height. The toolbar still folds when reading older messages. The existing shared UI-thread animation, motion tokens, reduced-motion handling, feed reserve, Android blur-on-keyboard-close, mounted picker state and attachment draft remain in use. The goal action now belongs to the secondary row; its worker/goal area scrolls horizontally for long labels. The one-line trigger hint and subagent summary are unchanged. docs/mobile.md describes the new writing mode. On both iOS and Android, tapping model, effort or attach dismisses the keyboard as the sheet opens. Attachment changes are limited to that keyboard dismissal; photo-picker presentation and intake are left to the separate freeze fix. Verification: - Passed: bun install, bun run gen:check, bun run typecheck, bun run lint, bun run format:check, web build, mobile typecheck and bunx expo lint. - CI passed for this exact head: static checks, all four complete check:tmp shards (with full test-file coverage verified), web/Linux builds and the aggregate gate. The local full run reported an unrelated linked-bot checkpoint gRPC UNAVAILABLE/disconnect on the heavily loaded shared machine; it was stopped after the complete isolated CI run passed. Earlier local attempts exposed temporary-directory Git discovery and timeout failures. The last local run used worktree temp data, a Git discovery ceiling and a 30-second timeout; the project-discovery failure cleared. - Native QA is blocked: both existing Android devices are held by other sessions; a temporary Android AVD failed to boot with the Mac nearly out of disk space and was deleted. The free iOS simulator's installed dev client lacks ExpoClipboard; no usable replacement artifact was available. The Mac had less than the required 12 GB free, so no iOS build was started. No native build was produced on Linux, where neither Android SDK nor JDK is installed. - The requested phone/Fold, light/dark, repeated focus/blur, multiline drafts, picker selection, reduced motion, pending attachment preservation and Paste image runtime matrix remains unverified. This PR stays draft pending device verification. - The isolated PostgreSQL/gateway/scripted-worker fixture started successfully; no device completed pairing. The fixture, Metro, SSH forwards and local test processes were stopped, their containers removed, and the temporary AVD deleted. No native build output was generated. Copy audit: no UI text changed. Related: #308
nixuuu
added a commit
that referenced
this pull request
Nov 8, 2026
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 - **Keyboard opens through a stationary composer, then the composer jumps.** Replace `KeyboardArea` and JS keyboard listeners with `react-native-keyboard-controller` 1.22.7, a provider per native window, and native frame worklets. Use frame positions rather than iOS start-event destinations; no separate keyboard easing. - **Keyboard hides while the composer floats above an empty gap, then drops.** The same native frame translation drives dismissal and interactive gestures; safe-area compensation sits outside the measured composer. - **Visible messages jump when the keyboard opens or closes.** Move chat insets and offsets together, normalize the inverted iOS inset for following/scroll anchoring, and prevent keyboard corrections from triggering compact-on-scroll. Preserve native visible-message anchoring while reading history. - **Attach opens while the keyboard and composer cross beneath it.** Wait for native keyboard dismissal before presenting attach/model/effort sheets and other modal panels. Searchable modal windows own their keyboard provider; mentions remain within the moving composer viewport. Native Photos/Files presentation follows menu dismissal. - **Oversized composer/fade on iPhone portrait and unfolded Fold.** Remove two empty 44 dp status slots, an empty 20 dp syncing row, and the retained expanded reserve. Keep active status rows/popovers outside the measured input, separate keyboard/safe-area space, and render a fixed 32 dp fade above its top edge. - **Phone sheet scaling exposes edge seams and keyboard padding limits dim coverage.** Keep the scrim full-window and animate phone sheets with translation only. Wide cards retain the shared motion tokens; reduced motion removes extra UI animation. 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 - Extracted the supplied keyboard/reference recordings at 60 fps around transitions. Before: the keyboard crosses a stationary composer around 4.65 s; dismissal leaves the composer floating around 5.82 s; attach overlaps the keyboard around 11.48 s. The supplied phone and Fold recordings also expose the oversized reserved area/fade. Captured a local iOS baseline and after recordings against an isolated long conversation. - iPhone 17 Pro simulator, iOS 26.3: inspected light/dark show/hide, swipe-down interactive dismissal, writing mode with a long draft, scroll compaction/return to latest, attach while typing, native Photos/Files presentation and cancellation, model/effort pickers, mention suggestions, subagent panel, and bot chat. Sampled after frames show composer/feed movement accompanying the keyboard without the old delayed jump or floating gap; sheets appear after dismissal with full-window dim coverage. The fade stays short and the empty reserve is gone. Recording requested 60 fps; the simulator exports variable-rate video, so this is sampled visual evidence, not a constant-60-fps timing guarantee or physical-device parity claim. - Android arm64 development client compiled locally and installed on the phone and unfolded Fold. Phone light static layout confirms the smaller composer area. Motion checks were invalid because the device tool selected its headless IME. Switching to Settings to restore a visible IME then failed twice with `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. - Used the single approved EAS iOS `development-simulator` build, [b145130c](https://expo.dev/accounts/itsol/projects/canopy-mobile/builds/b145130c-748c-4d69-afe1-23418ad09082), including the keyboard native module. Both native clients predate the separately merged OTA dependency (#357). After rebasing onto #357/#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. - Gates passed: `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 current `origin/dev`, including the `(main)` route moves from #358. Draft pending the remaining native visual checks. Evidence videos/frames stay outside version control. ### Review - Componentize pass completed before the final commit: shared native-window/frame ownership, keyboard viewport/presentation helpers, overlay surface, a dedicated iOS chat scroll adapter, and conditional connection status; no duplicated keyboard listeners. Final self-review covered safe-area ownership, actual-height measurement, gesture compaction, modal handoff, reduced motion, route rebase, and dependency scope. - Copy audit: no UI text changed. - No UI tests added, following repository policy.
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.
This was referenced Nov 13, 2026
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.
Fixes: #292
The floating composer from #292 stuttered while it folded or opened (reported at about 3–4 fps on a phone), moved the whole chat when it changed size, and started 300–500 ms after the scroll. It uses no animation library beyond React Native: the cause is described below. This PR also hides the composer's controls while the user writes.
Root cause
ComposerFoldandComposerBoxanimatedheight,minHeight,maxHeight, paddings and the send button'sbottomwith RNAnimatedanduseNativeDriver: false. Four separate animated values ran on the JS thread, which also renders the streaming turn.onLayoutthen calledmeasure, which ransetHeightand re-rendered the screen. That height fed the spacer in the inverted list's header, so the long FlatList re-laid out on every frame. This is also why the chat moved: at the bottom the spacer followed the composer.onScrollthrottled to 32 ms, behind a 250 msreaderUntilwindow. Each scroll event also set React state (setAtBottom).Fix: compact and expand on the UI thread
useFollowingListkeeps the scroll position in shared values. React hears only when the reader leaves or reaches the bottom. The lists are Reanimated lists (TimelineList,Animated.FlatList).useFloatingComposerdecides the fold in auseAnimatedScrollHandlerworklet with the web'sComposerCompactionrules: 192 dp from the end, 96 dp of reader travel, open within 8 dp of the end. Reader gestures are tracked by drag and momentum events instead of a timer, so stream updates, anchor corrections and the keyboard never fold it.ComposerMotionContext).ComposerFoldanimates its own clipped height and opacity. The field and send button animate on a frame around the AndroidTextInput, which does not take animated sizes itself.KeyboardArea, "Show latest messages", edge-to-edge safe areas, the protected draft/attachments/mention list, the motion tokens (slow/medium,smoothOut) and reduced motion (instant switch).Hide the composer controls while writing
motion.fast; instant with reduced motion).Before and after
All on an Android 16 emulator at 53 Hz, with production JS bundles, a 40-turn thread and a turn streaming during the measurements. The before run is the current
dev.dev)setHeightfromonLayout, plus the spacer)onScroll(32 ms throttle) behind a 250 ms reader window; about 200–300 ms in recordingsThe last row barely changes. The emulator's render-thread counter is dominated by drawing a long list while a turn streams. It can't see the old problem either: frames the JS-driven animation never produced simply aren't counted.
Verification
bun install,gen:check,typecheck,lint,format:check,expo lintandcheck:tmp(1558 pass, 0 fail, nothing left in the temp dir) are clean on the final commit.Medium_Phone_API_36.1andCanopy_Foldwere booted by other sessions, so I didn't take them. Covered:Unverified
Copy audit
No UI text changed.