Repository navigation
feat(mobile): animate ui state changes with reanimated - #298
Merged
Merged
Conversation
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
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.
This was referenced Nov 6, 2026
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.
This was referenced Nov 13, 2026
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
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.
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
FloatingComposer, appearance only).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.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.Switchalready animates its thumb.LayoutAnimationConfigin the Stack'sscreenLayout, 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
useArrivals). Rows that remount while scrolling appear at once, and virtualized rows have no exit animations. The timeline animates opacity only, never height.Verification
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.Unverified / known
maintainVisibleContentPositionon Android is the likely cause.Copy audit
No UI text changed.