feat(tui): join outbox rows to chat rows by message id (drop the body match) #50
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/tui-msgid-join"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
The chat pane now joins each pending outbox row to its chat row by message
id.
store::Messagecarries themessages.idrow id it was read from, andchat_with_deliverylooks upOutboxEntry::message_id==Message::id. Thebody match and its newest-send-first fallback are deleted.
Why it mattered: with the body match, an outbound message that was still queued
showed a delivered
✓whenever a newer send of the same text had alreadycrossed the circuit — the pending row was attached to the newest occurrence of
that body, not to the row that owns it. Exactly the false-delivery claim the
marker exists to prevent.
Stacked base — read this
This branch is
ebd3a30(the head of PR #48) plus one commit, so the diffagainst
mainalso contains PR #48 and its open parent PR #45(
feat/local-outbox). Review thesrc/store.rs/src/tui.rs/tests/tui_spec.rs/docs/TUI.mdhunks; everything else disappears once #45and #48 land.
Merge order: #45, then #48, then this. Do not merge before both.
Change
src/store.rs:Messagegainspub id: i64(themessages.idthe row wasread from).
list_messages()keeps its exact signature and behaviour — thisis an additive field, so the SDK,
tests/store.rs,tests/outbox.rs,tests/wipe.rs,tests/two_node.rsandtests/rotate_hs.rsare untouchedand still compile against it.
src/tui.rs:chat_with_deliverybuilds amessage_id → OutboxEntrymap andattaches the tag in a single forward pass. No
by_body, no.rev(), nopop(). A hypothetical duplicate row for one message resolves to the newest,matching the store's own
outbox_status_of_message(ORDER BY id DESC LIMIT 1).tests/tui_spec.rs: the fixtures take an explicit id (out_msg(id, body),queued_row(message_id, …)), because ids are what the join uses now.docs/TUI.md: the "Correlation" paragraph no longer describes a body match —it states the id join.
How it is verified
RED first, on the new test, before the
src/tui.rschange:That is the bug in one line: the queued row claimed delivery.
After the change:
New test
identical_bodies_join_by_message_id_not_body: two outbound messageswith identical text, only the older one queued (the ordering the body match
got wrong) → row 0 carries
◷ queuedand no✓, row 1 keeps✓, footer says1 queued.renders_a_queued_row_from_a_real_outbox_sendstill passes unchanged: it readsreal
Outbox::pending()rows (message_idset by the store) against reallist_messages()rows, so the id join is exercised against a real sqlite store,not only against fixtures.
Honest finding, out of scope here —
crates/onionwire-sdkdoes not compileonionwire-sdkis a separate cargo workspace, and root CI only runscargo test/cargo clippyat the root, so neither #45 nor #48 caught this:Pre-existing on this stack, not caused by this commit — proven by stashing this
diff and rebuilding the SDK on
ebd3a30alone (same E0308). It is PR #45'sNode::send() -> Result<OutboxStatus, String>change; the SDK still expectsResult<()>.crates/onionwire-sdk/**is out of scope for this card, so it isleft alone and filed as a follow-up task rather than smuggled in here.
Scope
Changed files:
src/store.rs,src/tui.rs,tests/tui_spec.rs,docs/TUI.md.No new crate, no wire change, no new wire prefix, no server, no README change.
rustfmtwas not run repo-wide (the tree is not rustfmt-clean and a plaincargo fmtwould add drive-by churn to parent-owned files).N queuedfooterafff5f8dff2cbe7d41e5