Skip to content

fix(ios): eliminate one source of chat scroll jitter and freezes (every message rebuilt on each scroll tick) - #165948

Merged
roboclaw-bot merged 1 commit into
openclaw:mainfrom
Marvinthebored:perf/ios-chat-swipe-scroll-state
Nov 4, 2026
Merged

roboclaw-bot merged 1 commit into
openclaw:mainfrom
Marvinthebored:perf/ios-chat-swipe-scroll-state

Conversation

@Marvinthebored

@Marvinthebored Marvinthebored commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Related: #163153

What Problem This Solves

Fixes unnecessary transcript rebuilding when users start and end swipes through long native chats.

Why This Change Was Made

Follow state lives in a reference-held observable owner. Small views observe the size-change anchor and jump-button visibility without subscribing the transcript to those updates. Reader policy, message grouping, and scroll-position storage stay unchanged.

User Impact

Starting and ending a swipe does less transcript work, leaving more capacity for scrolling. Jump to latest retains its existing behavior.

Evidence

Focused shared-kit Swift validation: 17 tests in 2 suites passed (ChatReaderScrollStateTests and ChatScrollCommandTests), using Xcode 27.1 and two build workers after preparing the Mermaid resources.

Matched native swipe proof on an Xcode 27.1 simulator: 60 question-and-answer pairs created through the unchanged local demo chat UI, followed by 16 native swipes on each side. Transcript body, preparation, and row-builder evaluations fell from 33/33/33 to 0/0/0. Both sides observed 16 interacting/decelerating/idle transitions and passed the native test. Jump to latest appeared away from the tail and returned to reply 59 when tapped; screenshots were inspected.

This measures simulator transcript work reduction, not device frame rate or latency. Identical scratch-only instrumentation was applied to both sides and was not included in the patch.

Raw traces, counts, test markers, and instrumentation.

Jump control visible
Jump returned to final reply

The separate keyboard-after-send test failed on both the clean baseline and candidate while waiting for the sent prompt; it does not establish a keyboard-follow improvement or regression from this change.

AI-assisted.

@clawsweeper

clawsweeper Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 6, 2026
@clawsweeper

clawsweeper Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR isolates native chat scroll-follow observation from transcript rendering.

Example: Swipe 16 times through a native chat containing 60 question-and-answer pairs.

  • Before: The supplied baseline trace records 33 transcript body, preparation, and row-builder evaluations.
  • After: The candidate records zero evaluations at all three points, while Jump to latest still returns to reply SWIPE_Q_59.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A narrow, correct performance repair with native production-view proof, preserved reader contracts, and no introduced finding; required CI must still complete.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (logs): Native XCUITest gestures exercised the real shared chat UI in an Xcode 27.1 simulator after creating 60 pairs through the unchanged demo interface; inspected traces show eliminated gesture-driven rebuilding and screenshots show the jump control returning to the final reply. Both changed source blobs match the measured candidate exactly. The single matched run establishes work counts, not physical-device smoothness; the separately reported keyboard test failure is not claimed fixed.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Performance · Worth it: Yes · Fix scope: Complete
User problem: Starting and ending swipes through long native chats unnecessarily rebuilds transcript presentation, consuming capacity needed for scrolling.
Reason: Measured removal of unnecessary work provides clear value while retaining existing output, defaults, reader transitions, and storage behavior.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it removes unnecessary native transcript rebuilding without changing reader policy, and no actionable introduced defect was found; exact-head CI remains pending.

Priority: P2
Reviewed head: 5b531a0728f3bdc26a5a687ef8c0a3b411057b32

Before merge

None.

Findings

None.

Agent review details

How this fits together

The shared SwiftUI chat serves iOS and macOS; scroll geometry and gesture phases update reader state, which controls the size-change anchor and Jump to latest affordance.

flowchart TD
    A[Native scroll gestures] --> B[Geometry and phase callbacks]
    B --> C[Observable follow state]
    C --> D[Size change anchor]
    C --> E[Jump control]
    F[Chat view model] --> G[Transcript rendering]
    E --> H[Existing scroll command]
Loading

Technical review

Best possible solution:

Retain the narrow observation isolation while preserving the existing reader policy, transcript grouping, and one-shot scroll-command owner.

Do we have a high-confidence way to reproduce the issue?

Current main reads scroll-follow State during transcript construction, and the supplied baseline native trace independently shows repeated preparation at gesture transitions; no target code was executed during this review.

Is this the best way to solve the issue?

The patch addresses the observation boundary directly using one reference-held state owner and two narrow rendering consumers, without adding a cache, alternate renderer, or competing reader policy.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 35b1636f135b.

Provenance checked

  • Reader-follow transitions and jump visibility keeps the original intent (improve: make native chat scrolling reader-managed #98258: Preserve the reader's position during incoming content and provide an explicit return to the live edge.)
  • One-shot scroll positioning keeps the original intent (deb1686: Prevent retained scroll targets and repeated commands from starving native interaction.)
  • Size-change anchor and observation isolation keeps the original intent (dde2941: Follow growing live content through native layout while reducing redundant transcript and telemetry work.)
  • Live-edge geometry reconciliation keeps the original intent (734856c: Observe distance changes so lazy layout cannot leave Jump to latest incorrectly hidden.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Pinned introduction and observation boundary: The introduced diff replaces four parent-view State properties with one reference-held observable object and moves their rendering reads into two small views; existing scroll commands and policy transitions remain. (apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatScrollCommand.swift:25, 5b531a0728f3)
  • Current main still has the unnecessary observation: Current main retains the four parent-view State properties and directly reads follow flags while constructing the transcript's default scroll anchor; its affected files match the pinned PR base. (apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatView.swift:130, 35b1636f135b)
  • Native swipe evidence: Inspected the linked README, instrumentation, counts, timestamped traces, native test markers, and downloaded screenshots. Both sides created 60 pairs and exercised 16 interacting/decelerating/idle sequences; evaluation counts changed from 33/33/33 to 0/0/0, and both recorded NATIVE_JUMP_PASS. This establishes work reduction, not device frame rate. (README.md:3)
  • Proof remains applicable after rebase: GitHub contents reads at the measured candidate cde4f192254351cb9ea8cd5b58830cb29ccc0666 return blob IDs 8c40f7330c351cdc62508b680fbb6f9b11024ba4 and de9c5ecfd99886cbdaf619deda5f16ff5f610295, exactly matching both changed files at the reviewed head. (apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatView.swift, 5b531a0728f3)
  • Existing performance intent preserved: The merged streaming-performance work introduced the size-change anchor to follow growing bubbles without a command per word; this PR preserves that behavior while narrowing observation. (apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatView.swift:493, dde29415eb56)
  • One-shot positioning preserved: The native qualification repair introduced one-shot, session-bound scroll commands to prevent layout stalls after repeated sends; this PR leaves that owner intact. (apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatScrollCommand.swift:66, deb168691b2a)

PR surface

Source +30. Total +30 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 96 66 +30
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 96 66 +30

Review metrics

Metric Value Why it matters
Native transcript evaluations during swipes 33/33/33 → 0/0/0 The supplied matched 60-pair, 16-swipe simulator traces measure body, preparation, and row-builder work; they establish eliminated rebuilding without claiming latency or frame-rate improvement.

Labels

Label changes:

  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.

Label justifications:

  • P2: A focused native chat performance improvement removes unnecessary work during ordinary scrolling without changing configuration or message delivery.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (7 earlier review cycles)
  • reviewed 2026-10-06T05:01:01.249Z sha e3639b81a0d7cd71b904576435b5824cc8efe1ed :: needs changes before merge. :: none
  • reviewed 2026-10-14T02:29:57.613Z sha f6205a7b5f10d00276ccbbcc9a45a5c15c9d5fc8 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-21T01:26:45.414Z sha e6de8f65d1c3f6c8a1458a86f9bce393660dc049 :: blocked before merge. :: none
  • reviewed 2026-10-24T02:26:49.983Z sha 17f192d79cd18a480278dea81abe2c9335ee9d5f :: blocked before merge. :: [P2] Keep history groups in one stable ForEach
  • reviewed 2026-10-24T03:30:33.776Z sha 261fdcc0bb5c7aab3ed236cdc2b56d77d646ca42 :: blocked before merge. :: none
  • reviewed 2026-11-01T17:21:26.513Z sha cde4f192254351cb9ea8cd5b58830cb29ccc0666 :: needs real behavior proof before merge. :: none
  • reviewed 2026-11-01T18:27:42.295Z sha cde4f192254351cb9ea8cd5b58830cb29ccc0666 :: needs maintainer review before merge. :: none

Reviewed November 2, 2026, 11:01 AM ET / 16:01 UTC (Revision 8).

@Marvinthebored
Marvinthebored force-pushed the perf/ios-chat-swipe-scroll-state branch from e3639b8 to f6205a7 Compare October 14, 2026 02:20
@clawsweeper clawsweeper Bot added proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 14, 2026
@Marvinthebored
Marvinthebored force-pushed the perf/ios-chat-swipe-scroll-state branch from f6205a7 to e6de8f6 Compare October 20, 2026 15:10
@Marvinthebored
Marvinthebored marked this pull request as ready for review October 20, 2026 15:10
@Marvinthebored

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Oct 21, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked. labels Nov 1, 2026
@Marvinthebored

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 1, 2026
The follow flags flip when a swipe starts and ends. They were @State read by the
chat view's body, so each flip re-evaluated the view and rebuilt every transcript row.

Hold that state in an observable object that only the follow anchor and the
jump-to-latest slot read. Scroll handling is unchanged.
@Marvinthebored
Marvinthebored force-pushed the perf/ios-chat-swipe-scroll-state branch from cde4f19 to 5b531a0 Compare November 2, 2026 15:49
@Marvinthebored

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 2, 2026
@roboclaw-bot

Copy link
Copy Markdown
Collaborator

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants