Skip to content

feat(mobile): float composers and extend layouts edge to edge - #292

Merged
nixuuu merged 1 commit into
devfrom
feat/mobile-sticky-composer
Nov 6, 2026
Merged

nixuuu merged 1 commit into
devfrom
feat/mobile-sticky-composer

Conversation

@nixuuu

@nixuuu nixuuu commented Nov 6, 2026 •

Copy link
Copy Markdown
Member

Mobile conversations used a solid composer block that shortened the timeline. Composers now float above the feed and fold while reading history; the main screens also extend their backgrounds and scroll viewports behind the system bars while keeping controls inside safe areas.

Rebased onto dev after the mobile UI kit landed (Related: #287). Its shared buttons, notices, search/form controls, confirmation host and sheet title/close controls are preserved. Connection banners now participate in the floating header measurement on threads, bot chats, sidebar and Settings. The extracted sidebar footer uses #287's interactive connection status with details and retry; Settings retains its density provider. Full sheets keep the kit's 20 dp content spacing inside the inset-aware modal frame.

The final rebase also includes the bot-history changes that landed meanwhile (Related: #288, #289, #290). Bot chats retain the snapshot cache, incremental updates, cached bot names, loading header/avatar, syncing subtitle and live-only approval/send/stop guards beneath the floating layout.

Composer behavior

  • Match web ComposerCompaction: fold after 96 dp of travel toward older messages, at least 192 dp from the end; expand within 8 dp of the end or on tap, focus, or typing. Only reader gestures fold it; streaming and layout changes do not. Synchronous questions keep it expanded.
  • Match VirtualFeed.reservedFooter: measure the full overlay, retain its largest reserve while reading history, and follow its height at the latest end. The changing spacer is excluded from the visible-message anchor. The latest-message action remains above the composer with an actual Android touch area.
  • Reuse the web surface, border, light-theme shadow and 32 dp canvas fade. Animate folding with shared 400/350 ms tokens and smoothOut; reduced motion uses zero duration. Inputs and folded controls stay mounted.
  • Mobile additionally keeps any draft, attachment or mention picker expanded, so compaction cannot hide unfinished input. Bot chats retain their native inline pill. This is a deliberate difference from web's ability to fold a draft to one line.

Insets by screen

Screen Layout and control insets
Thread and existing side thread Full-window inverted feed under a translucent floating header and composer. Oldest end reserves the measured header plus top inset; latest end reserves the measured composer including bottom inset. Composer controls have side/bottom padding.
Bot chat Same overlay, compaction, reserve and safe-area rules as threads, with the inline bot composer.
Sidebar and thread/bot lists Full-height list under measured floating header/footer. Content padding makes first/last rows reachable. Footer controls sit above the home indicator. Only the outside edge of each split pane consumes a horizontal inset.
New thread and side-thread creation Expanded forms because there is no conversation history to compact. New thread scrolls under its floating header; side-thread creation uses the modal frame. Form content gets safe-area padding.
Settings Both columns scroll behind the floating header. Navigation consumes the left outside inset, details the right; a single column consumes both. Forms retain keyboard-overlap handling.
Pairing and empty home pane Full-window background and scroll viewport, with content padding protecting controls at both ends and sides.
Full sheets and compact pickers Full sheets measure their own modal safe area and scroll under the header. Bottom pickers extend their surface behind the home indicator and inset actions; centered landscape/Fold cards fit the safe rectangle.

KeyboardArea keeps its existing keyboard screenY calculation. Closed-keyboard safe-area padding now belongs to scroll content and composer controls instead of the viewport. Status-bar icons continue to follow the selected light/dark theme; translucent header surfaces maintain contrast above scrolling content. No new native dependency or native configuration change.

Verification

Reran after the final rebase onto cf9f6be2: bun install, bun run gen:check, bun run typecheck, bun run lint, bun run format:check, bunx expo lint from apps/mobile, and the web build. All passed. Expo refreshed the ignored generated route list for the newly merged exchange screen before the passing typecheck. Final bun run check:tmp: 1534 passed, 158 skipped, 0 failed, 1692 tests across 274 files; no test temp directories left behind.

The full test run uses a private TMPDIR inside the ignored worktree temp directory, with GIT_CEILING_DIRECTORIES set to that directory. This prevents deliberately non-Git fixture folders from discovering the checkout above them. Live/provider tests remain opt-in. Self-review and git diff --check are clean.

Android Fold device observations before the final edge-to-edge expansion: light/dark surfaces, long history, content passing below the composer, folding on scroll, expanding on tap/focus and return to latest, functioning latest-message action, and a visible multiline draft. Screenshots are kept outside the checkout. The recording exporter failed after its documented debug retry.

After the UI-kit rebase, the source launched in the free Android Fold emulator using the existing development client. Smoke-checked the edge-to-edge shell in light and dark, readable status icons, inset sidebar footer, the offline connection banner and its details/retry overlay, plus Settings search with the real keyboard open and closed. After the final bot-cache rebase, the bot-chat screen also rendered its loading header and floating composer. The old fixture gateway was offline, so live conversation behavior was not rechecked. Multiline entry could not be verified: Android's system_server aborted during the fill attempt, and the tool's debug retry could not find the field after the reset. No new native build or download was needed; the owned emulator and Metro session were shut down afterwards.

Device QA remains incomplete: the earlier iOS development-client launch timed out twice, and its notch/Dynamic Island layouts remain unverified. Phone width, conversation keyboard handling, drafts with attachments and mention suggestions, bot/side-thread flows, reaching the bottom during streaming, reduced motion, landscape and Android three-button navigation still need device coverage. The rebase smoke check does not replace those checks.

Copy audit (docs/copy.md §8): no new user-facing copy; existing English action labels and form text are preserved. No web UI tests or permanent verification artifacts were added. Shared mobile buttons, notices and form controls retain #287's implementation; only the shared sheet's layout delegates to the new modal frame.

@nixuuu
nixuuu force-pushed the feat/mobile-sticky-composer branch from d1addfa to 3862eb3 Compare November 6, 2026 19:32
@nixuuu
nixuuu merged commit 926e2d1 into dev Nov 6, 2026
15 of 17 checks passed
@nixuuu
nixuuu deleted the feat/mobile-sticky-composer branch November 6, 2026 19:39
nixuuu added a commit that referenced this pull request Nov 6, 2026
Stage 2 of 2 (stack: #297 → this PR). Merge the stack together.

Applies the motion layer from #297 to the screens. Rebased onto #287 (UI
kit) and #292 (floating composer). The composer's compact/expand is
untouched.

## Transitions per screen

- **Thread timeline** (inverted list held by the fold anchor): a new
turn (sent or queued message) fades in; rows that arrive later inside a
turn fade in (work rows, notices, the answer when it leaves the fold);
an opened fold's rail fades in; fold, group, reasoning, code,
file-change and failure chevrons turn; pending steers fade in and out.
No height animation in the feed, so anchoring and following still hold.
- **Bottom of a conversation:** approval/question cards pop in and out;
"Show latest messages" pops in and out (in `FloatingComposer`,
appearance only).
- **Bot chat:** new messages fade in; the approval card fades its answer
block out on expiry and swaps the actions for the expiry note.
- **Sidebar:** the Threads/Bots lists cross-fade while the pill slides.
Thread rows glide on reorder (`GlidingCell`) and fade in when new, and
the row status (Working → Completed …) swaps. The "Working" section and
"Archived" get chevrons, and "Archived" expands as an accordion. In the
bot list, rows glide on reorder (`itemLayoutAnimation`), new bots fade
in, and unread counts pop and swap. The connection label swaps and its
dot eases.
- **Wide layout:** the sidebar slides in from the edge and fades
(`slow`) and slides out (`medium`). The column takes its width before
the slide in and gives it up after the slide out, so the screen beside
it lays out once, not on every frame. Rotation, folding, sign-in and
Settings switch at once. Screens keep the in-place swap from #234.
Screen transitions stay the native stack defaults.
- **Settings:** disclosures expand and collapse; connector error details
expand. The kit's `Switch` already animates its thumb.
- **Lists:** composer attachment chips pop in and out and their
neighbours glide. Bot approval rules resolve in when loaded, and a
removed rule fades out while the rest glide up.
- **In-app alert:** comes down from the top edge and leaves the same
way; a newer alert replaces it.
- A screen's first render and its removal do not animate
(`LayoutAnimationConfig` in the Stack's `screenLayout`, sheets and
overlays).

## Reduced motion

Fades only (rows, sheets, alerts, cards). Slides, pill, chevrons, text
swaps, layout glides and the sidebar are instant. Checked on iOS (Reduce
Motion) and Android ("Remove animations").

## Performance

- Every animation runs on the UI thread (Reanimated shared values,
layout animations).
- Long lists: virtual lists animate only real arrivals (`useArrivals`).
Rows that remount while scrolling appear at once, and virtualized rows
have no exit animations. The timeline animates opacity only, never
height.
- The sidebar no longer animates the column width. A width animation
re-laid out a 40-turn thread on every frame on the iPad and dropped the
motion; the column now changes width once, outside the motion.
- Checked with a 40-turn seeded thread on the iPhone 17 Pro simulator
(dev and production JS bundles), the iPad Pro 13" simulator and a Pixel
7 class Android 16 emulator.

## Verification

- Gates: `bun install`, `bun run gen:check`, `bun run typecheck`, `bun
run lint`, `bun run format:check`, `bunx expo lint`, `bun run check:tmp`
(1548 pass, 0 fail, nothing left in temp) and the web build are all
clean on the rebased stack.
- EAS dev builds (iOS simulator, Android APK) with the new native
modules were installed. The app was paired with a throwaway local
gateway that had seeded threads.
- iOS (iPhone simulator), light and dark, reduced motion on and off:
segmented pill, sheet open/close, live turn (rows arriving, fold
closing, answer out), fold toggle with the header anchored, "Show
latest", settings segments. After the rebase onto #292, a smoke test of
a live turn with the floating composer passed.
- iPad (wide layout): sidebar close and reopen end states, and pill.
- Android emulator: pill, live turn, dark mode, reduced motion (sheet
and scrim fade only).

## Unverified / known

- Frame-level timing on the iPad: simulator recordings at that
resolution drop frames, and frame stats need a physical device. The
sidebar design avoids per-frame layout, but it was not measured on
hardware.
- Not checked on a physical phone or a mid-range physical Android
device.
- Pre-existing and not changed here: on Android, after sending in a long
thread the feed stops just above the bottom and shows "Show latest
messages" instead of following. It reproduces with every animation
disabled, so `maintainVisibleContentPosition` on Android is the likely
cause.

## Copy audit

No UI text changed.
nixuuu added a commit that referenced this pull request Nov 6, 2026
Restarting Electron previously discarded all thread, bot chat and
exchange state. This stage saves public protobuf projections in the
app's private data directory and restores them before the first watch,
so reopening sends the saved journal checkpoint.

The shared durable LRU holds 32 views / 96 MiB, at most 16 MiB per
entry. Atomic rename, 0700 directories, 0600 files, projection
validation and generation fences protect partial writes and session
changes. Mode change, unpair and revocation clear disk and memory. Plain
browser sessions deliberately remain memory-only: no conversation
content in IndexedDB or localStorage. Polish desktop documentation
records the boundary and limits.

### Restart findings and measurements

The existing mobile caches really do survive force-stop/relaunch. On an
Android Fold emulator, using the current development binary, reopening a
3,000-message thread sent a 433-byte protobuf delta and reopening a
3,000-message bot chat sent a 310-byte delta with zero messages. Cached
bot content rendered before the delta arrived. No mobile
persistence/schema-key fix was needed. An obsolete development binary
initially buffered small streaming responses; the check was repeated on
the current build.

For context, the uncached full thread response was 3,559,707 protobuf
bytes. Desktop persistence plus a real gateway restart is verified by
integration tests; native Electron shell launch-to-paint timing and an
actual packaged Electron quit/relaunch remain unverified. The client
paging stages below address uncached opens.

### Verification

- Rebased onto current `dev`, including #292, #297/#298 and #304. `bun
install`, `bun run gen:check`, `bun run typecheck`, `bun run lint`, `bun
run format:check` and Expo lint passed on this stage.
- Real gateway/storage recreation: durable thread and bot checkpoints
still resume as deltas after gateway restart.
- Private permissions, LRU eviction, corrupt/path traversal rejection,
and clear fencing against late writes.
- The top stage adds full-suite/temp cleanup, web production build, Expo
lint and device/browser checks.

No migrations or new native mobile dependencies. No UI copy changes in
this stage.
nixuuu added a commit that referenced this pull request Nov 6, 2026
Uncached thread, bot chat and exchange reads can now start at the tail.
Additive protobuf fields request a page and return a stable older-page
boundary, continuation flag and reset metadata; generated code is
included.

Thread pages contain complete turns, including inherited fork history,
work segments and footers. Bot/exchange pages use immutable message
sequence boundaries. Current approvals, queue, goal and header
configuration remain complete. Existing journal cursors resume deltas;
the loaded-window reducers ignore edits outside the window until that
older page is read. Older-page merges preserve newer live rows and
replay from the pre-read checkpoint so concurrent edits cannot be lost.

Online linked-computer reads pass the client's cursor/page request to
the owner-scoped home. The top stage also pages the offline mirror.
Fork/moved-history changes, missing boundaries and journal gaps reset
safely. Older clients request page size zero and receive full history;
older gateways ignore the added fields and continue returning full
snapshots. No link-version bump or migration is needed.

### Measurements

Same real gateway/Postgres fixture: 1,500 completed turns, one input and
one answer per turn, approximately 2 KiB of answer/tool-like text, 3,000
messages total. Client stage defaults are 24 turns / 50 bot messages.

| Initial thread response | Full history | Tail page |
| --- | ---: | ---: |
| Gateway protobuf bytes | 3,559,707 | 57,453 |
| Snapshot build, Android measurement | 58.8 ms | 15.1 ms |
| Web first content, warmed development code | 1,390.6 ms | 76.1 ms |
| Web SSE data bytes | 3,906,105 | 63,625 |
| Android first content | 1,771.4 ms | 518.4 ms |

These are single loopback development measurements, not a production
percentile benchmark. Web SSE JSON bytes exclude framing and differ from
mobile protobuf bytes. Cold route compilation was slower (1,541.6 ms
after); warm code is used for the web comparison. Client integration and
device evidence belong to the top stage.

### Verification

- Rebased onto current `dev`, including #292, #297/#298 and #304.
Install, generated-code consistency, typecheck, lint, formatting and
Expo lint passed on this stage.
- Real gateways: all turns/messages reached without omissions during
concurrent append, fork/inherited history, target-item reads,
reset/fallback, owner scoping, cursor after restart, bot edits,
exchanges and linked-computer reads.
- Polish protocol and folding documentation updated; no UI copy changes
here.

Whole-turn pages intentionally do not split one unusually large turn.
Target-item navigation may fetch more than one normal page to retain a
contiguous loaded window.
nixuuu added a commit that referenced this pull request Nov 6, 2026
Web, Electron and mobile now request the latest 24 complete turns or 50
bot/exchange messages when no usable cache exists. Scrolling upward or
choosing Show earlier messages grows the cached window, preserving the
reader's position and the journal checkpoint. Cached content still
renders first; actions and pending approvals wait for the main live
state.

Thread search explicitly reads earlier pages through to the beginning
and searches user inputs plus agent answers, including inherited
history. Web results reveal the matching turn/item, and quoted-item
navigation fetches missing history before opening its fold. The usage
panel labels partial totals as Tokens of loaded turns. Offline linked
threads page the local mirror; an opaque offline checkpoint preserves
the loaded window until the home returns. Desktop bot-list
reconciliation also removes unopened archived/deleted/moved bot
projections from disk.

### Measurements and restart findings

Fixture: real gateway/Postgres, 1,500 completed turns / 3,000
input-and-answer messages with approximately 2 KiB answer/tool-like
text. Single samples on development clients, loopback link, warmed web
code.

| Open without cache | Before | After |
| --- | ---: | ---: |
| Web first content | 1,390.6 ms | 76.1 ms |
| Web SSE data bytes, excluding framing | 3,906,105 | 63,625 |
| Android first content | 1,771.4 ms | 518.4 ms |
| Android protobuf bytes | 3,559,707 | 57,453 |
| Android snapshot build | 58.8 ms | 15.1 ms |

A cold web route compilation took 1,541.6 ms after the change; this is
excluded from the warmed-code comparison. Android's initial 50-message
bot tail took 428.1 ms and 118,257 protobuf bytes.

Actual Android force-stop/relaunch preserved both caches: thread reopen
sent a 433-byte delta; bot reopen sent a 310-byte delta with zero
messages. Cached bot content reached its first frame before that delta
arrived. No cache key, epoch, startup eviction or disk-read-order defect
was found. An obsolete dev binary initially buffered small streams;
checks were repeated on the current EAS development build without
rebuilding native code.

Web prepend kept a measured input row at exactly the same y position
(164 px before and after). Bot prepend increased scrollTop by exactly
the added content height (34,500 px).

### Cache and compatibility

Mobile retains its existing separate budgets: threads 16 entries / 64
MiB on disk (16 MiB per entry), 6 / 24 MiB in memory; bot
chats/exchanges share 16 / 32 MiB (8 MiB per entry). Storage is
app-private Expo cache files, survives normal restarts, and may be
evicted by the OS. Electron adds a shared 32-entry / 96 MiB private disk
LRU, 16 MiB per entry. Browser content stays memory-only. Entries
contain public, redacted projections; unpair/revocation clears both
stores, and Electron mode changes clear persistence too.

Old clients and gateways continue full loads. Online linked-computer
paging/cursors pass through to the home; offline thread reads page the
mirror. Incompatible history or journal gaps replace the window with a
fresh tail. No migration or new native dependency.

### Verification

Rebased the complete stack onto the mobile motion changes (#297/#298)
and floating composer (#292). The history footer retains the initial
skeleton and empty-chat prompt. Thread and bot feeds keep their arrival
animations, compacting composer and measured spacer. In newest-first
histories, only keys before the first previously seen row can rise;
appended older pages and replacements without overlapping rows appear
immediately. Other animated lists retain their existing behavior.

Rebase verification: install, gen:check, typecheck, lint, format:check
and Expo lint on each stage; full check:tmp and web production build on
the top. Android Fold dev build against a temporary real gateway: 120
complete thread turns and 180 bot messages, multiple scroll-up page
boundaries, recorded checks of stable anchoring and no arrival animation
on older pages, retained floating-composer spacing. No native rebuild
needed; the test pairing, servers and port forwards were removed
afterward.

Full `check:tmp`: 1,559 passed, 158 opt-in/live skips, zero failures; no
project temp files left behind. All other top-stage gates passed.

- Install, gen:check, typecheck, lint, format:check, full check:tmp, web
production build and Expo lint.
- Real gateway tests cover paging with concurrent turns, edits during
older-page reads, forks/inheritance, target items, fallback, owner
scoping, durable checkpoints/restart and linked computers, including
offline mirror resume.
- Existing mobile cache/security tests cover revoke/unpair fences,
absence of credential/secret values, LRU and stale pending approval
rejection. Desktop tests cover durable restart, permissions, corruption,
traversal, LRU and unavailable-bot removal.
- Real browser: thread and bot views in light/dark, desktop/phone
widths; prepend anchoring and search to the first turn. Android Fold
emulator: current app, real force-stop/relaunch for thread and bot; tail
content, cached content and earlier-history search checked through the
device tools.

Copy audit: loading a full empty view → existing skeleton; Show earlier
messages / Search thread name the action; Syncing… is quiet and reserves
its space; Could not load earlier messages. Try again. states failure
and recovery. Tokens of loaded turns avoids presenting a partial sum as
a total. Sentence case, existing thread/bot glossary, accessible names
and no humour. Short and long fixture content inspected at desktop/phone
widths.

### Limits and unverified work

No packaged Electron shell restart/paint measurement or physical-device
measurement. Browser/native checks used development builds. Search is
client-side and explicitly downloads earlier pages; it is not a
server-side full-text index and does not search tool blobs. Mobile keeps
its existing read-only search results (web results jump to the
timeline); mobile has no pre-existing quoted-source reveal control. A
single huge turn remains atomic, so its first page can still be large.
These do not affect ordinary tail/delta reads.
nixuuu added a commit that referenced this pull request Nov 6, 2026
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 6, 2026
…at (#308)

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

- **JS-thread animation.** `ComposerFold` and `ComposerBox` animated
`height`, `minHeight`, `maxHeight`, paddings and the send button's
`bottom` with RN `Animated` and `useNativeDriver: false`. Four separate
animated values ran on the JS thread, which also renders the streaming
turn.
- **A re-render and re-layout on every frame.** Each animated frame
changed the composer's layout. Its `onLayout` then called `measure`,
which ran `setHeight` and 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.
- **Slow scroll path.** The decision ran in a JS `onScroll` throttled to
32 ms, behind a 250 ms `readerUntil` window. Each scroll event also set
React state (`setAtBottom`).

## Fix: compact and expand on the UI thread

- **Scroll handling:** `useFollowingList` keeps 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`).
- **The decision:** `useFloatingComposer` decides the fold in a
`useAnimatedScrollHandler` worklet with the web's `ComposerCompaction`
rules: 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.
- **The motion:** the animation starts in the same frame as the
decision. Tap, focus and typing open it from JS.
- **One progress value:** every part of the composer reads a single
shared value (`ComposerMotionContext`). `ComposerFold` animates its own
clipped height and opacity. The field and send button animate on a frame
around the Android `TextInput`, which does not take animated sizes
itself.
- **Fixed reserve:** the timeline reserves the expanded composer's
height. Folding and opening are overlay motion only. The reserve changes
only when the open composer has settled and its content really changed
(a longer draft, an attachment, the mention list).
- **No layout shift at the bottom:** reaching the end re-opens the
composer over the same reserve, so the chat doesn't move.
- **Unchanged:** `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).
- **Screens:** threads (including side threads), the bot chat, and the
bot exchange screen (follower only).

## Hide the composer controls while writing

- **What folds away:** while the field has focus, the toolbar (attach
button, model, effort, goal) and the worker/permission row fold away on
the UI thread (`motion.fast`; instant with reduced motion).
- **No movement:** the field takes over their measured room, so the
composer keeps its height and the feed does not move. A five-line draft
fits without growing the composer, about four more lines than before.
- **What stays:** send and stop stay visible and usable. Attachment
previews stay; only the add button hides. Choices and pending files are
kept because the controls stay mounted.
- **Coming back:** the controls return on blur, or when the keyboard
closes (Android keeps the field focused then, so the composer blurs it).
Pickers open normally right after the keyboard closes.

## 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`.

| | Before (`dev`) | After |
| --- | --- | --- |
| Composer frames during the 400 ms expand (recorded, 30 fps capture) |
4–5 distinct frames (about 9–12 fps); the fold appears in about one step
| 12–13 distinct frames: every captured frame, at the recorder's 30 fps
cap |
| React renders and list re-layouts per fold | one per animation frame
(`setHeight` from `onLayout`, plus the spacer) | 1 render (the folded
flag), 0 list re-layouts |
| Scroll to fold decision | JS `onScroll` (32 ms throttle) behind a 250
ms reader window; about 200–300 ms in recordings | worklet: folds on the
first scroll event past the threshold; motion starts in the same frame |
| Tap or focus to motion | JS state, then a JS-driven animation | JS
event, then a UI-thread animation (about 1 frame) |
| Feed movement on fold, expand, reaching the bottom, focus and blur |
the feed moves with the composer | none: the feed's y is identical in
every state (screenshots) |
| Android frame health over a scroll and fold sequence | 31–43% frames
over deadline | 33% |

The 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

- **Gates:** `bun install`, `gen:check`, `typecheck`, `lint`,
`format:check`, `expo lint` and `check:tmp` (1558 pass, 0 fail, nothing
left in the temp dir) are clean on the final commit.
- **Android:** my own temporary Pixel 7 and Pixel Fold AVDs;
`Medium_Phone_API_36.1` and `Canopy_Fold` were booted by other sessions,
so I didn't take them. Covered:
  - phone and Fold unfolded;
  - a long thread with a streaming turn;
  - fast scrolling up and down, and reaching the bottom;
  - repeated focus and blur, and a long multi-line draft;
  - the real keyboard (Gboard): open, type, close;
- opening the model and effort pickers right after the keyboard closed.
- **iOS** (iPhone 17 Pro simulator): writing mode with the keyboard, and
a protected draft keeping the composer open while scrolling.

## Unverified

- **Physical devices:** none tested. Neither the 60 fps (120 on
ProMotion) target nor sub-frame input latency was measured on hardware.
Emulator recordings cap at 30 fps, and simulators give no frame stats.
- **iOS blur on keyboard close:** couldn't be automated. The iOS
keyboard has no dismiss key for the tool, and interactive dismissal
needs a drag into the keyboard.
- **Attachments:** not exercised with a real file on the device. The
chips sit outside the folding rows, so they stay visible by
construction.
- **Bot chat:** folding wasn't exercised (no bots on the throwaway
gateway). It shares the same hook and composer.
- **Reduced motion:** not toggled on a device for these paths in this
round. In code, it is a zero duration.

## Copy audit

No UI text changed.
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
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