Skip to content

improve(ios): reduce repeated work while reading long chats - #198114

Closed
roboclaw-bot wants to merge 17 commits into
mainfrom
openclaw/ios-transcript-preparation-pr
Closed

roboclaw-bot wants to merge 17 commits into
mainfrom
openclaw/ios-transcript-preparation-pr

Conversation

@roboclaw-bot

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

Copy link
Copy Markdown
Collaborator

Related: #192232

What Problem This Solves

Reading long chats can repeatedly prepare the same transcript during unrelated view updates and scroll callbacks; an unfinished code fence inside a streamed list could also enable highlighting or Mermaid rendering before closure.

User Impact

Reduces redundant transcript preparation while preserving the current chat design, grouped replies, reader position, sidebar animation, and streaming word fade. Native build, device behavior, and measured performance are still pending; this is a draft for the Mac verification loop, not a ready-to-merge performance claim.

Stacked dependency: Vyctor accepted stacking this new PR on #192232 at 7618f4311be932aadf7a06d18e28fbfe806c407d. The inherited dependency changes shown against main are not this fix. The authored delta against that immutable head is seven files: the original five-file transcript preparation plus a two-file streamed-list fence repair requested during review. This PR does not modify #192232, does not duplicate #194235 composer isolation, and requests no merge.

Why This Change Was Made

One mounted chat now retains one immutable prepared transcript for its actual message, narration, reader-history, display-policy, session/model, run, and tool inputs. Rendering and scroll callbacks share its rows, footer metadata, groups, iOS cells, and turn anchors; split-row actions reuse the already-projected full current message instead of projecting history again per part.

The existing rendering, grouping, visibility, and scroll policies remain the owners of behavior. The cache is bounded to one preparation per view, reads observed dependencies even on hits, and does not rely on timeline notifications alone. This does not implement changed-delta incremental Markdown or remove the existing live-text reconciliation work. Input comparison and retained preparation have a CPU/memory cost that still needs device measurement.

The review repair propagates message completion through every recursive list level and accepts fence closure only when the parser consumed a matching closer inside the list item. Shorter, mismatched, trailing-content, over-indented, and outside-list fence-looking lines remain incomplete. It is equivalent to the minimal fix in #198122 at 57ba92122c12c94f95504d51c4d9462ff66c7343, without importing that PR’s other changes.

Simplification removed duplicate callback preparation and the forwarding grouping wrapper. Against the dependency head: production +236/-133 lines (net +103); tests +307 lines. The fence repair itself is +28/-1 production lines and +66 test lines. The retained growth supplies the one-entry owner and its invalidation/reuse proof; no durable state, schema, setting, or dependency change is authored here.

Evidence

  • Published head: 833e8853e47b872c25376df602cc4631ebb5abeb. Remote GitHub commit/compare reads verify its sole parent is the original published head da48e3f1521eb2ddab73783fc529771c79b0c794. It is two commits ahead of 7618f4311be932aadf7a06d18e28fbfe806c407d; all seven changed remote blobs match the inspected local files. The new commit changes only ChatMarkdownBlockSegmenter.swift and apps/ios/Tests/ChatStreamingCodeFenceTests.swift (+94/-1). Both required human coauthor trailers are present. GitHub currently reports conflicts against main (mergeState: dirty); the accepted dependency base is intentionally preserved for this draft build loop, not rebased.
  • Integration base: 7618f4311be932aadf7a06d18e28fbfe806c407d; independent managed worktree was clean before applying the reviewed patch.
  • Original transcript preparation (unchanged by the fence repair): exact v2 patch: 38,070 UTF-8 bytes, SHA-256 e9f9836e42f54bc12f07b3018c3f4150e83a38788ac85fdd5bc331e8e40e8bb7. Verified checksum, five-file allowlist, clean exact base, forward apply check, reverse apply check, and git diff --check. Inspected the complete patch, original ChatView, and grouping/footer/history owners. No overlay, docs, skills, or source-transition changes are included in the authored delta.
  • Fresh local Auto Review of the complete seven-file candidate against 7618f4311be932aadf7a06d18e28fbfe806c407d, OpenClaw engine / openai/gpt-6.1-sol, P0–P2: scoped-clean, no findings. Static review only; native Apple builds/tests were not run and unavailable unchanged context was not independently verified. The original five-file implementation also retains its earlier parent-reported review evidence.
  • Sibling sweep: rendering, initial-position restoration, timeline callbacks, iOS cell flattening, macOS grouping/search, completed-work rows, and full-message actions now share preparation. Reader snapshot capture and live-text reconciliation still need their own current-state projection; they were inspected and left unchanged. Composer, sidebar, and word-fade implementations are unchanged. The fence-repair sibling sweep covered top-level fences, recursive ordered/unordered lists, tab indentation, disclosure recursion, and both highlight/Mermaid consumers. Top-level completion and disclosure propagation were already present; the missing propagation was in list preparation.
  • Added ChatTranscriptPresentationTests cover interleaved independent readers and unrelated updates, policy/run/tool changes without timeline notifications, narration/history deletion/outbox/content changes, and full-message actions from split parts. These tests have not run here. Baseline red/green, test wall time, and CI seconds remain unmeasured.
  • Addressed the streamed-list completion finding. Added two parameterized ChatStreamingCodeFenceTests at the real segmenter boundary for ordered/unordered/nested/tab/same-line list fences, valid closure or final-message completion, and invalid/outside closers. Current pre-repair source hardcodes these blocks complete; the new !isComplete assertions target that defect directly. Executed native red/green proof and timing remain pending, not claimed. git diff --check and final seven-file allowlist/original-five-blob preservation checks passed.
  • Linux environment: Swift, Xcode, and SwiftLint are unavailable. Native compile, focused Swift tests, simulator/iOS-specific cells, macOS shared-consumer checks, device work counts, and before/after video are pending at the published head. No timing or UI-success result is claimed. The user's Mac agent owns that build/proof loop; leave this draft until those results exist.

Pending Mac verification

At 833e8853e47b872c25376df602cc4631ebb5abeb, with Xcode 27.1+ / Swift 6.3 and a task-owned simulator:

test "$(git rev-parse HEAD)" = 833e8853e47b872c25376df602cc4631ebb5abeb
swift --version
xcodebuild -version
swift test --package-path apps/shared/OpenClawKit --filter 'ChatTranscriptPresentationTests|ChatTranscriptRowTests|ChatAssistantRunGroupTests|ChatReaderScrollStateTests|ChatInlineNarrationRegressionTests|ChatTranscriptSearchTests|ChatMarkdownBlockSegmenterTests' --no-parallel
pnpm ios:build
IOS_SIM="<task-owned simulator UDID>" pnpm ios:test ChatStreamingCodeFenceTests SwiftUIRenderSmokeTests ChatTypingFocusTests ChatSendHydrationTests

For the red control, use a separate task-owned checkout at da48e3f1521eb2ddab73783fc529771c79b0c794 with only the new ChatStreamingCodeFenceTests.swift copied from the candidate. Run pnpm ios:build, then IOS_SIM="<task-owned simulator UDID>" pnpm ios:test ChatStreamingCodeFenceTests; the incomplete-fence assertions should fail there and pass on the candidate. A setup/build failure is not the red control. Also exercise an unfinished Mermaid and Swift fence inside a nested streamed list through the actual app, then close the fence and finish the message; attach sanitized before/after screenshots and video before marking ready.

Also run the new package tests on an iOS simulator so the conditional List-cell assertions execute (a host-only SwiftPM run cannot cover them). Confirm the selected destination/scheme supports that package test target before claiming iOS test coverage.

Before timing, compare dependency base versus candidate on the same synthetic long chat and device: settled history, streaming while reading above the live edge, trace/search toggles, narration/tool handoff, outbox insertion/removal, history trimming/deletion, session replacement, and split-row copy/reply/select-text actions. Preserve grouped/disclosure identity, reader position, return-to-latest behavior, sidebar animation, and word fade. Capture before/after video with the exact head, device, OS, fixture, and build configuration recorded.

Acceptance rule: count actual preparation/group/cell builds first. After the initial preparation, unchanged relevant inputs must cause zero additional full preparations; a relevant input change must produce fresh correct rows. Compare baseline/candidate serially in ABAB order with at least five samples each, separating cold and warm results. Record main-thread/total CPU, frame latency/hitches, cold-open latency, and peak memory with median, p95, and spread. Require a measured reduction in repeated preparation and no correctness/UI regression; a 20% regression in any user-facing metric is a stop, not a pass. The owner test's reuse counts are not a substitute for device performance or UI proof.

Contributor credit: Vyctor Brzezowski and Mike Nguyen.

Work sessions

Linked for team reference; these sessions aren’t 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: dc82630d-7e7f-438e-9099-0e75dafd6661
@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: stale review; fresh review needed.

Summary
The latest durable ClawSweeper review was for head da48e3f1521eb2ddab73783fc529771c79b0c794, but the PR head is now 833e8853e47b872c25376df602cc4631ebb5abeb. Its old verdict and PR readiness labels are no longer current.

Next step
Comment @clawsweeper re-review when the current head is ready; pushes after the first review are not reviewed automatically.

Review history (1 earlier review cycle)
  • reviewed 2026-11-13T05:38:22.009Z sha da48e3f :: needs changes before merge. :: [P2] Preserve incomplete fences when extracting streamed list items

Worked on by:
- @mikengyn
- @vyctorbrzezowski

Co-authored-by: mikengyn <[email protected]>
Co-authored-by: vyctorbrzezowski <[email protected]>
OpenClaw-Publication: 41e88100-3e68-4533-a831-9105ead7b210
@clawsweeper clawsweeper Bot removed the rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. label Nov 19, 2026
@clawsweeper clawsweeper Bot removed the status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. label Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: ios App: ios P2 Normal backlog priority with limited blast radius. size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants