Skip to content

Clear draft recovery once every recovered message was sent - #319

Merged
huacnlee merged 1 commit into
mainfrom
fix/recovery-empty-record-version
Oct 1, 2026
Merged

huacnlee merged 1 commit into
mainfrom
fix/recovery-empty-record-version

Conversation

@huacnlee

@huacnlee huacnlee commented Oct 1, 2026

Copy link
Copy Markdown
Owner

Problem

At startup, reconcileComposeReceipts() asks the outbox whether recovered drafts with a pendingSendId were delivered. When every one of them was sent, finish() wrote Recovery.empty() to compose.recoverySave. That object is presentation state and has no version. The backend (src/compose/mod.rs) refuses records without version: 1 with recovery_invalid.

Because -32000 is in unsentRefusals, the retry ladder resent the same payload six times (1, 2, 4, 8, 16, 32 s). The stale record never left disk, so the same failure and the "Draft recovery could not be saved" warning returned on every launch. Receipt acks, which wait for a durable save, were never released.

A local diagnostics report showed this as repeated compose.recoverySave → recovery_invalid bursts, spaced exactly by the retry ladder.

Fix

When nothing is left to restore, write {"version":1,"active":false}, the same record clearComposeRecovery() already writes. Recovery.empty() stays as UI state. The backend is unchanged: refusing unversioned records is correct.

Verification

  • Added version === 1 and active === false assertions to the existing test_sent_receipt_is_not_restored_and_is_acknowledged_only_after_durable_save. Before the fix it failed with Actual: undefined, Expected: 1. After the fix the file passes 99/99.
  • make test and make validate pass locally.

Release Notes

Draft recovery no longer keeps failing to save, or warns on every launch, after a recovered message turns out to have been sent already.

🤖 Generated with Claude Code

When startup reconciliation found that every recovered draft had already
been sent, the composer wrote Recovery.empty(), which has no version. The
backend refuses unversioned records with recovery_invalid, so the stale
record stayed on disk, the retry ladder ran six times, and the save
warning returned on every launch. Write the versioned inactive record
that clearComposeRecovery already uses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@huacnlee
huacnlee merged commit f32fb73 into main Oct 1, 2026
14 checks passed
@huacnlee
huacnlee deleted the fix/recovery-empty-record-version branch October 1, 2026 06:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant