notedeck

One damus client to rule them all
git clone git://jb55.com/notedeck
Log | Files | Refs | README | LICENSE

commit e483cfd9e23dc0bf92b19ce19ed92c3848ec0607
parent 2836d0d271e5d899fef9750fd896116ffdd498a5
Author: William Casarin <jb55@jb55.com>
Date:   Tue, 24 Feb 2026 10:05:00 -0800

session_loader: use seq tag as tiebreaker for message ordering

created_at has second granularity, so multiple events within the same
second (common during streaming/tool calls) had non-deterministic order.
Use the per-session seq tag as a tiebreaker to preserve correct ordering.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Diffstat:
Mcrates/notedeck_dave/src/session_loader.rs | 10++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/crates/notedeck_dave/src/session_loader.rs b/crates/notedeck_dave/src/session_loader.rs @@ -115,8 +115,14 @@ pub fn load_session_messages(ndb: &Ndb, txn: &Transaction, session_id: &str) -> .filter_map(|qr| ndb.get_note_by_key(txn, qr.note_key).ok()) .collect(); - // Sort by created_at (chronological order) - notes.sort_by_key(|note| note.created_at()); + // Sort by created_at first, then by seq tag as tiebreaker for events + // within the same second (seq is per-session, not globally ordered) + notes.sort_by_key(|note| { + let seq = get_tag_value(note, "seq") + .and_then(|s| s.parse::<u32>().ok()) + .unwrap_or(0); + (note.created_at(), seq) + }); let event_count = notes.len() as u32; let note_ids: HashSet<[u8; 32]> = notes.iter().map(|n| *n.id()).collect();