Skip to content

fix: preserve failed Apple chat messages across partial history pages - #205404

Merged
vincentkoc merged 1 commit into
mainfrom
fix/apple-paginated-history-outbox-restore-c34
Nov 27, 2026
Merged

vincentkoc merged 1 commit into
mainfrom
fix/apple-paginated-history-outbox-restore-c34

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

When an Apple chat reopened or refreshed, a nonempty newest history page could move a failed message from the outbox into the composer. The matching user message could still be on an older page. Scrolling back then showed the delivered message, and reopening the chat also showed it as a saved draft.

User Impact

A paginated history response leaves the failed message available for manual editing. When a complete history read establishes that the message is absent, automatic restore puts it back in the composer once. A canonical match confirms delivery.

Why This Change Was Made

The history reconciler now tracks whether the live snapshot covered the start of the session before using a tail delta as evidence of absence. An empty unanchored refresh preserves valid evidence from a previous complete read.

Evidence

Both frozen Swift/SQLite replays reproduced the premature restore. Both passed with this change. Thirteen focused controls covered one-row and 200-row pages, the older canonical echo, presentation changes, tail deltas, exhausted history, and the draft after reopening the database. All 168 existing controls passed.

The new SwiftPM regression drives the view model through a newest-page refresh, an older-page read, a tail delta, and a real SQLite close and reopen. Both changed Swift files passed compiler parsing. On macOS, the new regression passed in 0.079 seconds. The OpenClawKit package passed all 2,706 tests across 246 suites. Hosted SwiftPM job.

@vincentkoc vincentkoc self-assigned this Nov 25, 2026
@clawsweeper

clawsweeper Bot commented Nov 25, 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. impact:message-loss Channel message delivery can be lost, duplicated, or misrouted. impact:session-state Session, memory, transcript, context, or agent state can drift or corrupt. 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: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. 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 25, 2026
@clawsweeper

clawsweeper Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: passed.

What this changes

This PR prevents partial Apple chat history and its subsequent deltas from automatically restoring potentially delivered messages into the composer.

Example: The failed outbox message “already delivered” has key landed:user, but its canonical echo is on an older history page.

  • Before: Refreshing the newest page can move the message into a saved draft before the older echo is loaded.
  • After: The partial page leaves the message available for manual editing without creating a duplicate draft.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The focused implementation appears correct, but runtime confidence is limited by pending native validation and absent shipped-app proof; no persisted schema or serialization format changes require migration.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A message already delivered can reappear as a saved draft because its canonical echo is outside the newest history page.
Reason: Preventing duplicate drafts restores the existing proof-of-absence contract, and the maintainer-authored PR already supplies direction approval.

Merge readiness

✅ Ready for maintainer review

Keep this maintainer-authored draft open: it addresses a source-confirmed restoration bug still present on main, and inspection found no definite introduced defect.

Reviewed head: cf66323ed0471802788a21ebc719ced79977745e

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: Supply a redacted Apple-app run showing partial-page refresh, older-echo loading, tail refresh, and relaunch without a duplicate draft, plus complete-history absence still restoring once and existing outbox data surviving an upgrade from v2026.11.10; the committed regression’s base-fail/head-pass execution is also not yet shown.
Agent review details

How this fits together

The shared Apple chat view model consumes Gateway history snapshots and deltas, reconciles visible messages, and supplies evidence used by the existing SQLite outbox-to-draft operation.

flowchart TD
A[Gateway history] --> B[Shared Apple history reconciler]
B --> C[Visible transcript]
B --> D[Restore evidence]
D --> E[Outbox restore owner]
E --> F[SQLite outbox and composer draft]
Loading

Technical review

Best possible solution:

Keep absence decisions in the existing reconciler, invalidate evidence for partial snapshots, and let deltas inherit their snapshot’s coverage.

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

Source establishes the trigger: a nonempty newest page with older history advances restore evidence, allowing an eligible failed row whose echo remains unread to enter the draft; no target code was executed during this read-only review.

Is this the best way to solve the issue?

The patch is a small repair at the existing decision owner, reuses its evidence state, preserves manual Edit and canonical confirmation, and adds a distinct persistence regression without parallel machinery.

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: none.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit bf754b8 adds apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatViewModel+HistoryReconciliation.swift:784 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: bf754b8a344a; files: apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatViewModel+HistoryReconciliation.swift)

PR surface

Source +7, Tests +52. Total +59 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 8 1 +7
Tests 1 52 0 +52
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 60 1 +59

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:

  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

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 25, 2026, 10:26 AM ET / 15:26 UTC.

@vincentkoc
vincentkoc marked this pull request as ready for review November 25, 2026 16:01
@vincentkoc
vincentkoc merged commit bd459c6 into main Nov 27, 2026
207 of 208 checks passed
@vincentkoc
vincentkoc deleted the fix/apple-paginated-history-outbox-restore-c34 branch November 27, 2026 08:06
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Nov 27, 2026
* commit 'fd681ab8786e062045fa5ec6261b1b06f60832eb': (2115 commits)
  fix: keep doctor --fix pending checks from creating SQLite sidecars (#206485)
  fix(ci): update iOS screenshot reducer gate (#206497)
  fix: keep chat photo previews sharp within their byte limits (#206461)
  fix: let agents use short Workboard card IDs
  fix(tui): run provider sign-in in the local TUI (#200605)
  improve(config): reduce repeated directory checks for larger agent rosters (#206494)
  perf(test): reuse the Periphery producer workflow snapshot (#189681)
  fix(ci): keep locale assets within the installed package budget (#206492)
  fix: preserve failed Apple chat messages across partial history pages (#205404)
  improve: avoid merging unrelated settings for agent directory lookups (#206489)
  fix: show typing while a queued follow-up turn runs (#201920)
  fix: stop 2026-11-17 main Git checkouts from half-switching on a schema update (#206341)
  refactor(codex): centralize native completion delivery (#206447)
  fix(subagents): finish claimed stops after session rotation (#206405)
  fix: let owners fork a chat with exec after a subagent or exec completion (#206483)
  test(cli): gate agent --local cold-start processes and workers (#206466)
  perf(ci): skip baseline inventory when line-cap debt is empty (#189909)
  refactor(test): share core process-result fixtures (#174149)
  refactor(ci): reuse canonical budget flag parsing (#189480)
  fix: recover Codex chats after oversized requests (#206475)
  ...
vincentkoc added a commit that referenced this pull request Nov 27, 2026
* commit 'fd681ab8786e062045fa5ec6261b1b06f60832eb': (923 commits)
  fix: keep doctor --fix pending checks from creating SQLite sidecars (#206485)
  fix(ci): update iOS screenshot reducer gate (#206497)
  fix: keep chat photo previews sharp within their byte limits (#206461)
  fix: let agents use short Workboard card IDs
  fix(tui): run provider sign-in in the local TUI (#200605)
  improve(config): reduce repeated directory checks for larger agent rosters (#206494)
  perf(test): reuse the Periphery producer workflow snapshot (#189681)
  fix(ci): keep locale assets within the installed package budget (#206492)
  fix: preserve failed Apple chat messages across partial history pages (#205404)
  improve: avoid merging unrelated settings for agent directory lookups (#206489)
  fix: show typing while a queued follow-up turn runs (#201920)
  fix: stop 2026-11-17 main Git checkouts from half-switching on a schema update (#206341)
  refactor(codex): centralize native completion delivery (#206447)
  fix(subagents): finish claimed stops after session rotation (#206405)
  fix: let owners fork a chat with exec after a subagent or exec completion (#206483)
  test(cli): gate agent --local cold-start processes and workers (#206466)
  perf(ci): skip baseline inventory when line-cap debt is empty (#189909)
  refactor(test): share core process-result fixtures (#174149)
  refactor(ci): reuse canonical budget flag parsing (#189480)
  fix: recover Codex chats after oversized requests (#206475)
  ...
tideclaw-bot pushed a commit that referenced this pull request Nov 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

impact:message-loss Channel message delivery can be lost, duplicated, or misrouted. impact:session-state Session, memory, transcript, context, or agent state can drift or corrupt. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S 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.

1 participant