feat: unified ordering foundation (effective_ts + arrival_seq)#93
Merged
ImpulseB23 merged 2 commits intomainfrom Apr 20, 2026
Merged
feat: unified ordering foundation (effective_ts + arrival_seq)#93ImpulseB23 merged 2 commits intomainfrom
ImpulseB23 merged 2 commits intomainfrom
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Pull request overview
Adds foundational fields and helpers for unified cross-platform message ordering (snap-based effective timestamps + stable tie-break sequencing) to support future unified feed interleaving and optimistic send (issue #88).
Changes:
- Extend
UnifiedMessage/ frontendChatMessagewitheffective_tsandarrival_seq. - Add snap-rule helper (
compute_effective_ts,SNAP_WINDOW_MS) and stampeffective_tsduring batch parsing. - Assign monotonic
arrival_seqin the drain loop before emitting message batches; update tests accordingly.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| apps/desktop/src/stores/chatStore.ts | Mirrors new ordering fields on the frontend ChatMessage type with usage guidance. |
| apps/desktop/src/stores/chatStore.test.ts | Updates test message factory to include the new fields. |
| apps/desktop/src-tauri/src/sidecar_supervisor.rs | Introduces drain-loop-owned arrival sequence counter and stamps batches before emitting. |
| apps/desktop/src-tauri/src/message.rs | Adds effective_ts/arrival_seq to UnifiedMessage, snap-rule helper, and unit tests. |
| apps/desktop/src-tauri/src/host.rs | Stamps effective_ts in parse_batch and adds a unit test for the snap behavior. |
ImpulseB23
added a commit
that referenced
this pull request
Apr 20, 2026
Closes #88. Stacked on #93. Adds an optimistic-send path so locally-authored messages render the moment the user hits Enter, without waiting for the platform echo round-trip. **Frontend (chatStore)** - ChatMessage gains optional status (pending|failed), local_id, error_message - New API: insertPending, confirmPendingId, failPending, retryPending, plus messageRevision signal for in-place mutation - Reconcile incoming echo against pending tail by id (after confirm) or fingerprint (platform + username + text + 30s window) - Pending arrival_seq sourced from MAX_SAFE_INTEGER - 1M base so they sort to tail in any future cross-platform sort layer - buildOptimisticMessage helper builds the pending entry from {platform, login, text} **Frontend (UI)** - MessageInput now takes the user login, builds optimistic, inserts, then sends; on success calls confirmPendingId, on failure calls failPending - ChatFeed subscribes to messageRevision and clears its prepared-layout cache on bump; pending entries render at 0.55 opacity, failed entries get a red left-border + click-to-retry - twitchAuth.sendMessage now returns Promise<{ message_id }> **Backend** - twitch_send_message returns Result<SendChatOk, SendCommandError> with the Helix message_id so the frontend can swap the local id for the authoritative one before the echo arrives **Tests** - 11 new chatStore tests cover insertPending, reconcile-by-id, reconcile-by-fingerprint, fingerprint window expiry, cross-platform isolation, failPending, retryPending state machine, scan-tail bound, multi-pending ordering - All 73 vitest tests + 187 cargo tests pass; clippy/fmt/tsc/eslint/prettier clean
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds the foundation for cross-platform message ordering and optimistic send (issue #88).
What
UnifiedMessagegains two fields:effective_ts: i64— sort timestamp under the snap rulearrival_seq: u64— monotonic per-process tie-breakerSNAP_WINDOW_MS = 500and pure helpercompute_effective_ts(timestamp, arrival_time)assign_arrival_seqs(batch, &mut counter)stamps a whole batchChatMessagemirrors the new fieldsSnap rule
Trust the platform clock when it agrees with local arrival, otherwise fall back to arrival time. The sort key
(effective_ts, arrival_seq)is stable across renderers and gives us coherent interleave for Twitch + YouTube + Kick without any custom sync server.Why now
This is the substrate for issue #88 (optimistic send) and the future cross-platform unified feed. Both reuse the same machinery: optimistic sends start with
effective_ts = now(), get re-anchored to the authoritative event when it echoes back.Tests