useUIMessages / streaming freezes when message count approaches initialNumItems limit
- Dominant language
- TypeScript
- Stars
- 349
- Forks
- 92
- Avg merge
- 3d 10h
- Merged PRs (30d)
- 24
Description
When using `useUIMessages` (or `useThreadMessages`) with an `initialNumItems` limit, streaming consistently freezes once the thread's message count approaches that limit. The stream completes successfully on the backend, but the frontend remains stuck in a streaming state.
## Reproduction Steps
1. Set `initialNumItems: 20` in the messages hook (or any value)
2. Have a conversation that accumulates messages approaching that limit
3. Send a new message when message count is near/at the limit
4. **Result:** Frontend freezes in streaming state indefinitely
## Expected Behavior
Streaming should complete normally regardless of how many messages exist in the thread relative to `initialNumItems`.
## Actual Behavior
- **Backend:** Stream completes successfully (`onFinish`, `consumeStream` all fire correctly)
- **Frontend:** UI remains stuck in streaming state
## Environment
- `@convex-dev/agent`: PR #186 build (`https://pkg.pr.new/get-convex/agent/@convex-dev/agent@186`)
- `ai`: `^5.0.44`
- Framework: React Native / Expo
Contributor guide
Research direction
Start by reproducing the freeze with useUIMessages or useThreadMessages and an initialNumItems limit near the thread's message count. Trace the frontend streaming completion path, using the backend's successful onFinish and consumeStream behavior as a comparison. Done means the React Native/Expo UI leaves the streaming state normally at and around the limit.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react-native, typescript
- Domain
- frontend, mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100