Repository navigation
fix(imessage): plain-send fallback for threaded replies + db-scoped recovery cursor (#99638) - #100446
Conversation
|
Codex review: needs maintainer review before merge. Reviewed July 5, 2026, 4:42 PM ET / 20:42 UTC. Summary PR surface: Source +140, Tests +182. Total +322 across 6 files. Reproducibility: yes. source-reproducible: current main rethrows the upstream Review metrics: 1 noteworthy metric.
Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Maintainer decision needed
Security Review detailsBest possible solution: Land after a maintainer accepts the compatibility-sensitive fallback and cursor-upgrade behavior and exact-head checks remain green. Do we have a high-confidence way to reproduce the issue? Yes, source-reproducible: current main rethrows the upstream Is this the best way to solve the issue? Yes, this appears to be the best code shape: the fix stays inside the iMessage plugin boundary, covers text and media on the shared send path, and scopes cursor state to the watched database instead of adding config or a core shim. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 5e0504aa437e. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +140, Tests +182. Total +322 across 6 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
Review history (2 earlier review cycles)
|
f2fb769 to
3a233c8
Compare
|
Addressed the review (head
92 unit + integration tests green across the touched files, The two behaviors here are transport-error and persisted-cursor paths, proven deterministically by tests that drive the real @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
Live behavior proof (real deployment)Captured on a real two-Mac SSH deployment: the fixed gateway on one Mac driving 1. AppleScript-only threaded-reply fallback (
|
|
Live AppleScript-only fallback + dbPath-repoint proof added above, and PR body updated. @clawsweeper re-review |
…ecovery cursor (openclaw#99638) (openclaw#100446) * fix(imessage): retry unthreaded when a threaded reply is unsupported (openclaw#99638) * fix(imessage): scope downtime-recovery cursor to the watched database (openclaw#99638) --------- Co-authored-by: Omar Shahine <[email protected]>
Closes #99638
What Problem This Solves
Issue #99638 reported three failures on the dedicated bot-user / SSH-wrapped iMessage deployment. The primary one (every DM after the first failing with
reply session initialization conflicted) was already fixed by #98835. This PR fixes the two remaining reported failures:reply_tobut only AppleScript transport was available,imsghard-errored (reply_to requires bridge transport; ...) and OpenClaw rethrew, so the reply was lost — for both text and media replies.dbPathsilently stopped all inbound. The downtime-recovery cursor was keyed per account, not per database, and is monotonic. After pointingdbPathat a differentchat.dbwith lower rowids (e.g. a fresh bot-user DB, max rowid ~15), the stale high-water (~12396) was still sent assince_rowid, soimsgreplayed/emitted nothing and inbound was silently lost forever.Why This Change Was Made
Both fixes stay entirely within
extensions/imessage(no core or config-surface changes):send.ts): the sendcatchnow detects the specific "threaded reply unsupported" error and, when areply_towas set, retries the send once withreply_tostripped — delivering the message unthreaded instead of dropping it. This covers text and media replies alike (both carryreply_tothrough the same send path), keeps any attached file on the retry, and clears the reply id so the receipt reports the unthreaded send that was actually delivered. The match is a closed error class, so unrelated send failures still propagate.recovery-cursor.ts): the cursor is keyed per (account, database identity). The identity is derived fromremoteHost/dbPath/ customcliPath, with local paths canonicalized (leading~expanded, then resolved) so the implicit default and an explicit path to the samechat.dbmap to one identity. A cursor recorded against a different database no longer seedssince_rowid, advance is monotonic only within the same database, and a pre-scoping (account-only) cursor is adopted once for the active database on upgrade so downtime replay still works. This is cache-class state (rebuilds safely via GUID dedupe), so no migration is required.User Impact
dbPath(or moving to/from a remote host, or spelling the default path explicitly) no longer wedges inbound message delivery; recovery resumes from the correct database.Evidence
Unit + integration tests — all green (92 passed across the 3 touched files):
These exercise the exact runtime paths the fix changes:
send.test.ts: text and media replies that hit the upstreamreply_to-unsupported error retry once withreply_tostripped, deliver the message/media unthreaded, and report a non-threaded receipt.recovery-cursor.test.ts: cursor scoped per (account, database); ignores a cursor from a different database; re-scopes on advance without losing the other database's high-water; adopts a pre-scoping legacy cursor once for the active database; unifies the implicit default with explicit/~spellings of the samechat.db; keeps distinct DBs/wrappers/remotes separate.monitor.last-route.test.ts: existing downtime-recovery integration tests updated to the DB-scoped cursor (local + remote paths) and still passing.Typecheck:
pnpm tsgo:extensionsandpnpm tsgo:extensions:testboth clean.Codex review (
autoreview, gpt-5.5) run to clean over several rounds — it flagged and I fixed: legacy-cursor upgrade-drop, per-database cursor overwrite, custom-cliPathidentity aliasing, unthreaded-fallback receipt accuracy, media-reply fallback coverage, and default-vs-explicit-path identity normalization. Final pass reports no actionable findings.Live behavior proof (real two-Mac SSH deployment) — captured and posted in a PR comment:
sendRPC against the realimsgbinary,reply_to+ AppleScript transport returns the exactreply_to requires bridge transport; ...error, and the same send withreply_tostripped delivers (ok:true,transport:applescript). The PR performs that retry automatically.{"lastRowid":6597}was adopted and re-scoped by the fixed gateway into a db-scoped composite keydefault\x00remote:<host>:.../chat.db; the persisted key embeds the database identity, and a repoint left it untouched while the new database started fresh.Primary bug (#98835) also verified live for context: three sequential multi-turn DMs on the same SSH deployment all delivered replies with
outcome=completedand zeroreply session initialization conflicted.🤖 Generated with Claude Code