Settle an unconfirmed note PATCH with its read-back

Closed
PA
10h ago
+127-16

Closes #23

update_note and write_note_body (used by patches and push) now pass the PATCH outcome to a new HackmdClient::confirm_sent_note_write:

  • PATCH succeeded → confirm_note_write, unchanged.
  • PATCH WriteUnconfirmed → the same poll_readback; a read showing the note as sent returns success, anything else returns the original WriteUnconfirmed.
  • Any other error → returned as before.

The PATCH is never resent. README and docs/tools.md describe the new behaviour.

Tests

  • a_failed_patch_the_read_back_shows_is_confirmed: 502 on PATCH, then a read showing the write → success, 2 requests. Fails without the change.
  • a_failed_patch_the_read_back_does_not_show_stays_unconfirmed: 502, then reads showing the old body → WriteUnconfirmed, one PATCH.
  • cargo test --all-features: 354 passed; cargo clippy --all-features --all-targets: clean.
  • Manual check against hackmd.io with a private throwaway note (create, content+title update with expected_hash, stale hash refused, delete). The 5xx path itself cannot be triggered live.

🤖 Generated with Claude Code


Summary by cubic

Note updates whose PATCH ends with an unknown outcome (5xx, timeout, dropped connection) now settle the write with the same read-back used for a successful PATCH, instead of reporting unconfirmed right away.

  • A read showing the note as sent makes the update succeed; a read that does not (or fails) keeps the original WriteUnconfirmed.
  • The PATCH is never sent a second time; README and docs/tools.md describe the new behavior.