Skip to content

fix(ios): avoid blocking chat while decoding history - #198247

Merged
vyctorbrzezowski merged 17 commits into
mainfrom
openclaw/native-history-message-decoding
Nov 14, 2026
Merged

vyctorbrzezowski merged 17 commits into
mainfrom
openclaw/native-history-message-decoding

Conversation

@roboclaw-bot

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

Copy link
Copy Markdown
Collaborator

What problem this solves

Native chat converted every raw history row to its typed representation on the main actor. Large history loads competed with interaction, and visible outbox confirmation decoded the same canonical page twice.

What changes

Move typed row conversion into the existing structured concurrent decoding phase. Keep reconciliation and ingestion on their existing actor, with the same post-await cancellation, route generation, request-order and cursor checks. Reuse the decoded canonical page during visible outbox confirmation. No cache, detached task, schema or layout change is added.

The branch originally included #192232. A linear corrective commit removes that unrelated rendering work from the final diff: only the three history/transport production files and their directly affected tests remain. Historical commits are retained, but the squash does not include the parent feature.

Validation

  • The isolated source passes 541 tests in 14 selected shared Swift suites on Xcode 27.2, including history deltas, coalescing, route changes, outbox confirmation, replay, malformed data, canonical identities and reactions. The temporary test-source selection excluded unrelated package tests; the manifest was restored. This is focused native package proof, not an unmodified full-package run.
  • Configured SwiftFormat, strict SwiftLint on the three production owners, and whitespace checks pass. Independent review of the complete isolated change found no P0-P2 findings.
  • A clean effective merge with main 5df28e77efea retains the landed question-expiry repair, Markdown cache and streaming-display clearing behavior. The resulting diff has 12 files.
  • Earlier native iOS before/after instrumentation used the declared parent base: an ordinary 24-row page remained 24 typed conversions, moving them from the main queue to the cooperative executor. Visible canonical outbox confirmation fell from 48 conversions to 24. Cross-session confirmation kept the other conversation isolated. These observations support the decoding change but were not remeasured as end-to-end performance on the newly isolated tree.
  • The existing foreground test spends about 64 seconds waiting for a periodic fourth RPC; direct instrumentation measured the foreground task itself completing in under 1 ms. The polling expectation was preserved, not removed to green the test.

No claim of improved global CPU, memory, frame rate or load-to-display latency is made. Ingestion and the separate Watch preview remain on their existing paths.

Contributor credit: @vyctorbrzezowski and @mikengyn.

Work sessions

Linked for team reference; these sessions aren’t public.

Worked on by

@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: blocked before merge.

What this changes

Moves native chat history decoding off the main actor on top of a stacked iOS transcript repair.

Example: Open a native conversation containing 1,000 history rows.

  • Before: Typed conversion of all 1,000 rows runs on the main actor.
  • After: Row conversion runs in an explicit concurrent phase before main-actor reconciliation; responsiveness gains remain unmeasured.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The focused decoding design is reasonable, but native validation is absent and the complete stacked patch retains a concrete streamed-fence defect.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🦪 silver shellfish (2/6) 2 actionable review findings remain.

Product

Kind: Performance · Worth it: Yes · Fix scope: Complete
User problem: Opening or refreshing a long native chat can compete with interaction while history rows are converted on the main actor.
Reason: The maintainer-authored direction targets necessary work at its existing owner without adding configuration or a competing subsystem.

Merge readiness

⛔ Blocked before merge - 2 items remain

Keep this maintainer-authored draft open: current main still performs history-row conversion on the main actor, and this PR explicitly depends on an unmerged transcript repair.

Priority: P2
Reviewed head: 050498721bed53fe774656782e779f800972a8ff

Before merge

  • [P2] Preserve incomplete fences inside streamed list items (P2) - The inherited transcript change enables list extraction on iOS while isComplete is false, but list() still calls codeBlock(code, isComplete: true) for every nested code block. For a streamed response beginning with "1. Diagram\n\n ```mermaid\n graph TD\n A -->", the unclosed fence is therefore sent to ChatMermaidBlockView as a completed diagram; ordinary code also enters highlighting on every partial update. Preserve the parent completion state and detect an actual closing fence recursively before marking nested code complete. This concern is already recorded in the discussion of fix(ios): stops chat from going blank after sending a message or a reply arrives #192232 and remains in this merge-base diff.
  • Resolve merge risk - The PR owner must resolve the reported merge conflicts and coordinate inclusion of the unmerged transcript dependency before this branch can land independently.

Findings

  • [P2] [P2] Preserve incomplete fences inside streamed list items — apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatMarkdownBlockSegmenter.swift:275-277
  • [P3] [P3] Inline the one-caller scroll modifier forwarding helper — apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatScrollCommand.swift:112-116

Tests

  • Low-value test apps/shared/OpenClawKit/Tests/OpenClawKitTests/ChatStreamingListRenderingTests.swift: Remove or replace the two tests that inspect isStreaming/typography propagation and constructor field copies; they do not exercise rendered reveal or incomplete code fences, while the distinct repeated-prefix anchor regression should remain.
  • Missing end-to-end proof: Supply exact-head native build and affected-suite results, base-red/head-green regression evidence, and a long-history app run with executor tracing and comparable before/after responsiveness measurements.
Agent review details

How this fits together

The shared Apple chat model receives Gateway history pages, converts and reconciles their messages, and publishes transcript state consumed by native chat views.

flowchart LR
Gateway[Gateway history page] --> Owner[History refresh owner]
Owner --> Decode[Concurrent row decoding]
Decode --> Prepare[Main actor preparation]
Prepare --> Merge[Cursor and transcript reconciliation]
Merge --> View[Native chat transcript]
Loading

Technical review

Best possible solution:

Land the transcript dependency with its remaining fence repair, then retain the focused concurrent decoder and prepared-row publication in the existing history owner.

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

Source confirms synchronous per-row JSON conversion on the MainActor-isolated current-main model; no runtime reproduction establishes the size or frequency of visible pauses.

Is this the best way to solve the issue?

The decoding-only commit follows the existing owner, avoids a detached task or new cache, and preserves synchronous publication after revalidation; its measured benefit remains to be established.

Full review comments:

  • [P2] [P2] Preserve incomplete fences inside streamed list items — apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatMarkdownBlockSegmenter.swift:275-277
    The inherited transcript change enables list extraction on iOS while isComplete is false, but list() still calls codeBlock(code, isComplete: true) for every nested code block. For a streamed response beginning with "1. Diagram\n\n ```mermaid\n graph TD\n A -->", the unclosed fence is therefore sent to ChatMermaidBlockView as a completed diagram; ordinary code also enters highlighting on every partial update. Preserve the parent completion state and detect an actual closing fence recursively before marking nested code complete. This concern is already recorded in the discussion of fix(ios): stops chat from going blank after sending a message or a reply arrives #192232 and remains in this merge-base diff.
    Confidence: 0.98
    Late finding: first raised on code an earlier review cycle already covered.
  • [P3] [P3] Inline the one-caller scroll modifier forwarding helper — apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatScrollCommand.swift:112-116
    The added proxyContent method contains the modifier's entire implementation and is called only by body(content:). It introduces no observation, lifecycle, or platform boundary; keep ScrollViewReader directly in body(content:) and remove the forwarding layer.
    Confidence: 0.95

Overall correctness: patch is incorrect
Overall confidence: 0.93

AGENTS.md: found and applied where relevant.

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

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Land the transcript dependency with its remaining fence repair, then retain the focused concurrent decoder and prepared-row publication in the existing history owner.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Provenance checked

Testing

Proof path: none.

Security

None.

Evidence

What I checked:

Likely related people:

  • Marvinthebored: Raw commit 2065cee adds apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatViewModel+HistoryReconciliation.swift:25 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 2065ceecbe46; files: apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatViewModel+HistoryReconciliation.swift)
  • Peter Steinberger: Raw commit 443c582 adds apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatViewModel+HistoryReconciliation.swift:14 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 443c582949e3; files: apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatViewModel+HistoryReconciliation.swift)
  • Ayaan Zaidi: Raw commit 5c906f9 adds apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatViewModel+HistoryReconciliation.swift:16 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 5c906f9d7329; files: apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatViewModel+HistoryReconciliation.swift)

PR surface

Source +1110, Tests +353. Total +1463 across 41 files. Added test files: 3.

View PR surface stats
Area Files Added Removed Net
Source 23 1479 369 +1110
Tests 18 465 112 +353
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 41 1944 481 +1463

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:

No label changes.

Label justifications:

  • P2: Reducing main-actor history work is a useful native-chat performance improvement, but no measured urgency or widespread outage is established.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

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 13, 2026, 7:08 AM ET / 12:08 UTC.

@openclaw-barnacle openclaw-barnacle Bot removed the app: ios App: ios label Nov 14, 2026
@vyctorbrzezowski
vyctorbrzezowski marked this pull request as ready for review November 14, 2026 18:25
@vyctorbrzezowski
vyctorbrzezowski merged commit 2176ca7 into main Nov 14, 2026
143 of 145 checks passed
@vyctorbrzezowski
vyctorbrzezowski deleted the openclaw/native-history-message-decoding branch November 14, 2026 18:54
@vyctorbrzezowski

Copy link
Copy Markdown
Member

Merged the narrowed history-decoding change after 541 targeted Swift tests and green current-head CI. The final merge contains only the 12 history source/test files; it does not include the separate transcript-reader changes. The scope and limits of the native performance evidence remain documented above.

Thanks @mikengyn for the contribution.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 15, 2026
Decode native history rows away from MainActor while preserving cursor admission, cancellation, reconciliation and outbox confirmation. Retain only this PR's history-decoding changes; no transcript-reader feature is included.

Co-authored-by: mikengyn <[email protected]>
Co-authored-by: vyctorbrzezowski <[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. 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