feat: optimistic message rendering with reconcile#94
Merged
ImpulseB23 merged 2 commits intomainfrom Apr 20, 2026
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Adds an optimistic-send path so locally-authored Twitch messages render immediately on Enter, then reconcile in-place with the authoritative platform echo (using Helix message_id when available, otherwise a bounded fingerprint scan).
Changes:
- Extend
chatStorewith pending/failed message state, reconciliation, and a mutation signal for in-place updates. - Update UI to insert pending messages on submit, dim pending entries, and allow click-to-retry for failed sends.
- Return Helix
message_idfrom the Rusttwitch_send_messagecommand and surface it through the frontendsendMessageAPI.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| apps/desktop/src/stores/chatStore.ts | Adds optimistic message model fields, pending insert/confirm/fail/retry APIs, reconcile logic, and messageRevision. |
| apps/desktop/src/stores/chatStore.test.ts | Adds unit tests covering optimistic insert + reconciliation behaviors and state transitions. |
| apps/desktop/src/lib/twitchAuth.ts | Changes sendMessage to return { message_id } on success. |
| apps/desktop/src/components/MessageInput.tsx | Inserts optimistic pending message before sending; confirms/fails pending based on command result; now requires login prop. |
| apps/desktop/src/components/ChatFeed.tsx | Invalidates prepared-layout cache on message mutations; renders pending/failed styling and supports click-to-retry. |
| apps/desktop/src/App.tsx | Wires authenticated login into MessageInput. |
| apps/desktop/src-tauri/src/sidecar_commands.rs | Updates twitch_send_message to return a success payload containing message_id. |
| apps/desktop/src-tauri/src/host.rs | Documents SendChatResult.message_id as frontend-consumed for optimistic reconciliation. |
Comments suppressed due to low confidence (1)
apps/desktop/src/stores/chatStore.ts:222
- The createChatStore doc comment says there is a “single viewport signal”, but this change introduces an additional
messageRevisionsignal. Update the comment to reflect the new reactive surface (or consolidate to one signal if that’s the intent).
/**
* Creates a chat store backed by a plain pre-allocated ring buffer. Writes
* happen synchronously; the single viewport signal is batched into one
* `requestAnimationFrame` tick so multiple batches arriving within the same
* frame coalesce into exactly one reactive update.
b03bb1e to
b9a1c40
Compare
b9a1c40 to
8bc22a5
Compare
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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.
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)
Frontend (UI)
Backend
Tests