Skip to content

fix(ios): allow reading chat history before startup finishes - #198244

Closed
roboclaw-bot wants to merge 16 commits into
mainfrom
openclaw/ios-chat-opening-readiness
Closed

roboclaw-bot wants to merge 16 commits into
mainfrom
openclaw/ios-chat-opening-readiness

Conversation

@roboclaw-bot

Copy link
Copy Markdown
Collaborator

Related: #192232

Depends on #192232 at 7618f4311be932aadf7a06d18e28fbfe806c407d. This is a separate follow-up on that pinned head.

What Problem This Solves

Fixes: opening a native chat keeps initial reader positioning and scroll-follow release tied to the rest of startup even after its cached or live history is available.

User Impact

Users can begin reading and navigating accepted history without waiting for session metadata and model-list startup to finish. Grouped replies, sidebar animation, word fade, and Send/Talk admission are unchanged. This draft still needs exact-head Mac/iOS build, scrolling, and before/after visual proof; no measured speedup is claimed.

Why This Change Was Made

The existing history owner already records accepted live history and cache pre-paint. The transcript now consumes that fact for its one-shot initial position, loading overlay, and jump-to-latest availability instead of using whole-bootstrap completion. Session/model replacement resets the one-shot anchor even when SwiftUI coalesces readiness updates. A separate completed-load fallback preserves reading of restored outbox rows when history fails; an already-settled replacement uses the existing bootstrap task to distinguish an attempted load from unstarted idle. The shared macOS reader no longer repeatedly restores the initial anchor while optional startup runs.

Bootstrap work is neither deleted nor reordered: branch reconciliation, outbox recovery, subscription, health, metadata, mark-read, model availability, and permission guards retain their owners. isLoading and the existing empty-state/error/intro loading gates remain unchanged. The blocking full-chrome spinner is limited to the period before readable history exists; accepted history remains readable during a refresh. No cache or parallel startup task is added.

Evidence

  • Source-confirmed on the pinned base: bootstrap applies history, then awaits branches, health, the 50-row session refresh, mark-read, and models before its defer clears isLoading. The reader previously used that same flag to establish its initial anchor and admit scroll-phase handling.
  • git diff --check: passed. Source inspection and simplify pass completed. Production delta: +40/-15 lines (net +25); regression delta: +363/-1 (net +362). Swift tests are outside the repository's JavaScript/TypeScript test-line ratchet.
  • Authored actual-load() gate regressions: delayed sessions/models, empty history, active-stream ownership/send blocking, stale bootstrap after session/alias-route change, detachment during history, and history error with actual SQLite-restored outbox rows. Existing cache-to-live regression now checks early reader readiness. An iOS-only hosted OpenClawChatView regression covers failed-load positioning/follow release and settled same-key failed model replacement, using rendered-state signals and scroll observation. No test-only production seam or real sleep was added.
  • Parent inspection found and corrected a prior-candidate regression: failed history plus restored outbox rows never initialized the reader. Fresh independent Auto Review then found a P2 variant involving an already-settled failed replacement model; that was repaired and added to the hosted regression. The final full-candidate P0–P2 review (openclaw, openai/gpt-6.1-sol) reported scoped-clean, zero remaining findings, with intact view/load/history/cache/outbox/web/scroll owners and relevant fixtures. This is static review, not a native test result.
  • Pending: Swift compilation, focused test execution and intended-failure baseline control, SwiftFormat/SwiftLint, real iOS scrolling/initial-anchor/no-resnap proof, macOS native-reader smoke, before/after screenshots and video, and performance samples. This Linux environment has no Swift, Xcode, SwiftFormat, or SwiftLint. Test wall time and CI seconds are not available. Source review and fixtures are not native UI/performance proof.

Acceptance rule for the Mac proof loop

Use the exact pinned base and exact candidate commit with the same synthetic history and device. Separate cold open, cached reopen, and active-stream open. In the deterministic gated owner tests, accepted history must be readable before the sessions/models gate opens while bootstrap and metadata/send guards remain in their original states. In the actual UI, initial positioning must settle before optional startup completes; scrolling away must release follow, and optional completion must not snap back. Session/route switches must show only their own content; retry after an error must anchor when history first succeeds.

Record at least five interleaved baseline/candidate samples per cold/warm scenario: time to first correct anchor and successful scroll-away, median/p95/spread, host load, RPC counts, main-thread work, total CPU, memory, and frame hitches. Expect unchanged RPC counts and no added work/caches; a slower optional RPC must no longer extend reader readiness. Do not claim a performance win or mark ready without the table and exact-head native proof. A 20% regression in a user-facing metric stops the change for investigation.

Contributor credit

Requested by Vyctor Brzezowski, with the requested co-author credit to vyctorbrzezowski and mikengyn.

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: cb9361af-698e-4708-9a35-38f4a88703a8
@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-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. 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-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 changes before merge.

What this changes

This PR layers early native-history reading onto a pinned iOS transcript and scrolling repair.

Example: Open session main containing “Saved question” while the model catalog request remains pending.

  • Before: Initial reader positioning and scroll-follow release wait for startup to finish.
  • After: Accepted history initializes the reader before the remaining startup requests finish.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) Useful direction, but the readiness behavior lacks native execution evidence and the full introduced diff retains a blocking parser 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) 1 actionable review finding remain.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Available chat history cannot finish initializing its reading behavior while unrelated startup requests remain pending.
Reason: The source establishes a useful native reading improvement, and maintainer authorship supplies direction approval.

Merge readiness

⛔ Needs changes before merge - 2 items remain

Keep open: this maintainer-authored PR addresses a current startup-reading problem, but its inherited streamed-list changes contain a concrete rendering regression.

Priority: P2
Reviewed head: 010fbcdeac01ff1e61b28b9391701aa1ab998d17

Before merge

  • Preserve incomplete fences when extracting streaming lists (P2) - Enabling this path on iOS sends unfinished list code blocks through list(), which still calls codeBlock(code, isComplete: true). For example, a streamed item containing an open mermaid fence ending at graph TD\nA[ is treated as a finished diagram. ChatCodeBlockView consequently invokes ChatMermaidBlockView, displaying rendering/syntax-failure state and restarting rendering as fragments arrive instead of retaining unfinished code. Carry stream completion through recursive list conversion and determine whether each fence has actually closed. This defect is inherited from the pinned parent rather than added by the final readiness commit.
  • Complete next step - The PR owner should resolve GitHub’s reported conflicts against main while preserving the separately owned parent repair.

Findings

  • [P2] Preserve incomplete fences when extracting streaming lists — apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatMarkdownBlockSegmenter.swift:275-277

Tests

  • Low-value test apps/shared/OpenClawKit/Tests/OpenClawKitTests/ChatStreamingListRenderingTests.swift: Remove or replace the “streaming completion state reaches nested list items” property-forwarding test: it supplies completed list data and checks view fields, so it passes despite the unfinished nested-fence regression.
  • Missing end-to-end proof: Provide redacted exact-head native proof of early anchoring and scroll-away before optional startup completes, no resnap afterward, and macOS reader behavior, alongside executed focused regressions with intended baseline failures; redact credentials and non-public endpoints.
Agent review details

How this fits together

The shared Apple chat model accepts cached or Gateway history, and the native chat view turns it into transcript rows, initial positioning, follow behavior, and navigation controls.

flowchart TD
  A[Gateway history] --> C[Chat view model]
  B[Offline transcript cache] --> C
  C --> D[Accepted history readiness]
  C --> E[Remaining startup requests]
  D --> F[Native transcript reader]
  F --> G[Positioning and scroll navigation]
Loading

Technical review

Best possible solution:

Keep the readiness change at the existing history/view owners, preserve nested fence completion during streaming, and land the dependent transcript repair separately.

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

Current-main source shows accepted history arriving before optional startup completes while reader admission remains tied to isLoading; no target code was executed during this read-only review.

Is this the best way to solve the issue?

Using accepted-history facts for reader readiness is a focused solution that preserves bootstrap and send ownership; the inherited list renderer must also preserve incomplete-code semantics.

Full review comments:

  • [P2] Preserve incomplete fences when extracting streaming lists — apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatMarkdownBlockSegmenter.swift:275-277
    Enabling this path on iOS sends unfinished list code blocks through list(), which still calls codeBlock(code, isComplete: true). For example, a streamed item containing an open mermaid fence ending at graph TD\nA[ is treated as a finished diagram. ChatCodeBlockView consequently invokes ChatMermaidBlockView, displaying rendering/syntax-failure state and restarting rendering as fragments arrive instead of retaining unfinished code. Carry stream completion through recursive list conversion and determine whether each fence has actually closed. This defect is inherited from the pinned parent rather than added by the final readiness commit.
    Confidence: 0.99
    Late finding: first raised on code an earlier review cycle already covered.

Overall correctness: patch is incorrect
Overall confidence: 0.94

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Early positioning while startup remains pending changes intended behavior with a stated reason (5be01fd: The earlier repair positioned switched chats immediately but accepted repeated restoration until startup settled; this PR explains replacing that compromise with one-shot accepted-history readiness.)
  • Reader-managed follow and navigation changes intended behavior with a stated reason (ab2761f: Protect manual reading from incoming transcript updates and expose explicit Jump navigation; the inherited repair documents synchronous following and retained reading positions.)
  • Streaming Markdown lists changes intended behavior with a stated reason (a53461b: Lists were extracted only after completion to preserve streaming reveal; the inherited change seeks stable live/final geometry but misses nested fence completion.)
  • Offline cache and active-run reconciliation keeps the original intent (5d8293c: Cached transcripts prepaint cold opens while live history remains authoritative; run recovery separately preserves active ownership, and these owners remain in place.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Marvinthebored: Raw commit dde2941 adds apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatViewModel+TranscriptCache.swift:27 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+TranscriptCache.swift)
  • Peter Steinberger: Raw commit 5d8293c adds apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatViewModel+TranscriptCache.swift:3 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 5d8293c1fe40; files: apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatViewModel+TranscriptCache.swift)
  • christopheraaronhogg: Raw commit ab2761f adds apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatView.swift:598 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 +1098, Tests +659. Total +1757 across 35 files. Added test files: 5.

View PR surface stats
Area Files Added Removed Net
Source 22 1441 343 +1098
Tests 13 690 31 +659
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 35 2131 374 +1757

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.

Review metrics

Metric Value Why it matters
Readiness follow-up production versus tests Production +40/-15; tests +363/-1 against the pinned parent. The focused production change reuses existing readiness facts; regression growth covers delayed startup, session replacement, cache readiness, and failed-history outbox rendering, but execution remains pending.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This improves native chat reading during slow startup and includes a limited streaming-rendering defect without evidence of a broader outage.
  • 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:05 AM ET / 12:05 UTC.

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. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: XL 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.

2 participants