Repository navigation
Keep phone chat history in one window while preserving reading position - #29271
Conversation
…r tap On the phone page a scroll near the top paged in older history, often while iOS was still bouncing the list past the top. The place-hold then wrote scrollTop while WebKit owned the scroll, and the list stopped scrolling until the reader left the chat. The page now loads older history only from the existing Load earlier control (the native app keeps its drag paging), and the place-hold never writes while the list is bounced past either end.
…ked for A replayed snapshot cancelled any in-flight "Load earlier messages" page, even when the replay merged onto the same window and cursor, and every other lost page (host refusal, error reply, transport drop) was swallowed, so the control went back to its label as if nothing had been tried. A page now lands unless its window was replaced or the cursor it was sent from changed. A page that is lost shows one line under the control, "Couldn't load earlier messages. Tap to try again.", cleared by the next tap or a page that lands.
…d loader, bounded to one tap's budget
…loader A failed page now shows the retry line instead of an invisible chat error, history that can never be read ends paging, and one tap shares one budget.
…r both chat types A retryable failure keeps the button with the retry line; history that can never be read swaps the button for one line saying so; scrolling at the top no longer re-fires a failed read.
…le, retries on a tap, and ends at unreadable history
…he page goldens Hand-updated: only the nativeChat.readSession options change (absent -> 15 s budget spanning connect); every value is re-hashed and re-keyed as the recorder does.
…s the subscription's reload replaces the window Only a final read refusal (damaged history, or saved by a newer Orca) ends a tap at 'Earlier messages can't be loaded.'; the test now drives that reachable path.
# Conflicts: # mobile/src/session/MobileNativeChatView.tsx
…y paging change
A folded row's id is its first message's, so an older page that brings the start of a tool run (or an older sibling of a roster) replaced the displayed row: the list remounted it and the page's history split lost its first row. Rows now carry a presentation key that stays while any of their messages draw, handed on from the last committed render by the raw message ids each row draws, and a vanished key resolves to the row that took its messages.
…ollowing one to the follow owner The place-hold fired on the first drawn row's id, which a kept row key no longer changes, and held the lowest row on screen even while the reader followed the end, so at the 2,000 cap it wrote against the follow owner. It now fires when the source window's first message changes (an older page, a cap trim), only for a reader who is not following, and puts back the first tagged row on screen, else the nearest row the update kept, through the row keys. iOS bounce still gets no write.
…ls join it With the run's row kept, older calls joining its front pushed the lines the reader was on behind Show more. The reveal now counts the lines added above its first line apart from what Show more asked for, so those lines stay shown, each diff keeps its share, and Show less only undoes Show more. Lines and the run are tagged, so the page's hold puts the line being read back where it was. The flow test opens a chat inside a silent run, loads the rest from an old host's cursorless reply, then lands a reply and a send.
…already drew Pairing the run again for its first line on every render broke the bounded pairing a 2,049-call run relies on (one pairing per reveal). The flow test's icon mock names every icon the run reads.
Row-key hand-on walked the current rows oldest first, so when a trim left a run's first result alone above it, that orphan took the run's key and the open run remounted closed. Walk newest row first so the run keeps it.
…o the results it shows A cap trim that split the top run gave the run's key to whichever split-off result row a position-ordered scan met first: the result above it for calls made one at a time, the one below it for parallel calls. The run then remounted closed and the reader's line went. Each row is now identified by its own sources (a run by its assistant and call messages, a roster by its group, a lone result row by its results) and keeps the key of the one previous row it continues; results are content only. A key no row kept resolves to the row that took in what it drew. If identity ever came from two rows, neither inherits.
…t is still the same part The hold took a line only from the first row on screen and otherwise trusted that row's container. A result row absorbed by its run, a roster the fold moved to an older sibling, or a trimmed line then moved the reader. It now lists the tool lines on screen across every row (a run header only when no line shows, a row top only when neither), and puts back the first one still drawn: a run header only in the row that kept its key, a row top only while the same message places that row. One write, skipped under half a pixel.
… the hold's last cases into it An open run whose header is above the screen holds nothing: with only its Show more on screen, the rows after it keep their height when older calls join. Removing the header-on-screen check moves them 840 px. The collapsed case now checks the same rows. The iOS bounce and native cases move into the flow test over its page model, so the hold's separate fake scroller goes.
…t when the transcript grows RN Web reports content size a task after layout, so with no browser scroll anchoring a following reader saw one frame far above the end after Load earlier. One ResizeObserver over the page scroller and its content, bound to the list's mount, calls the same pin, which reads the live end and writes only when short of it.
…and layout to the live end The page's follow tests fold into one flow so the view test stays within its line limit; the place-hold reads the follow owner through one prop bag so the view does too.
The native list never needs the resize observer, so it shouldn't reach for the page-only node at attach.
…ser's scroll anchor At the 2,000-message cap a trim plus an append of the same height changes no size, so the follow owner hears nothing, and Chromium's scroll anchoring keeps a visible message still, scrolling the reader one message off the end each time. While the reader follows, the page's scroller now takes the transcript out of anchoring and leaves a 1 px end marker as the anchor. Parked readers and native lists are unchanged.
…e the list still glides The page's WebKit place-hold wrote its correction only at rest, so a regroup committed within 150 ms of a reader scroll (or mid-glide after a tap outside the list) skipped it, and nothing redid it: the text the reader was on moved by the regrouped rows' change and stayed there. Unlike a source change, whose new rows stay out of the spacer until measured at rest, a regroup resizes drawn rows at once. It now corrects at once, as main's hold always did.
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Merge Risk: 🔵 Low · up to
|
Resolve the phone chat lane against main's tool runs, timestamps and chat-switch follow
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
🟡 Minor · Filter nested-root input before updating page motion. · mobile-native-chat-page-motion.ts:57-149
mobile/src/session/mobile-native-chat-page-motion.ts:57-149
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winFilter nested-root input before updating page motion.
motion.attach(s)receives bubbled touch, wheel, and key events fromMobileNativeChatOwnedScrollView. The outer motion then records nested scrolling as outertouching,way, and recent input. During a concurrent outer layout shift,scrolled()can classify the shift asreader. The page then takes an anchor at the shifted position and skips the layout-only correction path, which can move the outer reading position.Filter events whose target is inside a
[data-chat-scroll-root]before updating the outer motion state. Apply the filter to touch, wheel, and key events.Suggested fix
diff --git a/mobile/src/session/mobile-native-chat-page-motion.ts b/mobile/src/session/mobile-native-chat-page-motion.ts @@ - attach(scroller: Listened, acceptsKey: (event: unknown) => boolean = () => true): () => void { + attach( + scroller: Listened, + acceptsKey: (event: unknown) => boolean = () => true, + acceptsInput: (event: unknown) => boolean = () => true + ): () => void { @@ - if (way !== 0 && acceptsKey(event)) { + if (way !== 0 && acceptsKey(event) && acceptsInput(event)) { input(way) } @@ const start = (event: unknown) => { + if (!acceptsInput(event)) return this.lastTouchY = touchY(event) input(0) this.touch(true) @@ - [scroller, 'touchend', () => this.touch(false)], - [scroller, 'touchcancel', () => this.touch(false)], - [scroller, 'touchmove', move], - [scroller, 'wheel', (event) => input(wheelWay(event))], + [scroller, 'touchend', (event) => acceptsInput(event) && this.touch(false)], + [scroller, 'touchcancel', (event) => acceptsInput(event) && this.touch(false)], + [scroller, 'touchmove', (event) => acceptsInput(event) && move(event)], + [scroller, 'wheel', (event) => acceptsInput(event) && input(wheelWay(event))],diff --git a/mobile/src/session/use-mobile-native-chat-page-window.ts b/mobile/src/session/use-mobile-native-chat-page-window.ts @@ - const detach = motion.attach(s) + const acceptsPageInput = (event: unknown) => { + const target = + typeof event === 'object' && event !== null && 'target' in event ? event.target : undefined + return !( + typeof Element !== 'undefined' && + target instanceof Element && + target.closest('[data-chat-scroll-root]') + ) + } + const detach = motion.attach(s, acceptsPageInput, acceptsPageInput)
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
d1f6cc38-c62d-4e00-af70-84199c038e98
📒 Files selected for processing: 25
mobile/src/session/MobileNativeChatDiffCard.tsxmobile/src/session/MobileNativeChatLiveLine.tsxmobile/src/session/MobileNativeChatMessage.tsxmobile/src/session/MobileNativeChatOwnedScrollView.tsxmobile/src/session/MobileNativeChatPageList.tsxmobile/src/session/MobileNativeChatReasoningRow.tsxmobile/src/session/MobileNativeChatScrollHold.tsxmobile/src/session/MobileNativeChatTaskList.tsxmobile/src/session/MobileNativeChatToolLine.tsxmobile/src/session/MobileNativeChatToolRun.tsxmobile/src/session/MobileNativeChatView.tsxmobile/src/session/mobile-native-chat-disclosure-store.tsmobile/src/session/mobile-native-chat-page-heights.test.tsmobile/src/session/mobile-native-chat-page-motion.tsmobile/src/session/mobile-native-chat-page-rows.tsmobile/src/session/mobile-native-chat-page-window-state.tsmobile/src/session/mobile-native-chat-row-keys.tsmobile/src/session/mobile-native-chat-run-descriptors.tsmobile/src/session/mobile-native-chat-scroll-ownership.test.tsxmobile/src/session/mobile-native-chat-scroll-root-handle.tsmobile/src/session/mobile-native-chat-scroll-roots.tsmobile/src/session/mobile-native-chat-tool-run-props.tsmobile/src/session/use-mobile-native-chat-page-window.tsmobile/src/session/use-mobile-native-chat-row-renderer.tsxmobile/src/session/use-mobile-native-chat-turn-disclosure.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
…ails a terminal that is still loading
On the page each terminal document listens for window errors, and before ready a reported error is
fatal ("Terminal failed to load"). The window is the whole app's, so the browser's ResizeObserver
loop notice, which the chat list's resize work can raise and which carries no error, reached a
terminal mounted in the background and failed it. The guest reporter now forwards only events with
an error behind them.
…clamps the phone page to its end After every resize the page attached following whenever the scroll sat within 1 px of the end, whatever put it there. A collapse below a reader parked near the end makes WebKit clamp onto the shorter end, so the next reply pulled them down. Following now comes only from classified motion (the reader's own move, or a move toward the end), as on main; the resize callback only pins.
…, is its own component Main's composer and tab changes took MobileNativeChatView past its line cap once merged; the platform choice of list and its wiring move out unchanged.
…der follow A clamp onto a shorter end that lands while the reader's finger is still down from tapping a collapse below them is classified as the reader's move, and any reader move ending at the end attached following. Following now attaches only on a move down toward the end, as on main; the test covers the clamp with and without a finger down.
Detach needed a single scroll event moving up more than 1px, so a slow drag that reports many 1px moves never detached, and the next reply pulled the reader back to the end. Any upward move of the reader's that leaves the end now detaches. Found by tracing the remaining iPhone jump.
…e browser's frame does
…t scroll positions A nested box's address is the run's key, then the line's key:command, so the old prefix match on the closed key never reached it and a reopened line restored a stale scroll position.
The problem
This is about the chat page the desktop app serves to a phone browser (iPhone Safari, Android Chrome), not the separate native phone app. On main today, which includes #28413, long chats on that page have four problems people can see:
Why it happens: the page drew older history as a separate block stacked on top of the live list, and it drew every message whether or not it was on screen. It also tried to keep your place by moving the scroll position by hand.
Four earlier PRs (#29137, #29043, #29170, #29198) each fixed one of these symptoms on top of that design. Each fix exposed the next problem in the same place, which is why they are replaced here by one change to the design itself.
Why we want this
How solid these numbers are:
What changes for you
How it works
Nothing changes for the desktop app or the paired servers: there is no new saved data and no change to what client and server send each other. Older paired servers keep working. The native iOS and Android app keeps its own list; only the shared message and tool-box changes reach it.
Why this PR is so big
It is about 2,800 production lines net, all on the phone page under
mobile/. Roughly:Tests are about 1,100 lines net. Most of them cover reading place and scroll ownership, and some replace tests for code this PR deletes.
It is one PR because the pieces only work together:
The four earlier PRs tried to land these one at a time. Their Load earlier messages changes (#29137, #29043) are kept here. The separate history block (#29170) and the end-of-chat marker used to keep up with replies (#29198) are replaced by the one list, so landing those separately would have shipped code this PR deletes. All four are closed in favor of this one, which was reviewed and tested as a whole against main.
Details for reviewers
Differences from the common pattern:
Linked Issue
Follows up #28413. Replaces #29137, #29043, #29170 and #29198, which are closed.
Visual Proof
Main-versus-branch screenshots, tested revisions and capture limits are in the review status comment. The latest comparisons use the iPhone simulator's Safari phone page against pinned main
407bf039c1c.Testing
Full-path round 3 reviewed only the branch-owned delta from
dde20a10b72through76a1fd75f54, after two whole-lane rounds. One fresh reviewer found a P2: returning to the end entirely in one-pixel steps could leave following disabled. The final panel retained the architecture and ruled a narrow repair. Round 4 reviewed only that repair at721af63eacc25a6f1d36452dc0e180799de4f108, agreed it fixes the contract, and found no new proven issue.The whole-diff eight-area readiness review and dedicated six-question performance scan completed, with amendments covering the following repair and owner close-position repair. Counsel was skipped as requested. No new saved field, protocol, dependency or native-list policy was added.
The added Safari regression failed before the repair. All 12 named history-paging tests passed afterward, including the existing slow-up, finger-down/up collapse and expired-fling cases. The normal commit hook passed; tested and committed source hashes match. The earlier whole-lane executable repair passed 108 tests across 13 named files.
Final-head
41ec1610cf0Full PR Checks, including PR checks passed, have passed; Mobile Checks have passed. Skipped jobs are not represented as executed tests.Historical paired iPhone Safari QA after the terminal repair passed cold-terminal-after-paging 5/5 on each arm. On
6f7e873a56b, slow parked reading stayed in place 3/3, normal parked reading 1/1, a long glide to the end followed the next append 3/3, and live following passed 3/3. These captures predate the final repair and are labelled in the status comment.The earlier round-4 iPhone Safari recheck on
721af63eaccpassed: slow return to the actual end followed the next reply 3/3; a slow return stopping 31 points short stayed parked with zero reading-line displacement 3/3 on both branch and main; collapse below a parked reader then append preserved the line 3/3 on the branch, matching earlier main 3/3. A long glide and live 24-chunk stream plus new tool each followed 1/1 on that branch revision, with earlier main comparisons. Main was freshly rerun for the stopped-short case; the actual-end slow-return case was branch-only. The earlier paired run also covered switching chats while history loads and open tool boxes; the branch retained the inner tool line where main collapsed the run. Reconnect remains unverified.The exact-head phone smoke on
41ec1610cf05b664c0c62c3f35652ef3a4120259passed after the owner repair. Fresh output-box comparisons reopened at the top 2/2 on each arm (scrollTop 560 → 0 points). Collapsing a line below an open output preserved the outer page, run position and painted reading line 1/1 (all displacement zero); a subsequent reader gesture moved the run normally. Slow one-point return to the actual end then append followed 2/2, with gap zero before and after. Main was freshly run for output reopen; collapse and actual-end smoke were branch-only. A separately overflowing command box was not tested.Known gaps and limits:
A source-level sampling difference remains: main evaluates throttled scroll reports while this list classifies raw events. The earlier round-4 bounded iPhone comparison found equal parked behavior for a slow return stopping 31 points short, and branch traces confirmed actual-end attachment after one-point moves. This verifies those tested gestures, rather than every timing schedule. Movements below half a point remain physically unverified; no worse outcome is accepted.
Review
The source repair, narrow round 4, final source readiness and bounded Safari recheck are complete. The launcher then repaired an older nested-position review thread at
41ec1610cf05b664c0c62c3f35652ef3a4120259: closing a tool line clears its nested command/output positions so reopening starts fresh, as on main. A narrow source/readiness checkpoint agreed and resolved the thread; this is not a fifth broad source round. Exact-head full PR and Mobile CI are green; the short final-head phone smoke passed. Final disposition and the exact-head marker are maintained in the existing status comment. This description covers the whole lane against main.Agent skill upstream boundary
Notes
Folder and SSH workspaces use the same client-side transcript path. The separate desktop renderer is unchanged by this lane. Author: @BrennanKB5.
Checklist