Skip to content

fix(apple): cut full chat-history downloads from 13 to 1 across refreshes - #171950

Merged
roboclaw-bot merged 4 commits into
openclaw:mainfrom
Marvinthebored:fix/apple-chat-history-refetch
Oct 30, 2026
Merged

roboclaw-bot merged 4 commits into
openclaw:mainfrom
Marvinthebored:fix/apple-chat-history-refetch

Conversation

@Marvinthebored

@Marvinthebored Marvinthebored commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Related: #100197

What Problem This Solves

Fixes repeated full-history downloads when Apple chats refresh after small updates or check unchanged history.

User Impact

Users download new chat rows instead of repeatedly downloading messages already on screen.

Why This Change Was Made

Reuse accepted Gateway history cursors and share overlapping refreshes through one read-and-publication owner. Session, route, and transcript replacements invalidate the cursor and reload canonical history. Incremental rows are decoded once and reused when publishing the transcript. Deltas carrying anchored activity placement use the existing canonical reload so nested completions retain the same order as a full read. This narrow fallback avoids duplicating the Gateway display composer and leaves ordinary append-only and empty deltas on the fast path.

Evidence

The app-hosted Swift Testing case realGatewayHistory() passed against a live isolated Gateway using the production iOS adapter and shared chat view model. A transparent wire relay observed the successful app connection and actual delta RPCs.

chat.history measurement Cursorless Cursor refresh
Requests 13 13
Full-history responses 13 1
Delta responses 0 12
Response JSON frame bytes 633,120 131,529

Response bytes fell 79.23%; both runs retain all nineteen messages. The 31 captured exchanges also verify active-run recovery, an empty sequence-gap delta, final completion, and stale-cursor reset followed by canonical reload.

Native proof and iOS adapter suite: 35 tests in 2 suites passed. Focused shared-kit validation after the anchored-placement fix: 673 tests in 22 suites passed. Removing prepared-message reuse makes the identity regression fail; restoring it passes 1 test in 1 suite.

Native harness, redacted wire trace, source hashes, measurements, and terminal results.

The anchored-completion regression captures the cursor after exec, wait, then receives a later completion anchored after exec. It fails on the prior head and passes with canonical fallback, yielding exec, completion, wait; a subsequent empty delta preserves that order. The existing real-Gateway measurements above cover the unchanged ordinary-delta path.

anchored-order-red: exit 1 (expected); 1 test failed on the prior source
anchored-order-green: exit 0; 1 test in 1 suite passed
Test run with 673 tests in 22 suites passed after 10.022 seconds.

AI-assisted.

@clawsweeper

clawsweeper Bot commented Oct 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.

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 14, 2026
@clawsweeper

clawsweeper Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR reuses Gateway history cursors and shares overlapping Apple chat refreshes while preserving canonical transcript recovery.

Example: An iOS conversation receives eleven appended messages and then checks unchanged history.

  • Before: Thirteen refreshes download thirteen full responses totaling 633,120 response-frame bytes.
  • After: Thirteen refreshes download one full response and twelve deltas totaling 131,529 response-frame bytes, preserving all nineteen messages.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Useful, source-reviewed repair with production-adapter live wire evidence and resolved prior findings; proof is app-hosted rather than a normal user-driven app flow.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (logs): Inspected app-hosted simulator output and real Gateway wire traces exercise the production iOS adapter and shared view model for append, unchanged, active-run, gap, completion, and reset recovery at c752c09. The current head changes only anchored-placement fallback and its regression; the body supplies its intended red/green result, while ordinary-delta proof remains applicable.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Performance · Worth it: Yes · Fix scope: Complete
User problem: Apple chat repeatedly downloads messages already displayed when small updates or unchanged-history checks trigger refreshes.
Reason: The inspected wire comparison establishes substantial bandwidth savings using an existing protocol, with no new user setting or competing server contract.

Merge readiness

✅ Ready for maintainer review

Keep open: current main still downloads full Apple chat history on refresh, and this PR provides a useful cursor-based repair. The previous anchored-order finding is resolved; no actionable findings remain. Exact-head CI is pending.

Priority: P2
Reviewed head: 73d29e5b6d7a455b18f7c2899817ae5c48964174

Before merge

None.

Findings

None.

Agent review details

How this fits together

The shared Apple chat view model receives refresh and transport events, requests history through the iOS or macOS adapter, and publishes reconciled messages and canonical cache updates.

flowchart LR
  A[Refresh and transport events] --> B[Shared history refresh owner]
  B --> C[Apple transport adapter]
  C --> D[Gateway chat history]
  D --> E[Delta or canonical response]
  E --> F[Transcript reconciliation]
  F --> G[Visible chat and existing cache]
Loading

Technical review

Best possible solution:

Use the shared refresh owner and existing Gateway cursor contract, retaining canonical reloads for resets and unsupported anchored placement.

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

Current-main source confirms cursorless refreshes; the contributor's inspected native comparison demonstrates the resulting repeated full downloads without running target code during this review.

Is this the best way to solve the issue?

The patch uses the existing Gateway contract, carries decoded rows to publication, and consolidates refresh ownership; its additional lifecycle state protects demonstrated ordering, route replacement, and local-message retention cases.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Active-run recovery and stale-response ordering keeps the original intent (443c582: Restore authoritative active-run ownership after reconnect, foreground resume, gaps, and completion without replacing transcript recovery.)
  • Retained local-message placement keeps the original intent (85f4efc: Keep locally held answers and their questions anchored among surviving conversation rows.)
  • Retryable history invalidation keeps the original intent (9ce7d58: Recover persisted updates after history-worker refusal while preserving newer messages and retiring replaced owners.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 443c582 adds apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatViewModel+HistoryReconciliation.swift:146 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)
  • Marvinthebored: Raw commit 85f4efc adds apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatViewModel+HistoryReconciliation.swift:641 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 85f4efc70fd1; files: apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatViewModel+HistoryReconciliation.swift)
  • joshavant: Raw commit ea7e214 adds apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatViewModel.swift:43 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: ea7e214bd4ef; files: apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatViewModel.swift)

PR surface

Source +395, Tests +995. Total +1390 across 13 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 11 559 164 +395
Tests 2 1087 92 +995
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 13 1646 256 +1390

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Repeated Apple history downloads waste bandwidth and refresh work without establishing an urgent broken workflow.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit 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.

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 (3 earlier review cycles)
  • reviewed 2026-10-14T08:13:43.452Z sha 2de7c65472062deba6f4781836ffe8ac0a929738 :: needs real behavior proof before merge. :: [P2] Decode delta rows once and carry the decoded messages to publication
  • reviewed 2026-10-24T04:09:22.833Z sha c752c09 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-24T06:44:32.940Z sha c752c09 :: needs changes before merge. :: [P2] Preserve display placement across the accepted cursor

Reviewed October 24, 2026, 4:39 AM ET / 08:39 UTC (Revision 4).

@Marvinthebored
Marvinthebored force-pushed the fix/apple-chat-history-refetch branch from 2de7c65 to 8fb912c Compare October 21, 2026 01:44
@Marvinthebored
Marvinthebored force-pushed the fix/apple-chat-history-refetch branch from 8fb912c to c752c09 Compare October 24, 2026 04:00
@Marvinthebored

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@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. labels Oct 24, 2026
@Marvinthebored

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The completed review on the current head rates overall readiness, proof, and patch quality at platinum (4/6), with sufficient proof and no findings, but the PR still carries the older rating: 🧂 unranked krab and status: 📣 needs proof labels. Please reconcile the labels with the current review result so the maintainer queue reflects the actual verdict.

@clawsweeper

clawsweeper Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. 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 Oct 24, 2026
@Marvinthebored

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@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. 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 rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. 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 Oct 24, 2026
Refresh request ordering for a still-current caller before its wire read, even when the intervening refresh left visible rows unchanged. Preserve session, route, invalidation and publication guards.

Add the deterministic subscription-overlap regression. The unchanged probe fails on the original PR and passes on the control and repair; all 57 focused history and unread tests pass.
@roboclaw-bot
roboclaw-bot merged commit 2065cee into openclaw:main Oct 30, 2026
75 of 79 checks passed
@roboclaw-bot

Copy link
Copy Markdown
Collaborator

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 31, 2026
…shes (openclaw#171950)

Reuse the existing Gateway history cursor contract for Apple chat refreshes and share overlapping reads through one publication owner. Retain canonical reloads for reset and unsupported anchored activity placement, preserving nested completion order.

Re-admit still-current bootstrap requests at the shared history owner after a foreground refresh supersedes their captured request order, so successful activation completes unread acknowledgement and remaining setup.

Validation: inspected contributor production-adapter live Gateway evidence records 633,120 versus 131,529 response-frame bytes for the supplied append-only workload (79.23% less; not a universal tool-heavy or latency claim). The repair commit reports the unchanged bootstrap probe failing on the original PR and passing on the control and repair, with all 57 focused tests passing. Native Swift tests were not independently executed by the landing agent. Exact-head hosted checks passed, including the recovered Periphery pipeline.

Co-authored-by: Marvinthebored <[email protected]>
Co-authored-by: Solvely-Colin <[email protected]>
Co-authored-by: Marvinthebored <[email protected]>
Co-authored-by: Colin <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: ios App: ios app: macos App: macos P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL 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.

4 participants