Skip to content

feat(mobile): step back to the previous message in chat - #37238

Open
gsxdsm wants to merge 16 commits into
stablyai:mainfrom
gsxdsm:feat/mobile-chat-previous-message
Open

gsxdsm wants to merge 16 commits into
stablyai:mainfrom
gsxdsm:feat/mobile-chat-previous-message

Conversation

@gsxdsm

@gsxdsm gsxdsm commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

ELI5

In a long chat on the phone, a new ↑ button above "jump to latest" takes you to the start of the previous message. Tap it again to keep stepping back, one message at a time.

What Changed

  • MobileNativeChatFloatingControls stacks a previous-message button (same size, style and spacing) above the existing jump-to-latest button.
  • A pure target function picks the nearest drawn user or assistant row whose top is above the viewport top (8px threshold, so a message already aligned at the top steps to the one before it). Tool, reasoning and system rows are skipped because they sit inside a turn; rows folded into a work run or folded away are skipped because they aren't drawn; a tool-only turn is skipped, so taps walk message boundaries.
  • A tap detaches tail-follow, then smooth-scrolls so that message's start sits at the top of the transcript. This works with the virtualized list, rows not yet measured, and pinch-scaled text.
  • The up arrow shows whenever a previous message exists, including while following the tail; it hides at the first message. Jump-to-latest keeps its existing show rule.
  • Respects the iPhone Duo status column and side rail (collapsed and expanded).
  • One new localized string: session.nativeChatFloatingControls.previousMessage (accessibility label).

Why

Agent transcripts get long, and much of the length is tool output. Scrolling manually to find where the previous message began is slow, especially on a phone. Message-boundary stepping is the navigation people actually want.

Linked Issue

Fixes #37237

Visual Proof

Layout mockups (iPhone; Duo cover and inner, landscape and portrait, chat collapsed and expanded) are attached in a comment; the feature was confirmed on an iPhone Duo device.

Testing

  • Focused tests for the previous-message target computation (thresholds, skipped row kinds, tool-only turns, first message).
  • Chat-view tests; pnpm typecheck && pnpm typecheck:tests in mobile; root pnpm tc; node config/scripts/verify-mobile-localization.mjs; npx oxlint.
  • Full mobile vitest: only known local-environment failures (NoticeRow react-native-svg symlink, two agent-launch tests, and a document-bundle test resolving through shared node_modules).
  • On device: in a long chat, tap ↑ repeatedly from the tail and confirm each tap lands at the top of the previous message, and that it hides at the first message.

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • Resume reviews
  • Trigger review
Walkthrough

The mobile native chat adds a floating control to navigate to the start of a previous user or assistant message. It selects eligible transcript rows, determines whether a target is measured or pending, and aligns or scrolls the list to reveal it. The floating controls stack the previous-message button above the jump-to-latest button. The composer now disables sending whenever a prompt is shown.

Severity of issue fixed: Low

Merge Risk: Low · previous review 2c2b3

Navigation can occasionally move back after a jump to latest or hide the previous-message button. Both cases have manual scrolling workarounds.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 46.15% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed

Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: adding previous-message navigation in mobile chat.
Description check Passed The description explains the user experience, implementation, rationale, linked issue, visual proof, and testing results. It omits the template's Risk, Review, Notes, and Checklist sections, but it is…
Linked Issues check Passed [#37237] requires an up-arrow control above jump-to-latest. It must scroll the start of the previous user or assistant message to the top. Repeated taps must step back message by message, skipping too…
Out of Scope Changes check Passed The raw summary states that the composer send-disabled condition changed. A focused diff of MobileNativeChatView.tsx (base to head) shows an inline refactor, not a behavior change. The expression `exp…
Full details: Description check

Explanation

The description explains the user experience, implementation, rationale, linked issue, visual proof, and testing results. It omits the template's Risk, Review, Notes, and Checklist sections, but it is otherwise sufficiently complete and focused.

Full details: Linked Issues check

Explanation

[#37237] requires an up-arrow control above jump-to-latest. It must scroll the start of the previous user or assistant message to the top. Repeated taps must step back message by message, skipping tool, reasoning, and system rows.

Evidence at the reviewed head:

  • MobileNativeChatFloatingControls.tsx adds showPreviousMessage and onJumpToPrevious. The previous button stacks above the latest button. The summary reports a localized accessibility label, and the locale file adds session.nativeChatFloatingControls.previousMessage.
  • mobile-native-chat-previous-message.ts defines isPreviousMessageStop. It accepts only user or assistant rows that do not join a work run and are not folded away. Tool, reasoning, and system rows are excluded.
  • previousMessageTarget selects the nearest measured stop above the viewport threshold. Stops that are not yet drawn are handled through pending keys.
  • use-mobile-native-chat-previous-stops.ts keeps the stop keys current. use-mobile-native-chat-tail-follow.ts detaches tail-follow and calls revealPreviousMessage on a tap.
  • use-mobile-native-chat-previous-align.ts and MobileNativeChatRowList.tsx handle unmeasured and virtualized rows. They retry index-based scrolling for rows that are not yet measured.
  • mobile-native-chat-previous-message.test.ts covers thresholds, skipped row kinds, unmeasured stops, and first-message behavior.

The changes since the previous review add cancellation handling and index-based scrolling for unmounted rows. These support the same navigation requirement. The previous PASS conclusion still holds.

Uncertainty: the native row list and align hook were assessed from the whole-PR summary and the commit summary, not a full line-by-line read. No unmet requirement was found.

Full details: Out of Scope Changes check

Explanation

The raw summary states that the composer send-disabled condition changed. A focused diff of MobileNativeChatView.tsx (base to head) shows an inline refactor, not a behavior change. The expression expandedPromptOwnsSend = !structuredActivityUi && promptShown is inlined as sendDisabled={!structuredActivityUi && promptShown}. The condition is identical, so the earlier conclusion still holds.

Other changes map to the navigation feature:

  • Floating controls, style constants, and the lucide-react-native test mocks (ArrowUp) support the stacked button.
  • mobile-native-chat-reading-place.ts (mobileNativeChatRowViewportTops) supplies viewport positions for the target row.
  • The previous-stops, previous-align, and tail-follow hooks implement target selection and programmatic reveal.
  • MobileNativeChatRowList.tsx changes support layout tracking and unmeasured-row scrolling. The summary says tail-follow, gesture, and list configuration are retained.
  • Test files add coverage for the new behavior.

No demonstrated unrelated change was found.

Uncertainty: the MobileNativeChatRowList.tsx diff (+257/-24) was not read line by line. The assessment relies on the summary for that file.

Full details: Docstring Coverage

Explanation

Docstring coverage is 46.15% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 13 functions across 21 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f34baff5-a102-4fbd-bb51-a02a844c48b5
Commits

Reviewing files that changed from the base of the PR and between c6b35bd and a9159f8.

Files selected for processing: 22
  • mobile/src/i18n/locales/en.json
  • mobile/src/session/MobileNativeChatView.streaming-rows.test.ts
  • mobile/src/session/mobile-native-chat-reading-place.ts
  • mobile/src/session/native-chat/MobileNativeChatFloatingControls.tsx
  • mobile/src/session/native-chat/MobileNativeChatView.composer-lock.test.ts
  • mobile/src/session/native-chat/MobileNativeChatView.failure-banner.test.ts
  • mobile/src/session/native-chat/MobileNativeChatView.history-paging.test.ts
  • mobile/src/session/native-chat/MobileNativeChatView.rows.test.ts
  • mobile/src/session/native-chat/MobileNativeChatView.stop.test.ts
  • mobile/src/session/native-chat/MobileNativeChatView.tail-follow.test.ts
  • mobile/src/session/native-chat/MobileNativeChatView.tsx
  • mobile/src/session/native-chat/MobileNativeChatView.turn-status.test.ts
  • mobile/src/session/native-chat/MobileNativeChatView.waiting-rows.test.ts
  • mobile/src/session/native-chat/mobile-native-chat-merged-snapshot-parity-hooks.test.tsx
  • mobile/src/session/native-chat/mobile-native-chat-view-styles.ts
  • mobile/src/session/native-chat/transcript/MobileNativeChatPageList.tsx
  • mobile/src/session/native-chat/transcript/MobileNativeChatRowList.tsx
  • mobile/src/session/native-chat/transcript/mobile-native-chat-previous-message.test.ts
  • mobile/src/session/native-chat/transcript/mobile-native-chat-previous-message.ts
  • mobile/src/session/native-chat/transcript/use-mobile-native-chat-previous-align.ts
  • mobile/src/session/native-chat/transcript/use-mobile-native-chat-previous-stops.ts
  • mobile/src/session/native-chat/transcript/use-mobile-native-chat-tail-follow.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow-up Comments

Outside diff Keep previous-message navigation available when no stop is measured.

65-68: Major · Functional Correctness · Heavy lift

Keep previous-message navigation available when no stop is measured.

If a long tool-only stretch places every user and assistant row outside the render window, every stop has an undefined top. This return path hides the control even when an earlier message exists. Use the list position or row indexes to establish availability without requiring a measured stop. Keep the first-message boundary check. React Native renders only a finite window of rows. (reactnative.dev)

Open the source location


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9b1c3d5e-a2d4-41bf-9f15-d8b526e94112
Commits

Reviewing files that changed from the base of the PR and between a9159f8 and 45777ab.

Files selected for processing: 6
  • mobile/src/session/native-chat/MobileNativeChatFloatingControls.tsx
  • mobile/src/session/native-chat/transcript/MobileNativeChatPageList.tsx
  • mobile/src/session/native-chat/transcript/MobileNativeChatRowList.tsx
  • mobile/src/session/native-chat/transcript/mobile-native-chat-previous-message.test.ts
  • mobile/src/session/native-chat/transcript/mobile-native-chat-previous-message.ts
  • mobile/src/session/native-chat/transcript/use-mobile-native-chat-previous-align.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ab23e8e2-3a2d-4cee-9be9-70762b98bea1
Commits

Reviewing files that changed from the base of the PR and between 45777ab and d906ebf.

Files selected for processing: 2
  • mobile/src/session/native-chat/transcript/MobileNativeChatPageList.tsx
  • mobile/src/session/native-chat/transcript/use-mobile-native-chat-previous-align.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0d2b7ebd-1cfc-4b1d-9b0f-07290d0a2944
Commits

Reviewing files that changed from the base of the PR and between d906ebf and c4f13be.

Files selected for processing: 1
  • mobile/src/session/native-chat/transcript/MobileNativeChatRowList.tsx

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow-up Comments

Outside diff Cancel a pending index jump when another scroll takes over.

193-198: Minor · Functional Correctness · Quick win

Cancel a pending index jump when another scroll takes over.

If the previous-message button selects an unmounted row, the list stores jump.retry. A jump-to-latest then calls scrollToEnd without clearing that retry. When the old row reports its layout, PreviousMessageCell calls scrollToOffset and moves the reader back. Clear the retry in scrollToEnd and scrollToOffset. Also guard the queued index retry against a canceled jump. (raw.githubusercontent.com)

Open the source location


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: cb91b47b-361b-4f87-b7f7-2d8dd89ce43f
Commits

Reviewing files that changed from the base of the PR and between c4f13be and 2c2b3b2.

Files selected for processing: 4
  • mobile/src/session/native-chat/transcript/MobileNativeChatRowList.tsx
  • mobile/src/session/native-chat/transcript/mobile-native-chat-previous-message.test.ts
  • mobile/src/session/native-chat/transcript/mobile-native-chat-previous-message.ts
  • mobile/src/session/native-chat/transcript/use-mobile-native-chat-previous-align.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.

@gsxdsm

gsxdsm commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

Fixed on e92fa8f. scrollToEnd, scrollToOffset, and a drag clear a pending previous-message index jump. The queued scrollToIndex retry does not run after that, so a late layout cannot pull the reader back.

#37238 (review)

@gsxdsm
gsxdsm force-pushed the feat/mobile-chat-previous-message branch from 1f08ff1 to 95b5925 Compare November 2, 2026 11:44
@gsxdsm

gsxdsm commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

Visual proof

Real iOS Simulator screenshots (iPhone 17 Pro Max). Personal info is covered with black boxes.

Previous-message arrow stacked above jump-to-latest

@gsxdsm
gsxdsm force-pushed the feat/mobile-chat-previous-message branch from 95b5925 to f9d80ee Compare November 3, 2026 11:42
@gsxdsm
gsxdsm force-pushed the feat/mobile-chat-previous-message branch 7 times, most recently from e05ac15 to 59acddb Compare November 4, 2026 11:42
gsxdsm and others added 12 commits November 5, 2026 12:03
Add an up arrow above jump-to-latest. Each tap aligns the start of the previous drawn user or assistant message to the top of the transcript.
The up arrow's native fade and its JS lift shared one animated node, so iOS and Android threw on mount. A FlatList hole, and a later cell reporting y=0, both aimed the jump at the wrong place. A pending align now retries until the row is measured.
The align animation kept writing scrollTop after a touch or a jump to the latest message. Those paths cancel the frame, and a frame that was already queued does not write.
FlatList unmounts cells outside the render window. Keeping their y sent the previous-message jump to a stale position after earlier rows changed.
… cancelled

A touch that stops the jump and does not scroll never reaches notePlace, so keepPlace would restore the pre-jump line.
When a cell unmounts, its cached offset is gone. If that row is still above the first visible row, scroll to its index instead of an older measured stop.
… takes over

scrollToEnd, scrollToOffset, and a drag clear the native index retry. A queued scrollToIndex does not run after that, so a late layout cannot pull the reader back.
A tap while the transcript was still moving measured that in-between offset and eased from a stale start, so the message missed the top. Another tap before the ease finished aimed at the same row.

Stop the fling, then choose the row. A tap during a jump steps from the committed row, and the jump's own scroll events do not count as the reader taking over.
A native list reports offset 0 until something actually scrolls, so the first taps after opening a chat measured every row as already on screen. A mount scroll event of 0 is still the tail: read that offset from the measured rows until a finger drag or a non-zero offset. The jump waits one frame so the stop does not drop it, and the stop's momentum end does not hand the list back to tail follow.

If the current message's top is above the viewport, the first tap brings that message's start up, and the next tap steps to the one before it.
…w list

The fresh-tail jump and the pinch scroll view do not both fit in the row list's line cap.
A page click on the lucide path never runs Pressable onPress. The icon ignores hits so the first tap on either arrow jumps.

This branch has not been deployed

No deployments
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.

Mobile chat: step back to the start of the previous message

1 participant