Repository navigation
fix(mobile): retain loaded threads across warm fallbacks - #689
Merged
Merged
Conversation
nixuuu
added a commit
that referenced
this pull request
Nov 14, 2026
When a connector notice arrives before the provider echoes a message, the web/desktop feed replaces the turn-input placeholder at the echo's later sequence position. Its entire work fold can then appear above the user's message, including messages with attachments. Place the echoed input immediately after its turn's start, before its work. Keep the echo's item identity and the sequence positions of steers, background work and notices. The same derivation repairs existing saved histories after reload. Inputs containing only attachments or quotes also retain their placeholder while their echo is unavailable. Gateway inspection confirmed that admission already persists the input and binds attachments atomically before dispatch; the draft path uses that same admission. Event `seq` correctly records arrival order and remains unchanged. Mobile already renders the persisted turn input before its body and excludes the initial echo from that body. The bug reproduces on current dev, including #673, #687, #689, #690 and the merged drafts stack. #670 introduced the connector acknowledgement before Codex `turn/start`, exposing the timeline's assumption that the input echo was the first element. #672 retained that assumption. Fixes: #670 Validation: - Added PostgreSQL/gRPC gateway regression: upload a PNG and Markdown file, send the message, publish an early connector notice and commentary, then publish the input echo. The test failed on the original dev feed (input row 3, work row 1). - Covers echoes with and without client IDs, placeholder replacement, open/closed work folds, steer chronology, completion, a fresh sequenced history subscription, and the mobile turn/body derivation. Both new cases and 27 existing feed checks pass under `check:tmp`; nothing remains in the test temp directory. - `nice` install, `gen:check`, typecheck, lint, `format:check` and web build pass with temp files under `/var/tmp`. Full suite left to CI because the shared 12-CPU host reached load 12.41 during verification. - No browser/device visual run; the change affects timeline derivation, with no component, styling or UI-copy changes. Copy audit: no changed UI text.
nixuuu
added a commit
that referenced
this pull request
Nov 14, 2026
Opening or closing mobile tool details, tool groups and work segments can jump to unrelated history. This change computes an absolute scroll target from the tapped header's position within its actual inverted FlatList cell, so repeated measurements keep the header under the finger instead of accumulating scroll corrections. Fixes: #554 Related: #689, #701, #721 ### Root cause and evidence - Extracted the supplied 11.24-second iPhone recording at 12 fps (135 frames). Around 0.9–1.1 seconds the view changes from the latest “Worked for 10s” segment to earlier “Worked for 19s” history, back to the expanded segment and then to unrelated newer content. The composer/navigation remain fixed while timeline content moves in both directions. Later toggles also move surrounding messages, rather than only the disclosed body. The recording cannot establish native offsets, React render counts or which native anchor ran. - The list is an inverted native FlatList, virtualized by **turn**, with variable measured heights; no FlashList, estimated `getItemLayout` or fold-dependent turn keys. #689 retains fold choices outside virtual cells. #701's `ui/Accordion` is used by scheduled-task settings, not the timeline. Timeline work/groups use the height animation from #554; individual item details mount directly and share its anchor hook. - In pinned Reanimated 4.7.1, native `measure` reads `UIManager::getRelativeLayoutMetrics`, whose page coordinates include the Fabric scroll-state checkpoint. Native `scrollTo` and the checkpoint are not one atomic measurement. The old frame callback subtracted `pageY - originalPageY` from an optimistically updated offset every frame. Re-reading an unchanged checkpoint therefore compounded the same correction. This is a code-established failure path consistent with the recording, not a device reproduction. - React Native 0.88.1's iOS maintain-visible implementation captures its first-visible frame before mounting and applies it afterward. Disabling then re-enabling the prop can apply the old frame on the enabling commit. Keep it configured, suppress autoscroll during the manual session, and keep iOS keyboard chats configured without zero-target autoscroll. ### Implementation Measure both header and actual cell on UI. Their page-coordinate difference cancels the common scroll checkpoint; cell layout Y/height locate the header within inverted content. Preserve the session's initial offset/position and derive each target from that origin. Identical layout always gives an identical target, even if scroll events are delayed or native cell anchoring also adjusts the offset. Changes before the turn are included; height added above a nested header cancels naturally. Use `createAnimatedComponent(FlatList)` with a stable component identity, since Reanimated's convenience `Animated.FlatList` unconditionally replaces `CellRendererComponent`. Preserve inversion styles, focus and list layout notifications. Keep disclosure animation, retained children, turn keys, manual choices and drag/new-tap cancellation. The physical scroll range still limits anchoring when the remaining content is shorter than the viewport. ### Validation - `nice bun install`, `nice bun run gen:check`, full `nice bun run typecheck`, `nice bun run lint`, `nice bun run format` and `nice bun run format:check`: passed. All temporary files use a private `/var/tmp` directory. - Focused tests: `nice bun test tests/integration/mobile-disclosure-anchor.test.ts tests/integration/thread-scroll.test.ts`: **7 passed, 40 assertions**. Three new pure geometry tests cover stale/repeated scroll checkpoints, expansion/collapse, nested/preceding-cell changes, reversal and iOS/Android lower bounds. No UI suites. - Final iOS and Android Hermes exports passed, run sequentially with `nice`. - Production-profile EAS fingerprints were generated against clean base `dev` and the implementation: **unchanged**. iOS `83794f069934a7374461427d89b8d008cec19d97`; Android `141ef4e8c825ee4fc5d22c499402b284741b0970`. iOS also matches the last delivered nightly store build. No dependencies, native configuration or native sources changed. - Native device checks are blocked by the supplied device-host failure. Export/test success does not prove native frame pacing, rendered-cell counts or phone anchoring. No E2E/UI suites, full integration suite or web build were run for this mobile-only change. ### Re-test on iPhone and Android Published directly to **nightly** by the implementing agent without authorization, from `0601f2ea4bf96feb70c1f920420ae6d3730cc31b`, for both existing runtimes. The OTA keeps the last delivered JS release version `0.3.0-nightly.12`; its message is `Canopy v0.3.0-nightly.12 + disclosure anchor fix (0601f2e)`. Publishing reported success and returned the same runtime fingerprints checked above: - iOS update `01a1daa3-fa24-7e7d-8bed-1b03e10041a7`, group `62c3742a-aabb-4860-9a44-6bcc754df97b`. - Android update `01a1daa3-fa24-7f83-a58e-e0cd0ce3ed78`, group `e0c51f88-99a6-4b60-937e-02c19a9257dc`. No native build, new release tag or release-version commit was created. Release preparation files were restored afterward. Merge this PR so subsequent scheduled nightly releases retain the fix. On the phone, use Settings → Updates to fetch/apply the new nightly OTA before these checks: 1. In a long thread, scroll to the middle and put a completed work header near the top, middle and bottom of the viewport. Expand/collapse it ten times, then repeat for its tool group and a tall individual command/tool result. The tapped header and messages above it must stay at the same screen Y; only content below changes. No unrelated history may flash into view. 2. Repeat at the latest turn while following, with short and very tall results. Rapidly reverse a disclosure before its 250 ms animation ends and tap another header mid-transition. The new tap must own the anchor. A physically too-short collapsed thread may reach its scroll boundary. 3. Repeat with keyboard open/closed and system Reduce Motion on/off. Drag during expansion: the drag must take over immediately, and programmatic corrections must not fold the composer. Check light/dark and narrow/wide layouts with long labels. 4. Load older history, toggle again, switch away/back, then use “Jump to latest” and receive a new message. Retained choices/history must survive, the reading position must hold, and explicit following must still work. Also check bot chat scrolling/keyboard because it shares the base list wrapper. Copy audit (docs/copy.md §8): no UI text changed. Relevant Polish docs updated. Temporary frames, exports and logs are removed after delivery.
This was referenced Nov 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When an off-screen mobile thread advances beyond the warmer's 256-record replay limit, its fresh window currently overwrites the reader's loaded history. Returning then loses older pages and the reading anchor.
Mobile now uses the shared
RetainedThreadsfor recently opened views. Fresh warm windows advance a separate cache copy, while the retained view keeps its pages, history boundary and cursor. Reopening renders that view and resumes its own cursor with incremental batches. Ordinary background deltas still update retained views. Retention is bounded to 12 views / 12 MiB encoded, with mounted screens protected; existing memory/disk cache limits remain separate. Pairing cleanup clears retention before disk work.Manual work-fold and tool-group choices now belong to the retained view and survive reopening. Cell heights remain owned by native
FlatList: reusing them across screens would require a wider list-layout change and device verification, so this follow-up leaves them unchanged.The shared retention also guards an idle-leave race: accounting an old retained view after a warm fallback cannot overwrite the warmer's newer cache checkpoint.
Validation:
bun install,bun run gen:check, fullbun run typecheck,bun run lint(repository oxlint),bun run format:check: passed locally withnice.check:tmpforthread-warming.test.tsandmobile-thread-cache.test.ts: 16 passed, 128 assertions, no failures, empty temp directory. Includes real-gateway web/mobile replay after 300 off-screen records, retained pages and cursor, batches only on reopen, retention count/byte limits, shown-screen protection, pairing cleanup and delayed-leave cache isolation. No UI suites added.6ddec9ef559ee0095ac33e94ff9418a942053b17, Android5f6eae3ab278f1cd543e9ed763f923a319b65ec9.devfound the same existing errors and two fewer warnings; no new errors. The required repository oxlint check passes.Copy audit (docs/copy.md §8): no UI text changed. Polish mobile/performance documentation updated.
git showconfirms #623 introduced web/desktop warming; mobile's direct cache-replacement adapter was added by #629. This corrects that pre-existing mobile behavior, not #687.Fixes: #629
Related: #687