Skip to content

fix(ios): keep streaming replies in view and stop the jump when they finish - #198326

Merged
obviyus merged 2 commits into
mainfrom
ios-chat-stream-handoff
Nov 13, 2026
Merged

obviyus merged 2 commits into
mainfrom
ios-chat-stream-handoff

Conversation

@obviyus

@obviyus obviyus commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Fixes: with the keyboard up, a long reply streams below the composer and the reader never sees it; when it finishes, the view jumps to the end or, in about half the runs, stays blank above the "Done in" line until the user scrolls. With the keyboard hidden, every reply visibly jumps up 42 pt the moment it finishes.

User Impact

Replies stay in view while they stream with the keyboard up, and the finished reply no longer jumps. The "working" status line now sits below the streaming words (where the "Done in" recap appears) instead of above them.

Why This Change Was Made

  • Follow the reply (keyboard up). The transcript relied on defaultScrollAnchor(.bottom, for: .sizeChanges), which left the scroll offset at 0 while the reply grew thousands of points below the composer; streamed words change no timeline revision, so nothing re-scrolled. The follow modifier now also pins the bottom edge (ScrollPosition.scrollTo(edge:)) on every content-height change while following. Edge scrolling does not depend on estimated row heights, and it runs in the modifier, outside the transcript body.
  • One update for the swap. When the saved reply lands, two things used to happen in different layout passes: the bubble hid itself in its own observation scope, and the transcript added the row. Now the transcript decides whether the bubble shows (from the live-content shape it already reads), and replaceMessages shows any paced words still held back so the exact-match suppression sees the same text. Before, the saved row and the bubble were on screen together for a frame (11,600 pt of content), and the bottom anchor jumped into the doubled content, which is what left the transcript blank.
  • No 42 pt jump. The working indicator sat above the streaming words and vanished when the reply finished. It now sits below them, so the final row takes the bubble's exact position.
  • Behavior cases: stream-turn and stream-follow become guards. stream-follow gates on following the reply while it streams; when a row changes height, the grader now reads motion on an edge the reader can see, since a reply taller than the screen can change height above the fold without visible motion. A row that keeps its height still counts as a whole move, so a long reply spanning the screen is still measured (re-grading the last run: scrolled-up holds read 0 pt drift with a spanning row in every frame).

Known remaining glitch, reported by the harness rather than gated: in about one run in three, as the final row replaces the bubble, the transcript flashes to the top for one or two frames (LazyVStack measures the run group at ~0 for one layout pass, and the bottom anchor follows that). In about one run in three the view also ends scrolled away from the reply until the reader scrolls (main: about half). The harness reports both; tracing the finish swap is the follow-up.

UI change: cc @vyctorbrzezowski for the working-indicator position.

Evidence

Keyboard up, 6 s into a 12 s reply. Before: the view stays at the top while the reply grows out of sight. After: the newest words sit above the composer.

Before After
Before: keyboard up, reply streams out of view After: keyboard up, reply followed

Keyboard hidden. The working status now sits below the streaming words (it was above the first heading), so nothing shifts when the reply finishes.

Before After
Before: keyboard hidden, status above the reply After: keyboard hidden, status below the reply

pnpm ios:behavior, iPhone 17 simulator, 3 samples per case:

Case Kind Gates (3 samples)
stream-turn guard all 3/3
stream-follow guard all 3/3 (reply followed while streaming)
scrolled-up guard all 3/3
keyboard guard all 3/3
relaunch guard all 3/3

Exit 0 with this PR's grading. Reported, not gated: in 2 of 3 stream-follow samples the reply ended scrolled away from view after it finished (the known finish glitch below).

On main (with #198293) the same stream-follow follow gate fails in every sample (p95 ~5,600 pt hidden) and stream-turn drifts 42 pt in every sample.

  • New regression test a durable reply retires the live bubble while pacing holds its last words fails on the base and passes here; ChatStreamPresentationTests and ChatStreamReplayTests pass.
  • test/scripts/ios-behavior-grade.test.ts: 6 passed. tsgo, oxlint, SwiftFormat, SwiftLint, native i18n inventory: clean.

Merge danger: two-way door. Revert restores the previous scroll and indicator behavior; no state, config or protocol change. Blast radius: the shared chat transcript on iOS and macOS.

@clawsweeper

clawsweeper Bot commented Nov 13, 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.

@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts size: M labels Nov 13, 2026
@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. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed 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. labels Nov 13, 2026
@clawsweeper

clawsweeper Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR follows growing native chat replies, coordinates their replacement by saved messages, and moves the working indicator below streaming text.

Example: An iPhone user sends UXSTREAM chunks=300 interval=40 with the software keyboard open.

  • Before: The reply grows roughly 5,600 points below the composer without being followed.
  • After: The newest streaming words remain above the composer, although completion can still leave the reply out of view.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Strong native-app evidence supports a focused repair with the prior finding resolved; the disclosed partial outcome limits overall readiness.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (screenshot): Inspected before/after screenshots and supplied iPhone 17 simulator results exercise the shipped chat UI against an isolated Gateway with scripted streaming output, showing keyboard-up following and the indicator-layout change while explicitly exposing the remaining completion limitation.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Partial
User problem: Long replies stream below the keyboard-covered viewport, and removing the working indicator shifts the completed reply.
Reason: The maintainer-authored direction delivers visible improvements while explicitly deferring the remaining intermittent finish-time failure.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it provides a useful partial fix, resolves the previous grader finding, and introduces no confirmed blocking defect; intermittent finish-time blanking remains explicitly deferred.

Priority: P2
Reviewed head: fcfc35b530c6fb0faf8a77671d86a2ff81a4a86e

Before merge

None.

Findings

None.

Agent review details

How this fits together

The shared SwiftUI chat receives paced assistant text and canonical history from its view model, renders live and saved replies, and positions the transcript according to the reader's follow state.

flowchart TD
Gateway[Gateway events and history] --> Model[Chat view model]
Model --> Pacing[Stream display pacing]
Model --> Transcript[Canonical transcript]
Pacing --> View[Shared SwiftUI chat]
Transcript --> View
Reader[Reader follow state] --> Anchor[Scroll follow modifier]
View --> Anchor
Loading

Technical review

Best possible solution:

Retain this focused repair in the existing scrolling and presentation owners, with intermittent finish-time blanking tracked as separate remaining work.

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

The source explains the missing height-driven follow and split live-to-saved rendering updates, while supplied simulator A/B results demonstrate the failures; this read-only review ran no target code.

Is this the best way to solve the issue?

The patch uses the existing follow modifier, transcript visibility projection, and pacing owner without adding a competing renderer or policy owner, but deliberately leaves intermittent completion blanking unresolved.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 90c620b8e554.

Provenance checked

  • Display pacing and transcript observation keeps the original intent (dde2941: Reduce redundant transcript work by pacing displayed text and observing words inside the live bubble.)
  • Follow-state isolation keeps the original intent (f2c27f0: Keep swipe-driven follow-state changes outside transcript construction while preserving reader policy.)
  • Streaming duplicate suppression keeps the original intent (fa8fc42: Prefer an exactly matching saved or sealed assistant row over a duplicate live bubble.)
  • Simulator grading changes intended behavior with a stated reason (858b5b0: Measure scroll failures through the real simulator app; this PR explains narrowing the streaming guard while continuing to report known completion failures.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Marvinthebored: Raw commit f2c27f0 adds apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatScrollCommand.swift:26 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: f2c27f09ea53; files: apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatScrollCommand.swift)
  • Ayaan Zaidi: Raw commit 858b5b0 adds scripts/ios-behavior.mts:23 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 858b5b01338e; files: scripts/ios-behavior.mts)
  • christopheraaronhogg: Raw commit ab2761f adds apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatView.swift:617 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: ab2761f3a59a; files: apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatView.swift)

PR surface

Source +25, Tests +35, Docs +1, Other +36. Total +97 across 10 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 4 52 27 +25
Tests 3 44 9 +35
Docs 1 9 8 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 2 68 32 +36
Total 10 173 76 +97

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: The repair improves native chat reading and streaming visibility with a limited shared-chat blast radius.
  • merge-risk: 🚨 automation: The simulator command's pass criteria change: finish-time failures become reported metrics rather than gates, an explicitly disclosed choice in this maintainer-authored PR.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.

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 (1 earlier review cycle)
  • reviewed 2026-11-13T15:22:08.028Z sha accff63 :: needs changes before merge. :: [P2] Preserve translation detection for rows spanning the viewport

Reviewed November 13, 2026, 12:53 PM ET / 17:53 UTC (Revision 2).

@obviyus
obviyus force-pushed the ios-chat-stream-handoff branch from accff63 to 8a3aaaf Compare November 13, 2026 17:32
@obviyus
obviyus marked this pull request as ready for review November 13, 2026 17:43
@obviyus

obviyus commented Nov 13, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 13, 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. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. 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. labels Nov 13, 2026
@obviyus
obviyus merged commit 97611bd into main Nov 13, 2026
131 checks passed
@obviyus
obviyus deleted the ios-chat-stream-handoff branch November 13, 2026 18:18
@obviyus

obviyus commented Nov 13, 2026

Copy link
Copy Markdown
Collaborator Author

Landed as 97611bd. With the keyboard up, a streaming reply now stays in view, and the jump when a reply finishes (keyboard hidden) is gone. Proof: pnpm ios:behavior, 3 samples per case on the simulator: stream-turn 0 pt (main: 42 pt), stream-follow follow lag 0 (main: ~5,600 pt); every guard passes. The keyboard-up finish glitch (a 1–2 frame flash, or ending scrolled away) is reported, not gated, and stays open as follow-up work. CI fully green on the exact head; ClawSweeper ready.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 14, 2026
…finish (openclaw#198326)

## What Problem This Solves

Fixes: with the keyboard up, a long reply streams below the composer and the reader never sees it; when it finishes, the view jumps to the end or, in about half the runs, stays blank above the "Done in" line until the user scrolls. With the keyboard hidden, every reply visibly jumps up 42 pt the moment it finishes.

## User Impact

Replies stay in view while they stream with the keyboard up, and the finished reply no longer jumps. The "working" status line now sits below the streaming words (where the "Done in" recap appears) instead of above them.

## Why This Change Was Made

- **Follow the reply (keyboard up).** The transcript relied on `defaultScrollAnchor(.bottom, for: .sizeChanges)`, which left the scroll offset at 0 while the reply grew thousands of points below the composer; streamed words change no timeline revision, so nothing re-scrolled. The follow modifier now also pins the bottom edge (`ScrollPosition.scrollTo(edge:)`) on every content-height change while following. Edge scrolling does not depend on estimated row heights, and it runs in the modifier, outside the transcript body.
- **One update for the swap.** When the saved reply lands, two things used to happen in different layout passes: the bubble hid itself in its own observation scope, and the transcript added the row. Now the transcript decides whether the bubble shows (from the live-content shape it already reads), and `replaceMessages` shows any paced words still held back so the exact-match suppression sees the same text. Before, the saved row and the bubble were on screen together for a frame (11,600 pt of content), and the bottom anchor jumped into the doubled content, which is what left the transcript blank.
- **No 42 pt jump.** The working indicator sat above the streaming words and vanished when the reply finished. It now sits below them, so the final row takes the bubble's exact position.
- Behavior cases: `stream-turn` and `stream-follow` become guards. `stream-follow` gates on following the reply while it streams; when a row changes height, the grader now reads motion on an edge the reader can see, since a reply taller than the screen can change height above the fold without visible motion. A row that keeps its height still counts as a whole move, so a long reply spanning the screen is still measured (re-grading the last run: `scrolled-up` holds read 0 pt drift with a spanning row in every frame).

Known remaining glitch, reported by the harness rather than gated: in about one run in three, as the final row replaces the bubble, the transcript flashes to the top for one or two frames (`LazyVStack` measures the run group at ~0 for one layout pass, and the bottom anchor follows that). In about one run in three the view also ends scrolled away from the reply until the reader scrolls (main: about half). The harness reports both; tracing the finish swap is the follow-up.

UI change: cc @vyctorbrzezowski for the working-indicator position.

## Evidence

Keyboard up, 6 s into a 12 s reply. Before: the view stays at the top while the reply grows out of sight. After: the newest words sit above the composer.

| Before | After |
| --- | --- |
| ![Before: keyboard up, reply streams out of view](https://github.com/user-attachments/assets/f813c40b-f18c-4207-958a-6c9ac9c5e4ca) | ![After: keyboard up, reply followed](https://github.com/user-attachments/assets/d4df82b4-ae9c-4820-9107-a5f304f8ec37) |

Keyboard hidden. The working status now sits below the streaming words (it was above the first heading), so nothing shifts when the reply finishes.

| Before | After |
| --- | --- |
| ![Before: keyboard hidden, status above the reply](https://github.com/user-attachments/assets/22d22a60-3175-4767-9c43-e6a6eac42c38) | ![After: keyboard hidden, status below the reply](https://github.com/user-attachments/assets/c13ee33d-96ff-427f-a0cd-fbf6f0fba347) |

`pnpm ios:behavior`, iPhone 17 simulator, 3 samples per case:

| Case | Kind | Gates (3 samples) |
| --- | --- | --- |
| `stream-turn` | guard | all 3/3 |
| `stream-follow` | guard | all 3/3 (reply followed while streaming) |
| `scrolled-up` | guard | all 3/3 |
| `keyboard` | guard | all 3/3 |
| `relaunch` | guard | all 3/3 |

Exit 0 with this PR's grading. Reported, not gated: in 2 of 3 `stream-follow` samples the reply ended scrolled away from view after it finished (the known finish glitch below).

On `main` (with openclaw#198293) the same `stream-follow` follow gate fails in every sample (p95 ~5,600 pt hidden) and `stream-turn` drifts 42 pt in every sample.

- New regression test `a durable reply retires the live bubble while pacing holds its last words` fails on the base and passes here; `ChatStreamPresentationTests` and `ChatStreamReplayTests` pass.
- `test/scripts/ios-behavior-grade.test.ts`: 6 passed. tsgo, oxlint, SwiftFormat, SwiftLint, native i18n inventory: clean.

Merge danger: two-way door. Revert restores the previous scroll and indicator behavior; no state, config or protocol change. Blast radius: the shared chat transcript on iOS and macOS.

Co-authored-by: Ayaan Zaidi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. P2 Normal backlog priority with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: M 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.

1 participant