Skip to content

feat(mobile): animate ui state changes with reanimated - #298

Merged
nixuuu merged 1 commit into
feat/mobile-motionfrom
feat/mobile-motion-screens
Nov 6, 2026
Merged

nixuuu merged 1 commit into
feat/mobile-motionfrom
feat/mobile-motion-screens

Conversation

@nixuuu

@nixuuu nixuuu commented Nov 6, 2026 •

Copy link
Copy Markdown
Member

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 fix(mobile): swap screens in place beside the sidebar #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 feat(mobile): float composers and extend layouts edge to edge #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.

Applies the motion layer to the screens: thread and bot lists glide on reorder and fade new rows in, the timeline fades in new turns, opened work and answers leaving the fold, chevrons turn, accordions expand, the sidebar column eases open and shut, the switch thumb slides, cards, chips, badges, presence and in-app alerts pop or swap. Reduced motion keeps fades only.
@nixuuu
nixuuu added this pull request to stack #299 November 6, 2026 20:26
@nixuuu
nixuuu merged commit b5c9c4a into dev Nov 6, 2026
9 checks passed
@nixuuu
nixuuu deleted the feat/mobile-motion-screens branch November 6, 2026 20:31
nixuuu added a commit that referenced this pull request Nov 6, 2026
Stage 1 of 2 (stack: this PR → #298). Merge the stack together.

Adds Reanimated and a small motion layer for the mobile app, on the same
motion tokens as the web.

## Dependency and native build

- `react-native-reanimated` 4.7.1 and `react-native-worklets` 0.13.0,
installed with `bunx expo install` (the SDK 58 versions).
- No `babel.config.js`: `babel-preset-expo` configures the worklets
plugin when the package is installed (Expo SDK 58 docs).
- Native modules: a new development build is required. TestFlight and
EAS builds pick them up. `docs/mobile.md` notes this.
- `bun.lock` and `bun run gen:check` are clean.

## Token mapping (`@canopy/ui` `motion` = web `routes/layout.css`)

| Token | Value | Mobile use |
| --- | --- | --- |
| `quick` / `fast` | 150 / 250 ms | close / open of menus and cards,
text swap, pill, chevron, rows |
| `medium` / `slow` | 350 / 400 ms | close / open of sheets, panels,
toasts; skeleton reveal (`slow`) |
| `verySlow` | 500 ms | skeleton pulse half-cycle (web `t-pulse`) |
| `stagger` | 40 ms | added to the tokens; no stagger is used yet |
| `distance.micro` / `medium` / `large` | 4 / 12 / 30 | text swap,
toast, bottom sheet |
| `scale.large` / `medium` | 0.96 / 0.97 | sheet and card, pop and press
|
| `smoothOut`, `inOut` | cubic-bezier | surfaces and position; text and
reveal |

`blur` tokens are not used: React Native has no `filter: blur`.

## Motion layer (`apps/mobile/src/ui`)

- `motion.ts`: tokens, `smoothOut` / `inOut` (`Easing.bezierFn`, valid
for RN `Animated` and worklets), a live `useReducedMotion` with one
app-wide subscription that is seeded by Reanimated's synchronous startup
value, the presets (`rise`, `pop`, `toast`, `banner`, `swap`, `reveal`,
`layout`) through `useMotion()`, and `useTween`.
- `MotionViews.tsx`: `Expand` (accordion), `Swap` (text and number
swap), `Chevron`, `useArrivals` / `ArrivingCell` (only real arrivals in
virtual lists animate), `GlidingCell` (list reorder), `usePressScale`.
- Applied in `ui/`: `Overlay` (bottom sheet rises from `distance.large`
and grows from `scale.large` on `slow`/`medium`; card on
`fast`/`quick`), skeleton pulse and reveal, a sliding `Segmented` pill
with the unread badge popping and swapping (moved to `ui/Segmented.tsx`,
styled like the UI kit), `StatusDot` colour easing, `Alert` toast
enter/exit, notices fade.
- First renders of sheets and overlays do not animate their contents.

## Reduced motion

Nothing moves or scales. Sheets, rows and alerts only fade. Text swaps,
the pill, the sidebar and layout changes are instant, and the skeleton
reveal is instant.

## Copy audit

No UI text changed.

## Unverified

See #298. That PR has the device checks for both stages.
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 21, 2026
…1089)

## Change

- Drive the sidebar and conversation boundary from the same animation.
The sidebar keeps its content width during the toggle. Changes across
the wide-layout breakpoint and toggles with Reduce Motion apply
immediately.
- Add a drag handle in wide Android and iOS windows. The app saves the
width per pairing on release. Double tap restores the default. Screen
readers can adjust the width and restore the default.

## Verification

- Passed locally: formatting and lint on edited files, mobile typecheck,
and Expo bundle export for Android and iOS.
- Native runtime verification is pending. The device tool could not
confirm ownership of the Android emulator. Check rapid toggles and live
resizing on a foldable and an iPad, including a long thread. The
measurements in #298 found dropped frames while the older implementation
reflowed a 40-turn thread during width animations.
- The full verification gate runs in GitHub CI.
- Copy audit (docs/copy.md §8): the new screen-reader labels are “Resize
sidebar” and “Restore default width.” Both name the action directly. The
control exposes its current value and adjustment range.

Fixes: #298
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