Skip to content

Conversation

@ammar-agent
Copy link
Collaborator

Summary

Fixes a UX issue where there was an occasional delay between sending a message and it appearing in the chat window. During this delay, the input was cleared but the user message wasn't visible anywhere.

Root Cause

useDeferredValue (added in #1004 to improve streaming performance) was deferring all message list updates, including new user messages. This is correct for streaming deltas (where rapid updates benefit from deferral) but wrong for user-initiated messages (where immediate feedback is expected).

Fix

Compare the message counts between the current and deferred values:

  • Count differs (new message added) → Show immediately
  • Count same (content changes in existing messages) → Defer for performance

This preserves the streaming optimization while ensuring user messages appear instantly.

Testing

  • make static-check
  • make test on WorkspaceStore ✅

Generated with mux

When a user sends a message, useDeferredValue was causing a delay
before the message appeared in the chat window. This created bad UX
where the input was cleared but the message wasn't visible anywhere.

The fix compares message counts between the current and deferred
values. When the count differs (new message added), we show immediately.
When only content changes (streaming deltas), we still defer for
performance.

This preserves the streaming optimization from commit 5cc443d while
ensuring user messages appear instantly.
@chatgpt-codex-connector
Copy link

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@ammario ammario merged commit 72eb0ff into main Dec 9, 2025
20 checks passed
@ammario ammario deleted the fix-message-send-delay branch December 9, 2025 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants