Skip to content

improve(ios): avoid reformatting unchanged parts of streaming replies - #198122

Closed
roboclaw-bot wants to merge 19 commits into
mainfrom
openclaw/ios-streaming-preparation-work
Closed

roboclaw-bot wants to merge 19 commits into
mainfrom
openclaw/ios-streaming-preparation-work

Conversation

@roboclaw-bot

@roboclaw-bot roboclaw-bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

What problem this solves

While a native iOS reply streams, unchanged Markdown sections are repeatedly prepared for display. A long answer with 32 stable sections and a growing final paragraph performed 66 block preparations per processed update.

What changed

Keep preparation in the mounted streaming view and reuse prepared blocks only when their semantic input, completion state, reveal role, and localized disclosure summary still match. Changed segments still use the complete Markdown parser, so later references and structural changes remain parser-owned.

The current-main integration narrows this PR to two renderer files, their focused preparation tests, and one generated translation-source entry for the existing “Details” key. The former parent, #192232, has landed. Its old reader, list, and fence changes are no longer part of this PR's delta; current main's scrolling and incomplete-fence behavior are preserved.

There is no global cache or new throttle. The retained data is the current streaming snapshot, not a history of updates. A single growing paragraph still requires its normal parsing and preparation.

Current verification

Candidate: a1606c583ec86db498114f565476cec3c4fd2a23, integrated with main 4cbd215af463775faa6807aea90621292b28af15. Its full tree matches the independently reviewed and tested four-file port.

Actual compiler-coverage counts, with separate cold and warm processes:

Workload Main This PR
32 sections: initial block preparations 66 66
32 sections: preparations over 128 subsequent updates 8,448 128
One growing paragraph: preparations over 128 updates 128 128
Full snapshot/parser initialization over 129 inputs 129 129

This proves less repeated preparation, not faster full parsing. No first-content latency, frame-rate, CPU, or memory improvement is claimed.

  • 129 permanent shared-package tests across five suites passed on macOS, plus the temporary measurement workload, which was removed afterward.
  • SwiftLint, SwiftFormat, generated translation inventory verification, and independent whole-change review passed.
  • Both normal iOS app builds passed. In Simulator, the same simulated loopback Gateway sent 32 sections with bold text/links and 128 tail updates. Sending, streaming reveal, scrolling, Jump, and final content were checked on both builds. Final text was identical.
  • After a manual scroll had settled, two pre-update readings and the readings after further deltas and finalization had the same Y coordinate on each build: 0-point movement in both.
  • The first fixture launch omitted a connection-state flag and produced no reply; it was excluded and corrected. An initial scroll capture included gesture deceleration; the settled controls above resolve that ambiguity.
  • The fixture is simulated, not a real model/provider or persistence qualification. Link destinations were not opened. GitHub CI remains separately visible on the published head.

Before/After

The images below show the same streaming checkpoint and completed tail. They are cropped native-app captures with synthetic content. The matching checkpoint images are byte-identical.

Videos show streaming and manual navigation. The baseline video joins its first eight and last ten seconds to remove an idle inspection interval; these clips are not a timing comparison.

Before: native iOS streaming checkpoint on main

After: same native iOS streaming checkpoint with block reuse

Before: completed response tail on main

After: identical completed response tail with block reuse

base-public.mp4
candidate-public.mp4

CI qualification

The iOS screenshot job built the app successfully and passed three of four screenshot cases. The static chat case failed at OpenClawSnapshotUITests.swift:269 because the “Mermaid diagram” button did not appear.

The renderer trace shows the WebKit document remained in its loading phase, with documentReady=false, until its watchdog expired after 27,048 ms. The HTML resource had been delivered, but the document never reported ready.

This screenshot uses completed fixture history, not a streaming reply. The new streaming preparation is not instantiated; the shared snapshot receives preparesReveal=false and no previous snapshot, so the new reuse branch does not execute. The screenshot, fixture, Mermaid loader/resources, and build inputs are byte-identical between the actual CI baseline f52f728d34158e66c0d11ce48cc7fb1c7a0cd6a7 and tested merge 6543bb204ee8d18a8093f3c032f20db408e1785b. That merge contains the exact published head and only this PR's four-file change relative to its baseline.

Independent source review agrees this failure is outside the optimization's changed behavior. The underlying WebKit loading cause has not been isolated, and no baseline rerun is claimed. This failure is retained explicitly for the native unrelated-CI qualification; it is not reported as a passing screenshot test.

Current landing hold: Android Play tests also ended cancelled, after GitHub's 20-minute job deadline. The step reached :app:testPlayDebugUnitTest; cancellation is not a passing test result. The complete apps/android tree is identical between the tested baseline and merge (5ef9c3f110fd6a64af44b50993323a5c8b0ad622). The Apple transport and Periphery workflows subsequently passed. The native landing verifier refused admission because this Android deadline cancellation is not covered by its supported cancellation-provenance cases. No merge was performed, and auto-merge was retired. The prepared head and evidence are retained; no timeout or CI limit was changed.

Work sessions

Linked for team reference; these sessions are not public.

Worked on by

phone-build and others added 16 commits November 7, 2026 10:29
Worked on by:
- @mikengyn
- @vyctorbrzezowski

Co-authored-by: mikengyn <[email protected]>
Co-authored-by: vyctorbrzezowski <[email protected]>
OpenClaw-Publication: eeb3fb41-afc6-4ff3-8230-37d6b03269a2
@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.

@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. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. 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-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 retains streaming Markdown preparation in the mounted view and reuses unchanged semantic blocks between updates.

Example: An iOS reply contains 32 stable sections followed by a paragraph receiving 128 updates.

  • Before: The supplied measurement records 8,448 block preparations across those updates.
  • After: The supplied measurement records 128 block preparations, with identical final text and unchanged full-parser initialization counts.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, useful optimization supported by native-entry-point verification and semantic invalidation tests, with no actionable finding.
Proof confidence 🐚 platinum hermit (4/6) ✨ media proof bonus Sufficient (screenshot): The body and maintainer comment identify the exact candidate, normal native app builds, a simulated loopback Gateway delivering 32 sections and 128 tail updates, matching final content, preserved settled reading position, and reduced preparation counts; inspected before/after screenshots support visual equivalence, while video inspection was unavailable because of reviewer infrastructure limits.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Performance · Worth it: Yes · Fix scope: Complete
User problem: Long streaming replies repeatedly prepare already-stable Markdown sections on the native UI path.
Reason: The maintainer-authored direction and subsequent maintainer verification support this bounded reduction in repeated work, without claiming unmeasured latency, CPU, or memory improvements.

Merge readiness

✅ Ready for maintainer review

Keep open: this is a useful, maintainer-directed optimization with no introduced correctness or security finding. The earlier fence-rendering blocker is resolved outside the current diff; exact-head CI remains in progress.

Priority: P2
Reviewed head: a1606c583ec86db498114f565476cec3c4fd2a23

Before merge

None.

Findings

None.

Agent review details

How this fits together

The shared Apple chat UI receives assistant text segments, parses Markdown, prepares display blocks and reveal metadata, and renders them through SwiftUI on iOS and macOS.

flowchart TD
  A[Assistant text updates] --> B[Assistant segment parser]
  B --> C[Mounted streaming preparation]
  C --> D[Full Markdown segmentation]
  D --> E[Semantic block reuse]
  E --> F[SwiftUI renderer and word reveal]
Loading

Technical review

Best possible solution:

Retain one preparation per mounted streaming view and reuse semantically unchanged blocks while preserving complete parsing and existing reveal behavior.

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

Current-main source reconstructs every rendered block for each changed streaming snapshot, and the supplied compiler-coverage measurements quantify that repeated work; this review ran no target code.

Is this the best way to solve the issue?

The change uses the existing mounted streaming owner, replaces eager initialization, retains only the current preparation, and preserves parser-owned structural changes; no unnecessary production layer was identified.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Mounted streaming snapshot and reveal lifecycle keeps the original intent (83f0527: Introduce word-paced reveal while keeping Markdown preparation outside per-frame opacity updates.)
  • Prepared-input reuse and assistant segmentation keeps the original intent (1fce045: Avoid duplicate preparation of one delta; subsequent segmentation work in 8681a84 shares canonical assistant segments.)
  • Reveal-role selection keeps the original intent (a410b4d: Prepare reveal metadata only for the last eligible streaming prose block.)
  • Whole-message preparation and localized disclosure summaries keeps the original intent (1240284: Retain prepared unchanged messages while rebuilding on source, completion, or localized default-summary changes.)
  • Generated native string inventory keeps the original intent (f02d16e: Record extraction sites independently to avoid unrelated native translation inventory conflicts.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 83f0527 adds apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatMessageViews.swift:880 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 83f052772429; files: apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatMessageViews.swift)
  • Vincent Koc: Raw commit a410b4d adds apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatMarkdownRenderer.swift:210 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: a410b4d0fb53; files: apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatMarkdownRenderer.swift)

PR surface

Source +67, Tests +158. Total +225 across 4 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 3 141 74 +67
Tests 1 158 0 +158
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 299 74 +225

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 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 🐚 platinum hermit and patch quality is 🐚 platinum hermit. Replaced prior rating: 🧂 unranked krab.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This reduces repeated native streaming preparation without establishing an urgent availability or rendering regression.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit. Replaced prior rating: 🧂 unranked krab.
  • 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-13T05:55:20.167Z sha ed9258e :: needs changes before merge. :: [P2] Preserve incomplete fences when extracting streamed list items

Reviewed November 16, 2026, 10:44 PM ET / November 17, 2026, 03:44 UTC (Revision 2).

Worked on by:
- @mikengyn
- @vyctorbrzezowski

Co-authored-by: mikengyn <[email protected]>
Co-authored-by: vyctorbrzezowski <[email protected]>
OpenClaw-Publication: 7ec31cd2-b5c4-43ce-8ed5-a3dab676e043
vyctorbrzezowski and others added 2 commits November 16, 2026 20:26
Stage the reviewed streaming preparation and current reader owners for native baseline integration. Qualification follows only after refreshing the remaining main context.
Baseline-Refresh: 95464db1329f38e111d8780cf3419c6d9678ad68
Co-authored-by: mikengyn <[email protected]>
Co-authored-by: Vyctor H. Brzezowski <[email protected]>
@vyctorbrzezowski
vyctorbrzezowski marked this pull request as ready for review November 17, 2026 03:40
@vyctorbrzezowski

Copy link
Copy Markdown
Member

Maintainer verification: rebased the preparation-only change onto current main and kept the already-landed reader/list/fence behavior. The final four-file tree passed 129 focused tests, independent review, actual preparation-count measurements, and a fresh native iOS visual pass. For the long reply, repeated block preparation falls from 66 to 1 per update; full parsing remains. Final content and settled reading position match the baseline. Before/after screenshots, videos, exact revisions, and simulated-Gateway limits are in the body.

The old review targeted the inherited list implementation, which is no longer in this diff. Current main owns incomplete-fence handling.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

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. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: M status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants