fix: reload sufficient message history after streaming completes
Fixed issue where only middle portion of message history was visible
after streaming, missing both newest and oldest messages.
Root cause:
- Previous fix only fetched 10 most recent messages after streaming
- If user had loaded more messages via scroll, we'd lose them
- Temp user message (id: temp-*) wasn't being removed
- Insufficient messages fetched from server after completion
Solution:
- Count current loaded messages (excluding temp messages)
- Fetch at least currentCount + 5, minimum 50 messages
- Replace messages entirely (removes temp duplicates)
- Increased server finalization delay from 300ms to 500ms
Now preserves full message history while properly updating with
finalized versions from server that include reasoning and metadata.
Example: If user had scrolled to load 80 messages, we now fetch
85 messages after streaming instead of just 10.