Skip to content

fix(ios): finished replies stay in view instead of leaving the chat blank - #198994

Merged
obviyus merged 2 commits into
mainfrom
ios-finish-swap
Nov 14, 2026
Merged

obviyus merged 2 commits into
mainfrom
ios-finish-swap

Conversation

@obviyus

@obviyus obviyus commented Nov 14, 2026

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Fixes: with the keyboard up, when a long reply finishes the chat flashes to the top and, in about half the runs, ends blank above the composer until the user scrolls.

User Impact

User impact: a finished reply stays in view where it streamed. The transcript no longer flashes to the top or goes blank when the saved reply replaces the streaming one.

Why This Change Was Made

  • Latest turn laid out as one piece. LazyVStack estimates the heights of rows it has not measured. When the saved reply replaced the streaming bubble, the stack measured the turn near zero for one layout pass (the scroll offset clamped to the top), then overshot its estimate by ~1,450 pt; the follow-the-end pin landed past every row, the rows unmounted, and nothing on screen corrected the estimate. The latest turn (from the user's message to the end) is now a single lazy child holding a plain VStack, so the part the reader follows always has measured heights. A run's rows were already laid out together inside one lazy item, so this adds only the user message and trailing rows to that item; a latest turn without run metadata is now laid out together too. Keeping the lazy stack as the scroll view's direct child matters: a VStack wrapping it made the history stack rebuild off-screen rows during sizing passes.
  • Run end keeps the words until the reply exists. The agent lifecycle end, and a chat final without a message, cleared the streaming words before the saved reply was in the transcript, so the turn showed neither for a history round trip. Recorded words still clear at once; unrecorded ones clear after the history read that brings the reply.
  • The streaming bubble never empties itself. A clear now hides the bubble through the transcript only; emptying the bubble in its own observation scope laid it out at zero a pass before the transcript changed.
  • The stream-follow behavior case gates on the end staying in view and no remounts again; teleports stay reported, not gated, because about one run in ten still flashes to the top for ~80 ms as the final row replaces the bubble. The grader ignores rows that stay off screen in both frames: rows of the eager tail stay mounted above the fold and shift when a height below them changes.
  • The reader scroll-policy helpers moved from ChatView.swift to ChatScrollCommand.swift unchanged, to keep ChatView.swift under the SwiftLint file length.

Accepted edge: a sessions.changed end for the selected run still clears unrecorded words; it was not seen ahead of the chat final on a real Gateway.

Evidence

  • iOS simulator, pnpm ios:behavior stream-follow (300-delta reply, keyboard up), end of reply, main → this PR:

    Before: transcript blank above Done in 12 seconds
    After: reply end in view above Done in 12 seconds

  • stream-follow on main: the reply ended out of view in about half the samples (2/4 in the run above; 8/17 earlier). With this PR: end in view and 0 remounts in 13/13 samples; a ~80 ms flash to top in 1/13.

  • Full pnpm ios:behavior suite on this head (all five cases, 3 samples each): every gate passes; also 5/5 on an earlier run of the same layout.

  • New tests red on main, green here: a run end without its reply keeps the live words until history brings it (lifecycle end and message-less final); a clear never empties the streaming bubble; the grader ignores rows off screen in both frames. OpenClawKit package tests: 2,630/2,632 pass; the two ChatMediaVideoPlayerTests audio-load tests fail only under full-suite load and pass alone.

No overlap with Pash/Sarah changes.

Merge danger: two-way door; a revert restores the previous layout and clear timing. No state, config or protocol change. Blast radius: the shared chat view on iOS and macOS (transcript layout and run-end clearing).

…lank

With the keyboard up, the lazy transcript measured the finished turn near zero for one layout pass, then overshot its estimate; the follow pin landed past every row and the chat stayed blank until the reader scrolled. The latest turn is now laid out eagerly as one lazy child, run ends keep the live words until the reply arrives, and a clear no longer empties the streaming bubble in its own scope.
@clawsweeper

clawsweeper Bot commented Nov 14, 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 14, 2026
@obviyus
obviyus marked this pull request as ready for review November 14, 2026 16:02
@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. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. 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 clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 14, 2026
@clawsweeper

clawsweeper Bot commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR measures the latest chat turn together and retains streaming words through the transition to the saved reply.

Example: A 300-delta reply finishes in the iPhone simulator with the keyboard open.

  • Before: The transcript can remain blank above “Done in 12 seconds” until the reader scrolls.
  • After: The finished reply’s UX-STREAM-END marker remains visible above the composer.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A useful, focused repair with directly inspected visual proof and meaningful regression coverage; broad native validation is still pending.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (screenshot): Inspected before/after iPhone simulator screenshots exercise the shared transcript through the real app against an isolated Gateway and scripted model, showing the finished reply visible after the fix; the body reports repeated finish samples and all five behavior cases passing.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A completed reply can disappear from the viewport until the reader scrolls.
Reason: The maintainer-authored direction repairs a demonstrated visibility failure with a focused change; the disclosed brief flash and sessions.changed ordering edge remain accepted limitations.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR provides a focused repair for the blank finished-reply viewport. No actionable introduced defect was found; exact-head native CI remains pending.

Priority: P2
Reviewed head: 5e912fba60d948d51c9014c5443a0eddcf5310f3

Before merge

None.

Findings

None.

Agent review details

How this fits together

The shared Apple chat UI consumes Gateway stream events and canonical history, reconciles their presentation in the view model, and renders the transcript for iOS and native macOS chat.

flowchart TD
  A[Gateway stream events] --> C[Chat view model]
  B[Canonical history] --> C
  C --> D[Transcript and live text]
  D --> E[Run groups]
  E --> F[Lazy history and measured latest turn]
  F --> G[Apple chat viewport]
Loading

Technical review

Best possible solution:

Keep the latest turn measured within the existing transcript renderer and preserve live words until the history handoff completes.

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

The supplied simulator comparison reproduces the blank finished-reply viewport on main using a 300-delta reply with the keyboard open; this review inspected that evidence without running target code.

Is this the best way to solve the issue?

The patch addresses measured-height instability and premature stream clearing through existing owners, preserves reader policies, and strengthens finish-state checks without introducing another renderer or state store.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 1ac07b333581.

Provenance checked

  • Reader-managed scrolling and lazy transcript layout keeps the original intent (ab2761f: Reader-managed scrolling preserves reading position and explicit navigation; subsequent repairs added live-edge following and documented the unresolved finish glitch. The original LazyVStack introduction remains unknown because older blobs are unavailable.)
  • Paced stream display and transcript observation changes intended behavior with a stated reason (dde2941: Pacing and separate observation scopes reduce transcript work during streaming; retaining the outgoing bubble’s last text preserves that separation while avoiding a zero-height clear.)
  • Terminal-event stream clearing changes intended behavior with a stated reason (d4708dc: The shared Swift cleanup consolidated paired streaming resets; this PR explains why unrecorded words must survive the terminal event until the existing history refresh settles.)
  • Simulator motion grading keeps the original intent (97611bd: Motion grading measures visible movement while tall replies change height; excluding rows offscreen in both frames follows that contract, while new end-position and remount gates cover the repaired failure.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Ayaan Zaidi: Raw commit 97611bd adds apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatScrollCommand.swift:45 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 97611bd5fb39; files: apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatScrollCommand.swift)
  • Marvinthebored: Raw commit dde2941 adds apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatViewModel.swift:813 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: dde29415eb56; files: apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatViewModel.swift)
  • christopheraaronhogg: Raw commit ab2761f adds apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatViewModel.swift:357 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/ChatViewModel.swift)

PR surface

Source +48, Tests +51, Docs 0, Other +10. Total +109 across 11 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 5 123 75 +48
Tests 3 52 1 +51
Docs 1 8 8 0
Config 0 0 0 0
Generated 0 0 0 0
Other 2 19 9 +10
Total 11 202 93 +109

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 P2: The intermittent native chat blanking obscures completed replies but is recoverable by scrolling.
  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: The intermittent native chat blanking obscures completed replies but is recoverable by scrolling.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; 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.

Reviewed November 14, 2026, 11:28 AM ET / 16:28 UTC.

@obviyus

obviyus commented Nov 14, 2026

Copy link
Copy Markdown
Collaborator Author

Maintainer note: the one red job, Build iOS Periphery reports → "Intersect shared OpenClawKit dead code", flags struct OpenClawIDDiscoveryAccountError (added by #197630; this PR does not touch it). The same error fails unrelated PRs #198793 and #198945. The check is not required; all required checks are green and the review is ready on 5e912fb. Ayaan approved landing past it.

@obviyus
obviyus merged commit f091e80 into main Nov 14, 2026
123 of 124 checks passed
@obviyus
obviyus deleted the ios-finish-swap branch November 14, 2026 17:24
@obviyus

obviyus commented Nov 14, 2026

Copy link
Copy Markdown
Collaborator Author

Landed as f091e80. With the keyboard up, a finished reply now stays in view instead of leaving the chat blank above the recap: the latest turn is laid out as one eager piece, run ends keep the live words until the saved reply arrives, and a clear no longer empties the streaming bubble on its own. Proof: pnpm ios:behavior full suite green on the head, stream-follow end in view 13/13 (main: about half blank), before/after simulator screenshots above, and regression tests red on main.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 15, 2026
…lank (openclaw#198994)

## What Problem This Solves

Fixes: with the keyboard up, when a long reply finishes the chat flashes to the top and, in about half the runs, ends blank above the composer until the user scrolls.

## User Impact

User impact: a finished reply stays in view where it streamed. The transcript no longer flashes to the top or goes blank when the saved reply replaces the streaming one.

## Why This Change Was Made

- **Latest turn laid out as one piece.** `LazyVStack` estimates the heights of rows it has not measured. When the saved reply replaced the streaming bubble, the stack measured the turn near zero for one layout pass (the scroll offset clamped to the top), then overshot its estimate by ~1,450 pt; the follow-the-end pin landed past every row, the rows unmounted, and nothing on screen corrected the estimate. The latest turn (from the user's message to the end) is now a single lazy child holding a plain `VStack`, so the part the reader follows always has measured heights. A run's rows were already laid out together inside one lazy item, so this adds only the user message and trailing rows to that item; a latest turn without run metadata is now laid out together too. Keeping the lazy stack as the scroll view's direct child matters: a `VStack` wrapping it made the history stack rebuild off-screen rows during sizing passes.
- **Run end keeps the words until the reply exists.** The agent lifecycle end, and a chat `final` without a message, cleared the streaming words before the saved reply was in the transcript, so the turn showed neither for a history round trip. Recorded words still clear at once; unrecorded ones clear after the history read that brings the reply.
- **The streaming bubble never empties itself.** A clear now hides the bubble through the transcript only; emptying the bubble in its own observation scope laid it out at zero a pass before the transcript changed.
- The `stream-follow` behavior case gates on the end staying in view and no remounts again; teleports stay reported, not gated, because about one run in ten still flashes to the top for ~80 ms as the final row replaces the bubble. The grader ignores rows that stay off screen in both frames: rows of the eager tail stay mounted above the fold and shift when a height below them changes.
- The reader scroll-policy helpers moved from `ChatView.swift` to `ChatScrollCommand.swift` unchanged, to keep `ChatView.swift` under the SwiftLint file length.

Accepted edge: a `sessions.changed` end for the selected run still clears unrecorded words; it was not seen ahead of the chat `final` on a real Gateway.

## Evidence

- iOS simulator, `pnpm ios:behavior` `stream-follow` (300-delta reply, keyboard up), end of reply, `main` → this PR:

  ![Before: transcript blank above Done in 12 seconds](https://github.com/user-attachments/assets/1e3963de-9e3a-4adc-b7b7-be996890ae55)
  ![After: reply end in view above Done in 12 seconds](https://github.com/user-attachments/assets/91b64624-16e0-4e6a-936a-fab3af91b4a0)

- `stream-follow` on `main`: the reply ended out of view in about half the samples (2/4 in the run above; 8/17 earlier). With this PR: end in view and 0 remounts in 13/13 samples; a ~80 ms flash to top in 1/13.
- Full `pnpm ios:behavior` suite on this head (all five cases, 3 samples each): every gate passes; also 5/5 on an earlier run of the same layout.
- New tests red on `main`, green here: a run end without its reply keeps the live words until history brings it (lifecycle end and message-less `final`); a clear never empties the streaming bubble; the grader ignores rows off screen in both frames. OpenClawKit package tests: 2,630/2,632 pass; the two `ChatMediaVideoPlayerTests` audio-load tests fail only under full-suite load and pass alone.

No overlap with Pash/Sarah changes.

**Merge danger:** two-way door; a revert restores the previous layout and clear timing. No state, config or protocol change. Blast radius: the shared chat view on iOS and macOS (transcript layout and run-end clearing).

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

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: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. 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