Skip to content

fix(mobile): fold and open the composer without moving the timeline - #367

Merged
nixuuu merged 1 commit into
devfrom
fix/mobile-composer-fold-jump
Nov 8, 2026
Merged

nixuuu merged 1 commit into
devfrom
fix/mobile-composer-fold-jump

Conversation

@nixuuu

@nixuuu nixuuu commented Nov 8, 2026

Copy link
Copy Markdown
Member

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. fix(mobile): fold the composer on the ui thread without moving the chat #308 retained the expanded reserve. fix(mobile): move the composer with the keyboard #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. fix(mobile): clean settings transitions and back navigation #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 fix(mobile): fold the composer on the ui thread without moving the chat #308/feat(mobile): keep attach, model and effort while typing #352/fix(mobile): clean settings transitions and back navigation #358/fix(mobile): move the composer with the keyboard #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:

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.

Keep the measured expanded input reserve through fold transitions, anchor the newest turn correctly, and reveal controls only after their row has room. Consume scroll intent after each transition and ignore keyboard, layout, anchor and programmatic corrections until a fresh reader gesture.

Fixes: #359

Related: #308

Related: #352
@nixuuu
nixuuu merged commit 39c3293 into dev Nov 8, 2026
9 checks passed
@nixuuu
nixuuu deleted the fix/mobile-composer-fold-jump branch November 8, 2026 20:12
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.
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